Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing tests reported by SimpleCov #1241

Merged
merged 8 commits into from
May 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions lib/faker/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def random_type
rb_string
when :fixnum
rb_integer
else
rb_integer
end
end

Expand All @@ -70,8 +68,6 @@ def random_complex_type
rb_hash
when :array
rb_array
else
rb_integer
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By reading the code, I noticed that the code will never pass in the else statements, therefore I believe we should just delete the statements.

Copy link
Author

@aamarill aamarill May 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those else statements give a bit more flexibility to quickly edit the constants in the class. But I wasn't sure if that's worth not getting 100% test coverage. Thanks for clarifying that!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the code is basically working with the values inside the SIMPLE_TYPES and COMPLEX_TYPES arrays and as we can see, integer isn't declared.

end

Expand Down
14 changes: 14 additions & 0 deletions test/test_faker_char.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/test_faker_unique_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ 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)
assert_equal(generator.send(:respond_to_missing?, 'address'), false)
end

def test_returns_error_when_retries_exceeded
stubbed_generator = Object.new
def stubbed_generator.test
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
SimpleCov.start do
add_filter ['.bundle', 'test']
add_filter ['.bundle', 'test', 'lib/extensions']
end

require 'test/unit'
Expand Down
1 change: 1 addition & 0 deletions test/test_ru_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_uk_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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