faker 1.6.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +13 -0
  3. data/README.md +185 -23
  4. data/lib/faker.rb +20 -0
  5. data/lib/faker/app.rb +1 -1
  6. data/lib/faker/beer.rb +1 -1
  7. data/lib/faker/chuck_norris.rb +16 -0
  8. data/lib/faker/code.rb +59 -0
  9. data/lib/faker/company.rb +19 -0
  10. data/lib/faker/crypto.rb +19 -0
  11. data/lib/faker/date.rb +30 -2
  12. data/lib/faker/educator.rb +23 -0
  13. data/lib/faker/file.rb +23 -0
  14. data/lib/faker/internet.rb +24 -15
  15. data/lib/faker/lorem.rb +21 -7
  16. data/lib/faker/music.rb +21 -0
  17. data/lib/faker/name.rb +7 -0
  18. data/lib/faker/placeholdit.rb +3 -3
  19. data/lib/faker/space.rb +54 -0
  20. data/lib/faker/time.rb +7 -18
  21. data/lib/faker/vehicle.rb +37 -0
  22. data/lib/faker/version.rb +1 -1
  23. data/lib/faker/yoda.rb +10 -0
  24. data/lib/locales/de.yml +26 -8
  25. data/lib/locales/en-GB.yml +1 -1
  26. data/lib/locales/en-PAK.yml +17 -0
  27. data/lib/locales/en.yml +195 -4
  28. data/lib/locales/es-MX.yml +82 -0
  29. data/lib/locales/es.yml +4 -0
  30. data/lib/locales/fr.yml +7 -4
  31. data/lib/locales/pt-BR.yml +51 -23
  32. metadata +13 -103
  33. data/test/test_array_sample_method_compat.rb +0 -56
  34. data/test/test_avatar.rb +0 -43
  35. data/test/test_ca_cat_locale.rb +0 -35
  36. data/test/test_ca_locale.rb +0 -22
  37. data/test/test_da_dk_locale.rb +0 -32
  38. data/test/test_en_au_locale.rb +0 -24
  39. data/test/test_en_au_ocker_locale.rb +0 -25
  40. data/test/test_en_ca_locale.rb +0 -18
  41. data/test/test_en_locale.rb +0 -35
  42. data/test/test_en_nz_locale.rb +0 -33
  43. data/test/test_en_ug_locale.rb +0 -23
  44. data/test/test_en_us_locale.rb +0 -89
  45. data/test/test_es_locale.rb +0 -34
  46. data/test/test_faker.rb +0 -29
  47. data/test/test_faker_app.rb +0 -12
  48. data/test/test_faker_beer.rb +0 -41
  49. data/test/test_faker_bitcoin.rb +0 -14
  50. data/test/test_faker_book.rb +0 -24
  51. data/test/test_faker_boolean.rb +0 -23
  52. data/test/test_faker_business.rb +0 -34
  53. data/test/test_faker_cat.rb +0 -20
  54. data/test/test_faker_city.rb +0 -52
  55. data/test/test_faker_code.rb +0 -35
  56. data/test/test_faker_color.rb +0 -50
  57. data/test/test_faker_commerce.rb +0 -84
  58. data/test/test_faker_company.rb +0 -34
  59. data/test/test_faker_date.rb +0 -89
  60. data/test/test_faker_hacker_talk.rb +0 -37
  61. data/test/test_faker_hipster.rb +0 -78
  62. data/test/test_faker_internet.rb +0 -190
  63. data/test/test_faker_lorem.rb +0 -87
  64. data/test/test_faker_name.rb +0 -20
  65. data/test/test_faker_number.rb +0 -107
  66. data/test/test_faker_shakespeare.rb +0 -53
  67. data/test/test_faker_slack_emoji.rb +0 -45
  68. data/test/test_faker_star_wars.rb +0 -74
  69. data/test/test_faker_street.rb +0 -58
  70. data/test/test_faker_superhero.rb +0 -16
  71. data/test/test_faker_team.rb +0 -25
  72. data/test/test_faker_time.rb +0 -93
  73. data/test/test_faker_university.rb +0 -20
  74. data/test/test_fi_locale.rb +0 -33
  75. data/test/test_flexible.rb +0 -62
  76. data/test/test_helper.rb +0 -12
  77. data/test/test_locale.rb +0 -47
  78. data/test/test_pl_locale.rb +0 -24
  79. data/test/test_placeholdit.rb +0 -92
  80. data/test/test_pt_locale.rb +0 -27
  81. data/test/test_sv_locale.rb +0 -28
  82. data/test/test_uk_locale.rb +0 -44
@@ -1,45 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerSlackEmoji < Test::Unit::TestCase
4
-
5
- def setup
6
- @tester = Faker::SlackEmoji
7
- @emoticon_regex= /^:([\w-]+):$/
8
- end
9
-
10
- def test_people
11
- assert @tester.people.match(@emoticon_regex)
12
- end
13
-
14
- def test_nature
15
- assert @tester.nature.match(@emoticon_regex)
16
- end
17
-
18
- def test_food_and_drink
19
- assert @tester.food_and_drink.match(@emoticon_regex)
20
- end
21
-
22
- def test_celebration
23
- assert @tester.celebration.match(@emoticon_regex)
24
- end
25
-
26
- def test_activity
27
- assert @tester.activity.match(@emoticon_regex)
28
- end
29
-
30
- def test_travel_and_places
31
- assert @tester.travel_and_places.match(@emoticon_regex)
32
- end
33
-
34
- def test_objects_and_symbols
35
- assert @tester.objects_and_symbols.match(@emoticon_regex)
36
- end
37
-
38
- def test_custom
39
- assert @tester.custom.match(@emoticon_regex)
40
- end
41
-
42
- def test_emoji
43
- assert @tester.emoji.match(@emoticon_regex)
44
- end
45
- end
@@ -1,74 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerStarWars < Test::Unit::TestCase
4
- def setup
5
- @characters = Faker::StarWars.characters
6
- @droids = Faker::StarWars.droids
7
- @planets = Faker::StarWars.planets
8
- @quotes = Faker::StarWars.quotes
9
- @species = Faker::StarWars.species
10
- @vehicles = Faker::StarWars.vehicles
11
- end
12
-
13
- def test_strings
14
- assert @characters.size == 33
15
- @characters.each do |character|
16
- assert !character.nil?
17
- assert character != ""
18
- end
19
-
20
- assert @droids.size == 21
21
- @droids.each do |droid|
22
- assert !droid.nil?
23
- assert droid != ""
24
- end
25
-
26
- assert @planets.size == 20
27
- @planets.each do |planet|
28
- assert !planet.nil?
29
- assert planet != ""
30
- end
31
-
32
- assert @quotes.size == 30
33
- @quotes.each do |quote|
34
- assert !quote.nil?
35
- assert quote != ""
36
- end
37
-
38
- assert @species.size == 9
39
- @species.each do |specie|
40
- assert !specie.nil?
41
- assert specie != ""
42
- end
43
-
44
- assert @vehicles.size == 21
45
- @vehicles.each do |vehicle|
46
- assert !vehicle.nil?
47
- assert vehicle != ""
48
- end
49
- end
50
-
51
- def test_character
52
- assert Faker::StarWars.character.match(/\w+/)
53
- end
54
-
55
- def test_droid
56
- assert Faker::StarWars.droid.match(/\w+/)
57
- end
58
-
59
- def test_planet
60
- assert Faker::StarWars.planet.match(/\w+/)
61
- end
62
-
63
- def test_quote
64
- assert Faker::StarWars.quote.match(/\w+/)
65
- end
66
-
67
- def test_specie
68
- assert Faker::StarWars.specie.match(/\w+/)
69
- end
70
-
71
- def test_vehicle
72
- assert Faker::StarWars.vehicle.match(/\w+/)
73
- end
74
- end
@@ -1,58 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestFakerStreet < Test::Unit::TestCase
4
- def setup
5
- @old_locales = I18n.config.available_locales
6
- shire = {
7
- :faker => {
8
- :address => {
9
- :street_name => ['#{street_prefix} #{street_root} #{street_suffix}'],
10
- :street_prefix => ["Wide"],
11
- :street_root => ["Cheerful"],
12
- :street_suffix => ["Path"],
13
- :secondary_address => ["(Green Door)"],
14
- :street_address => ['#{street_name} #{building_number}'],
15
- :building_number => ["#"],
16
- :time_zone => ["Pacific/Pago_Pago"],
17
- }
18
- }
19
- }
20
- I18n.backend.store_translations(:shire, shire)
21
- I18n.config.available_locales += [ :shire ]
22
- end
23
-
24
- def teardown
25
- I18n.config.available_locales = @old_locales
26
- end
27
-
28
- def test_street_name_supports_flexible_formats
29
- I18n.with_locale(:shire) do
30
- assert_equal "Wide Cheerful Path", Faker::Address.street_name
31
- end
32
- end
33
-
34
- def test_street_address_supports_flexible_formats
35
- I18n.with_locale(:shire) do
36
- assert_match(/Wide Cheerful Path \d/, Faker::Address.street_address)
37
- end
38
- end
39
-
40
- def test_street_address_optionally_provides_secondary_address
41
- I18n.with_locale(:shire) do
42
- assert_match(/Wide Cheerful Path \d \(Green Door\)/, Faker::Address.street_address(:include_secondary))
43
- end
44
- end
45
-
46
- def test_street_address_with_locale_fallback
47
- I18n.with_locale('en-GB') do
48
- assert_match(/^\d+ [\w']+ \w+/, Faker::Address.street_address)
49
- end
50
- end
51
-
52
- def test_timezone_support
53
- I18n.with_locale(:shire) do
54
- assert_equal "Pacific/Pago_Pago", Faker::Address.time_zone
55
- end
56
- end
57
-
58
- end
@@ -1,16 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerSuperhero < Test::Unit::TestCase
4
-
5
- def setup
6
- @tester = Faker::Superhero
7
- end
8
-
9
- def test_power
10
- assert @tester.power.match(/\w+\.?/)
11
- end
12
-
13
- def test_name
14
- assert @tester.name.match(/\w+\.?/)
15
- end
16
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerTeam < Test::Unit::TestCase
4
-
5
- def setup
6
- @tester = Faker::Team
7
- end
8
-
9
- def test_name
10
- assert @tester.name.match(/(\w+\.? ?){2}/)
11
- end
12
-
13
- def test_creature
14
- assert @tester.creature.match(/(\w+){1}/)
15
- end
16
-
17
- def test_state
18
- assert @tester.state.match(/(\w+){1}/)
19
- end
20
-
21
- def test_sport
22
- assert @tester.sport.match(/(\w+){1}/)
23
- end
24
-
25
- end
@@ -1,93 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerTime < Test::Unit::TestCase
4
- TEN_HOURS = 36000
5
-
6
- def setup
7
- @tester = Faker::Time
8
- @time_ranges = Faker::Time::TIME_RANGES
9
- end
10
-
11
- def test_between_with_time_parameters
12
- from = Time.local(2014, 12, 28, 06, 0, 0)
13
- to = Time.local(2014, 12, 30, 13, 0, 0)
14
-
15
- 100.times do
16
- random_time = @tester.between(from, to)
17
- assert random_time >= from, "Expected >= \"#{from}\", but got #{random_time}"
18
- assert random_time <= to , "Expected <= \"#{to}\", but got #{random_time}"
19
- end
20
- end
21
-
22
- def test_between_with_date_parameters
23
- from = Date.parse("2014-12-28")
24
- to = Date.parse("2014-12-30")
25
-
26
- 100.times do
27
- random_time = @tester.between(from, to)
28
- assert random_time.to_date >= from, "Expected >= \"#{from}\", but got #{random_time}"
29
- assert random_time.to_date <= to , "Expected <= \"#{to}\", but got #{random_time}"
30
- end
31
- end
32
-
33
- def test_forward
34
- today = Date.today
35
-
36
- 100.times do
37
- random_time = @tester.forward(10)
38
- assert random_time > today.to_time, "Expected > \"#{today}\", but got #{random_time}"
39
- end
40
- end
41
-
42
- def test_backward
43
- tomorrow = Date.today + 1
44
-
45
- 100.times do
46
- random_time = @tester.backward(10)
47
- assert random_time < tomorrow.to_time, "Expected < \"#{tomorrow}\", but got #{random_time}"
48
- end
49
- end
50
-
51
- def test_invalid_period_error
52
- from = Date.today
53
- to = Date.today + 15
54
-
55
- assert_raise ArgumentError do
56
- @tester.between(from, to, :invalid_period)
57
- end
58
- end
59
-
60
- def test_return_type
61
- random_backward = @tester.backward(5)
62
- random_between_dates = @tester.between(Date.today, Date.today + 5)
63
- random_between_times = @tester.between(Time.now, Time.now + TEN_HOURS)
64
- random_forward = @tester.forward(5)
65
-
66
- [
67
- random_backward,
68
- random_between_dates,
69
- random_between_times,
70
- random_forward
71
- ].each do |result|
72
- assert result.is_a?(Time), "Expected a Time object, but got #{result.class}"
73
- end
74
- end
75
-
76
- def test_time_period
77
- from = Date.today
78
- to = Date.today + 15
79
-
80
- 100.times do
81
- period = @time_ranges.keys.to_a.sample
82
- period_range = @time_ranges[period]
83
-
84
- random_backward = @tester.backward(30, period)
85
- random_between = @tester.between(from, to, period)
86
- random_forward = @tester.forward(30, period)
87
-
88
- [random_backward, random_between, random_forward].each do |result|
89
- assert period_range.include?(result.hour.to_i), "\"#{result.hour}\" expected to be included in Faker::Time::TIME_RANGES[:#{period}] range"
90
- end
91
- end
92
- end
93
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TestFakerUniversity < Test::Unit::TestCase
4
- def setup
5
- @tester = Faker::University
6
- end
7
-
8
- def test_prefix
9
- assert @tester.prefix.match(/\w+\.?/)
10
- end
11
-
12
- def test_suffix
13
- assert @tester.suffix.match(/\w+\.?/)
14
- end
15
-
16
- def test_name
17
- assert @tester.name.match(/\w+\.?/)
18
- end
19
-
20
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
-
3
- class TesetEnLocale < Test::Unit::TestCase
4
- def setup
5
- Faker::Config.locale = 'fi-FI'
6
- end
7
-
8
- def teardown
9
- Faker::Config.locale = nil
10
- end
11
-
12
- def test_fi_methods
13
- assert Faker::Name.first_name_women.is_a? String
14
- assert Faker::Name.first_name_men.is_a? String
15
- assert Faker::Name.first_name.is_a? String
16
- assert Faker::Name.last_name.is_a? String
17
- assert Faker::Address.street_name.is_a? String
18
- assert Faker::Address.city.is_a? String
19
- end
20
-
21
- def test_fi_phone_number
22
- assert_match /0\d{2}[\-\s]?\d{6}/, Faker::PhoneNumber.cell_phone
23
- assert_match /\d{2,3}[\s\-]?\d{5,6}/, Faker::PhoneNumber.phone_number
24
- end
25
-
26
- def test_fi_building_number
27
- assert_match /^[\d]{1,3}$/, Faker::Address.building_number
28
- end
29
-
30
- def test_fi_post_code
31
- assert_match /^[\d]{5}$/, Faker::Address.postcode
32
- end
33
- end
@@ -1,62 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- module Faker
4
- class Foodie < Base
5
- flexible :chow
6
- end
7
- end
8
-
9
- class TestFlexible < Test::Unit::TestCase
10
-
11
- def setup
12
- @old_locales = I18n.config.available_locales
13
- I18n.backend.store_translations(:xx, :faker => {:chow => {:yummie => [:fudge, :chocolate, :caramel], :taste => "delicious"}})
14
- I18n.backend.store_translations(:home, :faker => {:address => {:birthplace => [:bed, :hospital, :airplane]}})
15
- I18n.backend.store_translations(:kindergarden, :faker => {:name => {:girls_name => [:alice, :cheryl, :tatiana]}})
16
- I18n.backend.store_translations(:work, :faker => {:company => {:do_stuff => [:work, :work, :work]}})
17
- I18n.config.available_locales += [ :xx, :home, :kindergarden, :work ]
18
- end
19
-
20
- def teardown
21
- I18n.config.available_locales = @old_locales
22
- end
23
-
24
- def test_flexible_multiple_values
25
- I18n.with_locale(:xx) do
26
- actual = Faker::Foodie.yummie
27
- assert [:fudge, :chocolate, :caramel].include? actual
28
- end
29
- end
30
-
31
- def test_flexible_single_value
32
- I18n.with_locale(:xx) do
33
- assert_equal "delicious", Faker::Foodie.taste
34
- end
35
- end
36
-
37
- def test_raises_no_method_error
38
- I18n.with_locale(:xx) do
39
- assert_raise(NoMethodError) do
40
- Faker::Foodie.eeew
41
- end
42
- end
43
- end
44
-
45
- def test_address_is_flexible
46
- I18n.with_locale(:home) do
47
- assert [:bed, :hospital, :airplane].include? Faker::Address.birthplace
48
- end
49
- end
50
-
51
- def test_name_is_flexible
52
- I18n.with_locale(:kindergarden) do
53
- assert [:alice, :cheryl, :tatiana].include? Faker::Name.girls_name
54
- end
55
- end
56
-
57
- def test_company_is_flexible
58
- I18n.with_locale(:work) do
59
- assert Faker::Company.do_stuff == :work
60
- end
61
- end
62
- end
@@ -1,12 +0,0 @@
1
- require 'test/unit'
2
- require 'rubygems'
3
- require 'yaml'
4
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
5
- require File.expand_path(File.dirname(__FILE__) + '/../lib/faker')
6
-
7
- # configure I18n
8
- locales_path = File.expand_path(File.dirname(__FILE__) + '../lib/locales')
9
- I18n.available_locales = Dir[locales_path + '/*'].map do |file|
10
- file.split('.').first
11
- end
12
- I18n.enforce_available_locales = true