From a04b3d76c0b11c7716cb8a04aba0b086830fd385 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Mon, 21 May 2018 22:30:00 -0700 Subject: [PATCH 1/6] Add some tests --- test/test_faker_company.rb | 4 ++++ test/test_faker_measurement.rb | 2 +- test/test_faker_types.rb | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/test_faker_company.rb b/test/test_faker_company.rb index 647b467d5a..d76a386f2a 100644 --- a/test/test_faker_company.rb +++ b/test/test_faker_company.rb @@ -99,6 +99,10 @@ def test_polish_register_of_national_economy assert control_number == number[13].to_i end + def test_mod11 + assert @tester.send(:mod11, 0) + end + private def abn_checksum(abn) diff --git a/test/test_faker_measurement.rb b/test/test_faker_measurement.rb index 21fbb68cda..1d78494c7c 100644 --- a/test/test_faker_measurement.rb +++ b/test/test_faker_measurement.rb @@ -5,7 +5,7 @@ def setup @tester = Faker::Measurement end - def height + def test_height assert @tester.height.match(/\d\s[a-z]/) assert @tester.height(1).match(/\d\s[a-z]/) end diff --git a/test/test_faker_types.rb b/test/test_faker_types.rb index 471a6b8279..360993102e 100644 --- a/test/test_faker_types.rb +++ b/test/test_faker_types.rb @@ -72,4 +72,11 @@ def test_titleize expected = 'Foobar' assert @tester.send(:titleize, val) == expected end + + def test_resolve + array = [1, 2, 3] + range = 1..10 + assert array.include?(@tester.send(:resolve, array)) + assert range.include?(@tester.send(:resolve, range)) + end end From 2a57e3a8b6c1c4d607a64baca1869a2caeed1644 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Tue, 22 May 2018 13:33:11 -0700 Subject: [PATCH 2/6] Add more tests --- test/test_faker_char.rb | 14 ++++++++++++++ test/test_ru_locale.rb | 1 + test/test_uk_locale.rb | 4 ++++ 3 files changed, 19 insertions(+) create mode 100644 test/test_faker_char.rb diff --git a/test/test_faker_char.rb b/test/test_faker_char.rb new file mode 100644 index 0000000000..36b9601064 --- /dev/null +++ b/test/test_faker_char.rb @@ -0,0 +1,14 @@ +require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb') + +class TestFakerChar < Test::Unit::TestCase + def setup + @tester = Faker::Char + end + + def test_fix_umlauts + assert @tester.fix_umlauts('ä') == 'ae' + assert @tester.fix_umlauts('ö') == 'oe' + assert @tester.fix_umlauts('ü') == 'ue' + assert @tester.fix_umlauts('ß') == 'ss' + end +end diff --git a/test/test_ru_locale.rb b/test/test_ru_locale.rb index fa4f54ae9d..2f79350124 100644 --- a/test/test_ru_locale.rb +++ b/test/test_ru_locale.rb @@ -36,6 +36,7 @@ def test_ru_methods assert Faker::Company.prefix.is_a? String assert Faker::Company.suffix.is_a? String assert Faker::Company.name.is_a? String + assert Faker::Char.romanize_cyrillic('').is_a? String end def test_ru_default_country diff --git a/test/test_uk_locale.rb b/test/test_uk_locale.rb index 1104554719..f25da34249 100644 --- a/test/test_uk_locale.rb +++ b/test/test_uk_locale.rb @@ -41,4 +41,8 @@ def test_uk_states_do_not_have_abbreviations def test_uk_company_prefix_returns_true_value assert_send([Faker::Company, :prefix]) end + + def test_uk_romanize_cyrillic + assert Faker::Char.romanize_cyrillic('').is_a? String + end end From c7d246397b9aa3645b18bcc391e0064d9fe209cd Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Wed, 23 May 2018 22:24:55 -0300 Subject: [PATCH 3/6] Remove unnecessary else statements --- lib/faker/types.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/faker/types.rb b/lib/faker/types.rb index b4c71d74a5..e548abaae1 100644 --- a/lib/faker/types.rb +++ b/lib/faker/types.rb @@ -53,8 +53,6 @@ def random_type rb_string when :fixnum rb_integer - else - rb_integer end end @@ -70,8 +68,6 @@ def random_complex_type rb_hash when :array rb_array - else - rb_integer end end From 7373a2089ab4d782e1f557155eab1aff876ea643 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Wed, 23 May 2018 22:45:37 -0300 Subject: [PATCH 4/6] Add faker unique generator missing test --- test/test_faker_unique_generator.rb | 8 ++++++++ test/test_helper.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_faker_unique_generator.rb b/test/test_faker_unique_generator.rb index ae1823712e..9d1f25c2b0 100644 --- a/test/test_faker_unique_generator.rb +++ b/test/test_faker_unique_generator.rb @@ -8,6 +8,14 @@ def test_generates_unique_values assert_equal([1, 2], result.sort) end + def test_respond_to_missing + stubbed_generator = Object.new + + generator = Faker::UniqueGenerator.new(stubbed_generator, 3) + + assert_equal(generator.send(:respond_to_missing?, 'faker_address'), true) + end + def test_returns_error_when_retries_exceeded stubbed_generator = Object.new def stubbed_generator.test diff --git a/test/test_helper.rb b/test/test_helper.rb index ca928dea4f..7fc43709c4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,7 @@ require 'simplecov-console' SimpleCov.formatter = SimpleCov.formatter = SimpleCov::Formatter::Console SimpleCov.start do - add_filter ['.bundle', 'test'] + add_filter ['.bundle', 'test', 'lib/extensions'] end require 'test/unit' From 7c2b62365df782427c87806dcd14a0bf8d8c51c8 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Wed, 23 May 2018 22:56:02 -0300 Subject: [PATCH 5/6] Add more unique generator tests --- test/test_faker_unique_generator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_faker_unique_generator.rb b/test/test_faker_unique_generator.rb index 9d1f25c2b0..53ca80c6d4 100644 --- a/test/test_faker_unique_generator.rb +++ b/test/test_faker_unique_generator.rb @@ -14,6 +14,7 @@ def test_respond_to_missing generator = Faker::UniqueGenerator.new(stubbed_generator, 3) assert_equal(generator.send(:respond_to_missing?, 'faker_address'), true) + assert_equal(generator.send(:respond_to_missing?, 'address'), false) end def test_returns_error_when_retries_exceeded From 1523fa39c4c9f7a6bee9ceabe04060cc8723262b Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Sat, 26 May 2018 21:12:08 -0300 Subject: [PATCH 6/6] Update changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4936798f89..d34ff4e919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - [PR #1117](https://github.com/stympy/faker/pull/1117) Added Ukrainian entries to yml [@RomanIsko](https://github.com/RomanIsko) ### Bug/Fixes +- [PR #1241](https://github.com/stympy/faker/pull/1241) Add missing tests reported by SimpleCov [@aamarill](https://github.com/aamarill) - [PR #1240](https://github.com/stympy/faker/pull/1240) Add some tests [@aamarill](https://github.com/aamarill) - [PR #1238](https://github.com/stympy/faker/pull/1238) pluralized file to match link name in the readme [@Connerh92](https://github.com/Connerh92) - [PR #1232](https://github.com/stympy/faker/pull/1232) Fix file permissions [@tagliala](https://github.com/tagliala)