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

Fix rubocop updates #2708

Merged
merged 5 commits into from
Feb 13, 2023
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
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ GEM
method_source (1.0.0)
minitest (5.17.0)
parallel (1.22.1)
parser (3.2.0.0)
parser (3.2.1.0)
ast (~> 2.4.1)
power_assert (2.0.2)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.2)
regexp_parser (2.7.0)
rexml (3.2.5)
rubocop (1.44.1)
rubocop (1.45.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
Expand All @@ -39,7 +39,7 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
rubocop-minitest (0.25.1)
rubocop-minitest (0.27.0)
rubocop (>= 0.90, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
Expand All @@ -66,8 +66,8 @@ DEPENDENCIES
minitest (= 5.17.0)
pry (= 0.14.2)
rake (= 13.0.6)
rubocop (= 1.44.1)
rubocop-minitest (= 0.25.1)
rubocop (= 1.45.1)
rubocop-minitest (= 0.27.0)
rubocop-rake (= 0.6.0)
simplecov (= 0.22.0)
test-unit (= 3.5.7)
Expand Down
4 changes: 2 additions & 2 deletions faker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency('minitest', '5.17.0')
spec.add_development_dependency('pry', '0.14.2')
spec.add_development_dependency('rake', '13.0.6')
spec.add_development_dependency('rubocop', '1.44.1')
spec.add_development_dependency('rubocop-minitest', '0.25.1')
spec.add_development_dependency('rubocop', '1.45.1')
spec.add_development_dependency('rubocop-minitest', '0.27.0')
spec.add_development_dependency('rubocop-rake', '0.6.0')
spec.add_development_dependency('simplecov', '0.22.0')
spec.add_development_dependency('test-unit', '3.5.7')
Expand Down
4 changes: 0 additions & 4 deletions lib/faker/travel/airport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class << self
# @faker.version next
def name(size:, region:)
fetch("airport.#{region}.#{size}")
rescue I18n::MissingTranslationData
p 'valid arguments are size && region -> US has size large medium small, EU has size large medium -- united_states || european_union'
end

##
Expand All @@ -38,8 +36,6 @@ def name(size:, region:)
# @faker.version next
def iata(size:, region:)
fetch("airport.#{region}.iata_code.#{size}")
rescue I18n::MissingTranslationData
p 'valid arguments are size && region -> US has size large medium small, EU has size large medium -- united_states || european_union'
end
end
end
Expand Down
41 changes: 26 additions & 15 deletions test/faker/default/test_faker_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@
class TestFakerJson < Test::Unit::TestCase
require 'json'

def setup
@tester = Faker::Json
def test_simple_json_lenght
expected_result_length = JSON.parse(simple_json).flatten.length

assert_same(expected_result_length, 6)
end

def test_shallow_json
json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
def test_nested_json_length
result = Faker::Json.add_depth_to_json(json: simple_json, options: { key: 'Name.first_name', value: 'Name.first_name' })

first_json_length = JSON.parse(result).flatten[1].flatten.length
second_json_length = JSON.parse(result).flatten[3].flatten.length
third_json_length = JSON.parse(result).flatten[5].flatten.length

assert JSON.parse(json).flatten.length.equal?(6)
assert_same(first_json_length, 6)
assert_same(second_json_length, 6)
assert_same(third_json_length, 6)
end

def test_add_depth_to_json
json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
json = Faker::Json.add_depth_to_json(json: json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
def test_nested_json_width_length
json = Faker::Json.add_depth_to_json(json: nested_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })

assert JSON.parse(json).flatten[1].flatten.length.equal?(6)
assert JSON.parse(json).flatten[3].flatten.length.equal?(6)
assert JSON.parse(json).flatten[5].flatten.length.equal?(6)
first_json_length = JSON.parse(json).flatten[1].flatten[1].flatten.length
second_json_length = JSON.parse(json).flatten[3].flatten[3].flatten.length

json = Faker::Json.add_depth_to_json(json: json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
assert_same(first_json_length, 6)
assert_same(second_json_length, 6)
end

def simple_json
Faker::Json.shallow_json(options: { key: 'Name.first_name', value: 'Name.first_name' })
end

assert JSON.parse(json).flatten[1].flatten[1].flatten.length.equal?(6)
assert JSON.parse(json).flatten[3].flatten[3].flatten.length.equal?(6)
assert JSON.parse(json).flatten[5].flatten[5].flatten.length.equal?(6)
def nested_json
Faker::Json.add_depth_to_json(json: simple_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
end
end
20 changes: 16 additions & 4 deletions test/faker/travel/test_faker_airports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ def setup
@tester = Faker::Travel::Airport
end

def name
assert_match(/\w+/, @tester.name)
def test_name
assert_match(/\w+/, @tester.name(size: 'small', region: 'united_states'))
end

def iata
assert_match(/\w+/, @tester.iata)
def test_iata
assert_match(/\w+/, @tester.iata(size: 'small', region: 'united_states'))
end

def test_name_with_invalid_arguments
assert_raises ArgumentError do
@tester.name(cats: 'meow', dogs: 'woof')
end
end

def test_iata_with_invalid_arguments
assert_raises ArgumentError do
@tester.iata(cats: 'meow', dogs: 'woof')
end
end
end