forked from faker-ruby/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_faker_city.rb
45 lines (40 loc) · 1.25 KB
/
test_faker_city.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require File.dirname(__FILE__) + '/test_helper.rb'
class TestFakerCity < Test::Unit::TestCase
def setup
xx = {
:faker => {
:name => {:first_name => ['alice'], :last_name => ['smith']},
:address => {:city_prefix => ['west'], :city_suffix => ['burg']}
}
}
I18n.backend.store_translations(:xx, xx)
xy = {
:faker => {
:address => {
:city_prefix => ['big'],
:city_root => ['rock'],
:city_root_suffix => ['ing'],
:city_suffix => ['town'],
:city => ['#{city_prefix} #{city_root}#{city_root_suffix} #{city_suffix}']
}
}
}
I18n.backend.store_translations(:xy, xy)
end
def test_default_city_formats
I18n.with_locale(:xx) do
100.times do
cities = ["west alice", "west smith", "west aliceburg", "west smithburg", "aliceburg", "smithburg"]
city = Faker::Address.city
assert cities.include?(city), "Expected <#{cities.join(' / ')}>, but got #{city}"
end
end
end
def test_city_formats_are_flexible
I18n.with_locale(:xy) do
cities = ['big rocking town']
city = Faker::Address.city
assert cities.include?(city), "Expected <#{cities.join(' / ')}>, but got #{city}"
end
end
end