From ed88904158226825a35277ece259a3a74d42f4dc Mon Sep 17 00:00:00 2001 From: Ryder Timberlake Date: Thu, 22 Sep 2016 23:53:41 -0400 Subject: [PATCH 1/4] Changed specie to species and species to species_list in StarWars. Made corresponding changes in test file --- lib/faker/star_wars.rb | 6 +++--- test/test_faker_star_wars.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/faker/star_wars.rb b/lib/faker/star_wars.rb index f91f279a06..d3cbfb919a 100644 --- a/lib/faker/star_wars.rb +++ b/lib/faker/star_wars.rb @@ -17,8 +17,8 @@ def quote quotes.sample end - def specie - species.sample + def species + species_list.sample end def vehicle @@ -54,7 +54,7 @@ def quotes "Fear is the path to the dark side... fear leads to anger... anger leads to hate... hate leads to suffering.", "Do. Or do not. There is no try."] end - def species + def species_list ['Ewok', 'Hutt', 'Gungan', 'Ithorian', 'Jawa', 'Neimoidian', 'Sullustan', 'Wookiee', 'Mon Calamari'] end diff --git a/test/test_faker_star_wars.rb b/test/test_faker_star_wars.rb index 93677572e0..52bf029049 100644 --- a/test/test_faker_star_wars.rb +++ b/test/test_faker_star_wars.rb @@ -6,7 +6,7 @@ def setup @droids = Faker::StarWars.droids @planets = Faker::StarWars.planets @quotes = Faker::StarWars.quotes - @species = Faker::StarWars.species + @species = Faker::StarWars.species_list @vehicles = Faker::StarWars.vehicles end @@ -64,8 +64,8 @@ def test_quote assert Faker::StarWars.quote.match(/\w+/) end - def test_specie - assert Faker::StarWars.specie.match(/\w+/) + def test_species + assert Faker::StarWars.species.match(/\w+/) end def test_vehicle From 6d7a6a9c5fd41a15cd0c3e4602b9ff5181880eb9 Mon Sep 17 00:00:00 2001 From: Ryder Timberlake Date: Sun, 25 Dec 2016 19:05:25 -0500 Subject: [PATCH 2/4] Added back the StarWars.specie method to ensure backwards compatibility. StarWars.specie now puts a deprecation warning before calling the StarWars.species method that replaces it. --- lib/faker/star_wars.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/faker/star_wars.rb b/lib/faker/star_wars.rb index af4a14e9af..c33c598f9b 100644 --- a/lib/faker/star_wars.rb +++ b/lib/faker/star_wars.rb @@ -75,6 +75,11 @@ def wookie_words ['wyaaaaaa', 'ruh', 'huewaa', 'muaa', 'mumwa', 'wua', 'ga', 'ma', 'ahuma', 'ooma', 'youw', 'kabukk', 'wyogg', 'gwyaaaag', 'roooarrgh', 'ur', 'ru', 'roo', 'hnn-rowr', 'yrroonn', 'nng', 'rarr'] end + + def specie + puts "#{self}.#{__method__} is deprecated and will be removed. Switch to the functionally identical #{self}.species at your convenience." + species + end end end end From 10b1ce23ef997ace701e24b54d20ca04b0ac1ad0 Mon Sep 17 00:00:00 2001 From: Ryder Timberlake Date: Sun, 25 Dec 2016 19:15:23 -0500 Subject: [PATCH 3/4] Added back a test for StarWars.specie --- test/test_faker_star_wars.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_faker_star_wars.rb b/test/test_faker_star_wars.rb index f42ec84a2d..216b5c6f6d 100644 --- a/test/test_faker_star_wars.rb +++ b/test/test_faker_star_wars.rb @@ -76,4 +76,8 @@ def test_vehicle def test_wookie_sentence assert Faker::StarWars.wookie_sentence.match(/\w+/) end + + def test_specie # Ensure StarWars.specie calls continue to work. To be removed when StarWars.specie is removed. + assert Faker::StarWars.specie.match(/\w+/) + end end From cf4d3b58ac805c369154a6d7500456bd15ca95c6 Mon Sep 17 00:00:00 2001 From: Ryder Timberlake Date: Sun, 25 Dec 2016 19:55:37 -0500 Subject: [PATCH 4/4] Added branching logic so that StarWars.specie deprecation warning isn't output when run from test suite --- lib/faker/star_wars.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/faker/star_wars.rb b/lib/faker/star_wars.rb index c33c598f9b..304a7e8615 100644 --- a/lib/faker/star_wars.rb +++ b/lib/faker/star_wars.rb @@ -77,7 +77,7 @@ def wookie_words end def specie - puts "#{self}.#{__method__} is deprecated and will be removed. Switch to the functionally identical #{self}.species at your convenience." + puts "#{self}.#{__method__} is deprecated and will be removed. Switch to the functionally identical #{self}.species at your convenience." unless caller[0].to_s.include? "test" species end end