Skip to content

Commit

Permalink
Add missing tests reported by SimpleCov (faker-ruby#1241)
Browse files Browse the repository at this point in the history
* Add some tests

* Add more tests

* Remove unnecessary else statements

* Add faker unique generator missing test

* Add more unique generator tests

* Update changelog.md
  • Loading branch information
Adan Amarillas authored and vbrazo committed May 27, 2018
1 parent c985fcd commit 33f20a4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
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
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

0 comments on commit 33f20a4

Please sign in to comment.