ffaker 1.18.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf3d5735d1734b8298c97b6c15d7969e3d9fd314
4
+ data.tar.gz: 5d36bb254c0400fe1ecaff37da9a07a8e41b1a22
5
+ SHA512:
6
+ metadata.gz: 58e441288b082a9d57dfeb206442d1997576a534ea22311d766ee32e1f3e0b7b83748e9cab3456f871197163370c7f51a5b69302de48f37def7036c0a56bf123
7
+ data.tar.gz: d28d57e87e90dd944204c4a799dbac5af7384daa51fcd1619f7b522f834cb9215ee2cfb7e4a3ddd0fdab5af051e332bd88259c1a9564c9a746f4d9543c1fa25f
data/Changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.19.0
2
+ More APIs
3
+
1
4
  ## 1.16.2
2
5
  Small bug fix and updated docs.
3
6
 
data/ffaker.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'ffaker'
7
- s.version = '1.18.0'
8
- s.date = '2013-08-06'
7
+ s.version = '1.19.0'
8
+ s.date = '2013-09-29'
9
9
  s.rubyforge_project = 'ffaker'
10
10
 
11
11
  s.summary = "Faster Faker, generates dummy data."
@@ -50,6 +50,8 @@ Gem::Specification.new do |s|
50
50
  lib/ffaker/hipster_ipsum.rb
51
51
  lib/ffaker/html_ipsum.rb
52
52
  lib/ffaker/identification.rb
53
+ lib/ffaker/identification_es.rb
54
+ lib/ffaker/identification_es_cl.rb
53
55
  lib/ffaker/internet.rb
54
56
  lib/ffaker/internet_se.rb
55
57
  lib/ffaker/job.rb
@@ -59,6 +61,7 @@ Gem::Specification.new do |s|
59
61
  lib/ffaker/movie.rb
60
62
  lib/ffaker/name.rb
61
63
  lib/ffaker/name_cn.rb
64
+ lib/ffaker/name_cs.rb
62
65
  lib/ffaker/name_da.rb
63
66
  lib/ffaker/name_de.rb
64
67
  lib/ffaker/name_ga.rb
@@ -73,6 +76,7 @@ Gem::Specification.new do |s|
73
76
  lib/ffaker/phone_number.rb
74
77
  lib/ffaker/phone_number_au.rb
75
78
  lib/ffaker/phone_number_da.rb
79
+ lib/ffaker/phone_number_de.rb
76
80
  lib/ffaker/phone_number_mx.rb
77
81
  lib/ffaker/phone_number_se.rb
78
82
  lib/ffaker/phone_number_sg.rb
@@ -111,6 +115,7 @@ Gem::Specification.new do |s|
111
115
  test/test_faker_job.rb
112
116
  test/test_faker_name.rb
113
117
  test/test_faker_name_cn.rb
118
+ test/test_faker_name_cs.rb
114
119
  test/test_faker_name_de.rb
115
120
  test/test_faker_name_ga.rb
116
121
  test/test_faker_name_ja.rb
@@ -125,6 +130,8 @@ Gem::Specification.new do |s|
125
130
  test/test_hipster_ipsum.rb
126
131
  test/test_html_ipsum.rb
127
132
  test/test_identification.rb
133
+ test/test_identification_es.rb
134
+ test/test_identification_es_cl.rb
128
135
  test/test_lorem.rb
129
136
  test/test_lorem_ar.rb
130
137
  test/test_lorem_cn.rb
@@ -132,6 +139,7 @@ Gem::Specification.new do |s|
132
139
  test/test_movie.rb
133
140
  test/test_phone_number.rb
134
141
  test/test_phone_number_au.rb
142
+ test/test_phone_number_de.rb
135
143
  test/test_phone_number_mx.rb
136
144
  test/test_phone_number_se.rb
137
145
  test/test_phone_number_sg.rb
data/lib/ffaker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Faker
2
- VERSION = "1.18.0"
2
+ VERSION = "1.19.0"
3
3
 
4
4
  require 'ffaker/utils/array_utils'
5
5
  require 'ffaker/utils/module_utils'
@@ -44,6 +44,8 @@ module Faker
44
44
  autoload :HealthcareIpsum, 'ffaker/healthcare_ipsum'
45
45
  autoload :HipsterIpsum, 'ffaker/hipster_ipsum'
46
46
  autoload :Identification, 'ffaker/identification'
47
+ autoload :IdentificationES, 'ffaker/identification_es'
48
+ autoload :IdentificationESCL, 'ffaker/identification_es_cl'
47
49
  autoload :Internet, 'ffaker/internet'
48
50
  autoload :InternetSE, 'ffaker/internet_se'
49
51
  autoload :Job, 'ffaker/job'
@@ -53,6 +55,7 @@ module Faker
53
55
  autoload :Movie, 'ffaker/movie'
54
56
  autoload :Name, 'ffaker/name'
55
57
  autoload :NameCN, 'ffaker/name_cn'
58
+ autoload :NameCS, 'ffaker/name_cs'
56
59
  autoload :NameDE, 'ffaker/name_de'
57
60
  autoload :NameGA, 'ffaker/name_ga'
58
61
  autoload :NameJA, 'ffaker/name_ja'
@@ -64,6 +67,7 @@ module Faker
64
67
  autoload :NameSN, 'ffaker/name_sn'
65
68
  autoload :PhoneNumber, 'ffaker/phone_number'
66
69
  autoload :PhoneNumberAU, 'ffaker/phone_number_au'
70
+ autoload :PhoneNumberDE, 'ffaker/phone_number_de'
67
71
  autoload :PhoneNumberMX, 'ffaker/phone_number_mx'
68
72
  autoload :PhoneNumberSE, 'ffaker/phone_number_se'
69
73
  autoload :PhoneNumberSG, 'ffaker/phone_number_sg'
@@ -18,65 +18,71 @@ module Faker
18
18
  def state_abbr
19
19
  STATE_ABBR.rand
20
20
  end
21
-
22
- def suburb(st_abbr = nil)
21
+
22
+ def suburb(st_abbr = nil, p_code = nil)
23
23
  st_abbr ||= state_abbr
24
- SUBURB[st_abbr][rand(SUBURB[st_abbr].size)]
24
+ p_code ||= postcode(st_abbr)
25
+ SUBURB[st_abbr][p_code]
25
26
  end
26
27
 
27
28
  def full_address(st_abbr = nil)
28
29
  st_abbr ||= state_abbr
29
30
  "#{Faker::Address.street_address}, #{suburb(st_abbr)} #{st_abbr} #{postcode}"
30
31
  end
31
-
32
+
32
33
  # based on areas labeled state (+act) here: http://en.wikipedia.org/wiki/States_and_territories_of_Australia
33
34
  STATE = k ['Australian Capital Territory', 'New South Wales', 'Queensland',
34
35
  'South Australia', 'Tasmania', 'Victoria', 'Western Australia']
35
36
 
36
37
  STATE_ABBR = k %w(ACT NSW NT QLD SA TAS VIC WA)
37
-
38
+
38
39
  # based on http://en.wikipedia.org/wiki/List_of_cities_in_Australia
39
40
  SUBURB = {
40
- "ACT" => ["Canberra", "Ainslie", "Braddon", "O'Connor"],
41
- "NSW" => ["Albury", "Armidale", "Bankstown", "Bathurst", "Blacktown",
42
- "Blue Mountains", "Botany Bay", "Broken Hill", "Campbelltown",
43
- "Canada Bay", "Canterbury", "Cessnock", "Coffs Harbour", "Dubbo",
44
- "Fairfield", "Gosford", "Goulburn", "Grafton", "Greater Taree", "Griffith",
45
- "Hawkesbury", "Holroyd", "Hurstville", "Lake Macquarie", "Lismore", "Lithgow",
46
- "Liverpool", "Maitland", "Newcastle", "Orange", "Parramatta", "Penrith",
47
- "Queanbeyan", "Randwick", "Rockdale", "Ryde", "Shellharbour", "Shoalhaven",
48
- "Sydney", "Tamworth", "Wagga Wagga", "Willoughby", "Wollongong"],
49
- "NT" => ["Darwin", "Palmerston"],
50
- "QLD" => ["Brisbane", "Bundaberg", "Cairns", "Caloundra", "Charters Towers",
51
- "Gladstone", "Gold Coast", "Gympie", "Hervey Bay", "Ipswich", "Logan City",
52
- "Mackay", "Maryborough", "Mount Isa", "Redcliffe City", "Redland City",
53
- "Rockhampton", "Sunshine Coast", "Surfers Paradise", "Thuringowa",
54
- "Toowoomba", "Townsville", "Warwick"],
55
- "SA" => ["Adelaide", "Mount Barker", "Mount Gambier", "Murray Bridge",
56
- "Port Adelaide", "Port Augusta", "Port Lincoln", "Port Pirie", "Victor Harbor",
57
- "Whyalla"],
58
- "TAS" => ["Burnie", "Clarence", "Devonport", "Glenorchy", "Hobart", "Launceston"],
59
- "VIC" => ["Ararat", "Bairnsdale", "Ballarat", "Benalla", "Bendigo", "Dandenong",
60
- "Frankston", "Geelong", "Hamilton", "Horsham", "Melbourne", "Melton", "Mildura",
61
- "Moe", "Morwell", "Sale", "Shepparton", "Swan Hill", "Traralgon", "Wangaratta",
62
- "Warrnambool", "Wodonga"],
63
- "WA" => ["Albany", "Armadale", "Bayswater", "Bunbury", "Canning", "Cockburn",
64
- "Fremantle", "Geraldton", "Gosnells", "Joondalup", "Kalgoorlie", "Mandurah",
65
- "Melville", "Nedlands", "Perth", "Rockingham", "South Perth", "Stirling",
66
- "Subiaco", "Swan", "Wanneroo"]
67
- }
68
-
69
- # based on http://en.wikipedia.org/wiki/Postcodes_in_Australia
70
- POSTCODE = {
71
- 'NSW' => [('1000'..'1999').to_a + ('2000'..'2599').to_a + ('2619'..'2898').to_a + ('2921'..'2999').to_a].flatten,
72
- 'ACT' => [('0200'..'0299').to_a + ('2600'..'2618').to_a + ('2900'..'2920').to_a].flatten,
73
- 'VIC' => [('3000'..'3999').to_a + ('8000'..'8999').to_a].flatten,
74
- 'QLD' => [('4000'..'4999').to_a + ('9000'..'9999').to_a].flatten,
75
- 'SA' => [('5000'..'5799').to_a + ('5800'..'5999').to_a].flatten,
76
- 'WA' => [('6000'..'6797').to_a + ('6800'..'6999').to_a].flatten,
77
- 'TAS' => [('7000'..'7799').to_a + ('7800'..'7999').to_a].flatten,
78
- 'NT' => [('0800'..'0899').to_a + ('0900'..'0999').to_a].flatten
41
+ "ACT"=>{"2600"=>"Canberra", "2601"=>"Canberra", "2602"=>"O'Connor",
42
+ "2612"=>"Braddon"},
43
+ "NT"=>{"0800"=>"Darwin", "0830"=>"Palmerston"},
44
+ "SA"=>{"5000"=>"Adelaide", "5015"=>"Port Adelaide", "5211"=>"Victor Harbor",
45
+ "5251"=>"Mount Barker", "5253"=>"Murray Bridge", "5254"=>"Murray Bridge",
46
+ "5290"=>"Mount Gambier", "5291"=>"Mount Gambier", "5540"=>"Port Pirie",
47
+ "5600"=>"Whyalla", "5606"=>"Port Lincoln", "5607"=>"Port Lincoln",
48
+ "5700"=>"Port Augusta", "5710"=>"Port Augusta"},
49
+ "WA"=>{"6000"=>"Perth", "6008"=>"Subiaco", "6009"=>"Nedlands",
50
+ "6021"=>"Stirling", "6027"=>"Joondalup", "6053"=>"Bayswater",
51
+ "6065"=>"Wanneroo", "6110"=>"Gosnells", "6112"=>"Armadale",
52
+ "6151"=>"South Perth", "6156"=>"Melville", "6160"=>"Fremantle",
53
+ "6168"=>"Rockingham", "6210"=>"Mandurah", "6230"=>"Bunbury",
54
+ "6330"=>"Albany", "6430"=>"Kalgoorlie", "6530"=>"Geraldton"},
55
+ "NSW"=>{"2000"=>"Sydney", "2031"=>"Randwick", "2046"=>"Canada Bay",
56
+ "2068"=>"Willoughby", "2112"=>"Ryde", "2142"=>"Holroyd",
57
+ "2148"=>"Blacktown", "2150"=>"Parramatta", "2165"=>"Fairfield",
58
+ "2170"=>"Liverpool", "2193"=>"Canterbury", "2200"=>"Bankstown",
59
+ "2216"=>"Rockdale", "2220"=>"Hurstville", "2250"=>"Gosford",
60
+ "2300"=>"Newcastle", "2320"=>"Maitland", "2325"=>"Cessnock",
61
+ "2340"=>"Tamworth", "2350"=>"Armidale", "2450"=>"Coffs Harbour",
62
+ "2460"=>"Grafton", "2480"=>"Lismore", "2500"=>"Wollongong",
63
+ "2529"=>"Shellharbour", "2560"=>"Campbelltown", "2580"=>"Goulburn",
64
+ "2620"=>"Queanbeyan", "2640"=>"Albury", "2650"=>"Wagga Wagga",
65
+ "2680"=>"Griffith", "2750"=>"Penrith", "2790"=>"Lithgow",
66
+ "2795"=>"Bathurst", "2800"=>"Orange", "2830"=>"Dubbo",
67
+ "2880"=>"Broken Hill"},
68
+ "QLD"=>{"4000"=>"Brisbane", "4217"=>"Surfers Paradise", "4305"=>"Ipswich",
69
+ "4350"=>"Toowoomba", "4370"=>"Warwick", "4551"=>"Caloundra",
70
+ "4570"=>"Gympie", "4650"=>"Maryborough", "4655"=>"Hervey Bay",
71
+ "4670"=>"Bundaberg", "4680"=>"Gladstone", "4700"=>"Rockhampton",
72
+ "4740"=>"Mackay", "4810"=>"Townsville", "4820"=>"Charters Towers",
73
+ "4825"=>"Mount Isa", "4870"=>"Cairns"},
74
+ "VIC"=>{"3000"=>"Melbourne", "3175"=>"Dandenong", "3199"=>"Frankston",
75
+ "3220"=>"Geelong", "3280"=>"Warrnambool", "3300"=>"Hamilton",
76
+ "3337"=>"Melton", "3350"=>"Ballarat", "3377"=>"Ararat",
77
+ "3400"=>"Horsham", "3500"=>"Mildura", "3550"=>"Bendigo",
78
+ "3585"=>"Swan Hill", "3630"=>"Shepparton", "3672"=>"Benalla",
79
+ "3677"=>"Wangaratta", "3690"=>"Wodonga", "3825"=>"Moe",
80
+ "3840"=>"Morwell", "3844"=>"Traralgon", "3850"=>"Sale",
81
+ "3875"=>"Bairnsdale"},
82
+ "TAS"=>{"7000"=>"Hobart", "7010"=>"Glenorchy", "7250"=>"Launceston",
83
+ "7310"=>"Devonport", "7320"=>"Burnie"}
79
84
  }
80
85
 
86
+ POSTCODE = SUBURB.inject({}) { |h, (s_abbr, postcode_suburb_map)| h.update(s_abbr => postcode_suburb_map.keys) }
81
87
  end
82
88
  end
@@ -0,0 +1,13 @@
1
+ module Faker
2
+ module IdentificationES
3
+ extend ModuleUtils
4
+ extend self
5
+
6
+ def gender
7
+ GENDERS.rand
8
+ end
9
+
10
+ GENDERS = k %w(Hombre Mujer)
11
+
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ module Faker
2
+ module IdentificationESCL
3
+ extend IdentificationES
4
+ extend self
5
+
6
+ # RUT is the Chilean ID, followed by format: XX.XXX.XXX - Y
7
+ # http://es.wikipedia.org/wiki/Rol_%C3%9Anico_Tributario
8
+ #
9
+ # The last Y is a modulo 11 validation code. In the case the result is 10, it will be replaced by a 'K' character
10
+ def rut
11
+ # Rut is gonna be between 1.000.000 and 24.999.999
12
+ n = Kernel.rand(24000000) + 1000000
13
+ "#{n}-#{dv(n)}"
14
+ end
15
+
16
+ private
17
+ def dv(rut)
18
+ total = rut.to_s.rjust(8,'0').split(//).zip(%w(3 2 7 6 5 4 3 2)).collect{|a,b| a.to_i*b.to_i}.inject(:+)
19
+ (11 - total % 11).to_s.gsub(/10/,'k').gsub(/11/,'0')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+
3
+ module Faker
4
+ module NameCS
5
+ include Faker::Name
6
+ extend ModuleUtils
7
+ extend self
8
+
9
+ # All names generated inside the block will have the same sex.
10
+ # Can be called with explicit sex which will affect
11
+ # all calls inside thee block:
12
+ #
13
+ # Faker::NameCS.with_same_sex(:female)
14
+ # person.last_name = Faker::NameCS.last_name
15
+ # person.first_name = Faker::NameCS.first_name
16
+ # end
17
+ #
18
+ # person.last_name # => "Nováková"
19
+ # person.first_name # => "Jana"
20
+ def with_same_sex(sex = :random)
21
+ @fixed_sex = sex == :random ? GENDERS[rand(2)] : sex
22
+ yield
23
+ ensure
24
+ @fixed_sex = nil
25
+ end
26
+
27
+ # Generates random full name which can contain prefix and suffix
28
+ # Can be called with explicit sex (:male, :female), like:
29
+ #
30
+ # Faker::NameCS.name(:male)
31
+ #
32
+ # for_sex defaults to :random.
33
+ def name(for_sex = :random)
34
+ with_same_sex(for_sex) do
35
+ case rand(10)
36
+ when 0 then "#{prefix} #{first_name} #{last_name} #{suffix}"
37
+ when 1..2 then "#{prefix} #{first_name} #{last_name}"
38
+ else "#{first_name} #{last_name}"
39
+ end
40
+ end
41
+ end
42
+
43
+ # Generates random last name
44
+ # for_sex can be :male, :female. Defaults to :random
45
+ def last_name(for_sex = :random)
46
+ LAST_NAMES[select_sex(for_sex)].rand
47
+ end
48
+
49
+ # Generates random first name
50
+ # for_sex can be :male, :female. Defaults to :random
51
+ def first_name(for_sex = :random)
52
+ FIRST_NAMES[select_sex(for_sex)].rand
53
+ end
54
+
55
+ # Generates random name prefix, an academic degree
56
+ def prefix
57
+ PREFIXES.rand
58
+ end
59
+
60
+ # Generates random name suffix, an academic degree
61
+ def suffix
62
+ SUFFIXES.rand
63
+ end
64
+
65
+ FIRST_NAMES = {
66
+ :female => k(%w(Alena Andrea Anna Barbora Božena Dagmar Dana Eliška Eva Hana Helena Irena Ivana Jana Jarmila Jaroslava Jiřina Jitka Kateřina Kristýna Lenka Libuše Lucie Ludmila Marcela Marie Markéta Marta Martina Michaela Miroslava Monika Pavla Petra Tereza Věra Veronika Vlasta Zdeňka Zuzana)),
67
+ :male => k(%w(Adam Aleš Alexandr Alois Antonín Bedřich Bohumil Bohuslav Břetislav Dalibor Daniel David Denis Dominik Dušan Eduard Emil Filip František Ivan Ivo Jakub Jan Jaromír Jaroslav Jindřich Jiří Josef Jozef Kamil Karel Kryštof Ladislav Leoš Libor Lubomír Luboš Luděk Ludvík Lukáš Marcel Marek Marian Martin Matěj Matyáš Michael Michal Milan Miloslav Miloš Miroslav Oldřich Ondřej Otakar Patrik Pavel Petr Přemysl Radek Radim Radomír Radovan René Richard Robert Roman Rostislav Rudolf Samuel Stanislav Šimon Štefan Štěpán Tadeáš Tomáš Václav Viktor Vilém Vít Vítězslav Vladimír Vladislav Vlastimil Vojtěch Vratislav Zbyněk Zdeněk))
68
+ }
69
+
70
+ LAST_NAMES= {
71
+ :female => k(%w(Dvořáková Černá Benešová Fialová Doležalová Čermáková Blažková Bartošová Čechová Dostálová Bláhová Burešová Dušková Beranová Bednářová Bártová Fišerová Bílková Beránková Brožová Čížková Adámková Daňková Filipová Červenková Čapková Bendová Adamcová Dvořáčková Brabcová Davidová Březinová Dlouhá Dohnalová Burianová Dufková Fojtíková Burdová Červená Boháčová Bartoňová Doleželová Dudová Adamová Bauerová Divišová Coufalová Čejková Berková Balážová)),
72
+ :male => k(%w(Dvořák Černý Beneš Fiala Doležal Čermák Blažek Bartoš Čech Dostál Bláha Bureš Dušek Beran Bednář Bárta Bílek Beránek Fišer Brož Čížek Filip Červenka Adámek Daněk Dvořáček Benda Adamec Brabec Březina David Burian Čapek Dohnal Dlouhý Fojtík Bartoň Červený Dufek Burda Duda Adam Boháč Doležel Baláž Diviš Coufal Bauer Dolejší))
73
+ }
74
+
75
+ PREFIXES = k %w(Bc. BcA. Mgr. MgA. Ing. Ing. arch. JUDr. MDDr. MUDr. MVDr. PharmDr. PhDr. RNDr. ThDr. ThLic.)
76
+
77
+ SUFFIXES = k %w(Ph.D. Th.D. DSc.)
78
+
79
+ private
80
+ GENDERS = [:male, :female, :random] # :nodoc:
81
+
82
+ def select_sex(sex) # :nodoc:
83
+ given_sex = @fixed_sex ? @fixed_sex : sex
84
+ raise ArgumentError, "Unknown sex #{given_sex}" unless GENDERS.include?(given_sex)
85
+ given_sex == :random ? GENDERS[rand(2)] : given_sex
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ # => author: lawitschka
4
+ # => email: moritz.lawitschka@urbanvention.com
5
+ module Faker
6
+ module PhoneNumberDE
7
+ extend ModuleUtils
8
+ extend self
9
+
10
+ # Mobile prefixes are in the 015x, 016x, 017x ranges
11
+ def mobile_prefix(leading_zero = true)
12
+ mobile_prefix = '1' + (rand(3) + 5).to_s + rand(10).to_s
13
+ mobile_prefix = '0' + mobile_prefix if leading_zero
14
+ mobile_prefix
15
+ end
16
+
17
+ # Region prefixes are in range 02..09 with length of 3 to 5 digits
18
+ def region_prefix(leading_zero = true)
19
+ region_prefix = (rand(8) + 2).to_s + Faker.numerify( '#' * (rand(3) + 1) ).to_s
20
+ region_prefix = '0' + region_prefix if leading_zero
21
+ region_prefix
22
+ end
23
+
24
+ def phone_number
25
+ home_work_phone_number
26
+ end
27
+
28
+ def mobile_phone_number(leading_zero = true)
29
+ [mobile_prefix(leading_zero), Faker.numerify('#######')].join(' ')
30
+ end
31
+
32
+ def home_work_phone_number(leading_zero = true)
33
+ [region_prefix(leading_zero), Faker.numerify('#######')].join(' ')
34
+ end
35
+
36
+ def country_code
37
+ '+49'
38
+ end
39
+
40
+ def international_mobile_phone_number
41
+ [country_code, mobile_phone_number(false)].join(' ')
42
+ end
43
+
44
+ def international_home_work_phone_number
45
+ [country_code, home_work_phone_number(false)].join(' ')
46
+ end
47
+
48
+ def international_phone_number
49
+ international_home_work_phone_number
50
+ end
51
+ end
52
+ end
@@ -3,13 +3,13 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestAddressAU < Test::Unit::TestCase
6
-
6
+
7
7
  def test_au_state_abbr
8
8
  arr = Faker::AddressAU::STATE_ABBR.sort
9
9
  assert arr = Faker::AddressAU::SUBURB.keys.sort
10
10
  assert arr = Faker::AddressAU::POSTCODE.keys.sort
11
11
  end
12
-
12
+
13
13
  def test_au_state
14
14
  assert_match /[ a-z]/, Faker::AddressAU.state
15
15
  end
@@ -21,7 +21,7 @@ class TestAddressAU < Test::Unit::TestCase
21
21
  def test_au_suburb
22
22
  assert_match /[a-zA-Z]/, Faker::AddressAU.suburb
23
23
  end
24
-
24
+
25
25
  def test_postcode
26
26
  assert_match /\d{4}/, Faker::AddressAU.postcode
27
27
  end
@@ -29,10 +29,6 @@ class TestAddressAU < Test::Unit::TestCase
29
29
  def test_full_address
30
30
  assert_match /[\, a-z]/, Faker::AddressAU.full_address
31
31
  end
32
-
33
- def test_postcode_frozen
34
- assert Faker::AddressAU.postcode.frozen? == false
35
- end
36
32
 
37
33
  def test_au_suburb_with_states
38
34
  Faker::AddressAU::STATE_ABBR.each do |st_abbr|
@@ -40,6 +36,13 @@ class TestAddressAU < Test::Unit::TestCase
40
36
  end
41
37
  end
42
38
 
39
+ def test_au_suburb_with_state_and_postcodes
40
+ Faker::AddressAU::STATE_ABBR.each do |st_abbr|
41
+ p_code = Faker::AddressAU.postcode(st_abbr)
42
+ assert_match /[a-zA-Z]/, Faker::AddressAU.suburb(st_abbr, p_code)
43
+ end
44
+ end
45
+
43
46
  def test_postcode_with_states
44
47
  Faker::AddressAU::STATE_ABBR.each do |st_abbr|
45
48
  assert_match /\d{4}/, Faker::AddressAU.postcode(st_abbr)
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+ require 'helper'
3
+
4
+ class TestFakerNameCS < Test::Unit::TestCase
5
+ def setup
6
+ @tester = Faker::NameCS
7
+ end
8
+
9
+ def test_name
10
+ @words = @tester.name.split
11
+ assert [2,3,4].include?(@words.size) # just name, or prefix, or prefix+suffix
12
+ end
13
+
14
+ def test_name_sex
15
+ @words = @tester.name.split
16
+ @words = @words[1..2] if @words.size > 2
17
+ assert same_sex?(@words)
18
+ end
19
+
20
+ def test_male_last_name
21
+ assert Faker::NameCS::LAST_NAMES[:male].include?(@tester.last_name(:male))
22
+ end
23
+
24
+ def test_male_first_name
25
+ assert Faker::NameCS::FIRST_NAMES[:male].include?(@tester.first_name(:male))
26
+ end
27
+
28
+ def test_prefix
29
+ assert Faker::NameCS::PREFIXES.include?(@tester.prefix)
30
+ end
31
+
32
+ def test_suffix
33
+ assert Faker::NameCS::SUFFIXES.include?(@tester.suffix)
34
+ end
35
+
36
+ def test_with_same_sex
37
+ names = []
38
+ @tester.with_same_sex do
39
+ names << @tester.last_name
40
+ names << @tester.first_name
41
+ end
42
+ assert same_sex?(names)
43
+ end
44
+
45
+ def test_with_same_sex_for_male
46
+ names = []
47
+ @tester.with_same_sex(:male) do
48
+ names << @tester.last_name
49
+ names << @tester.first_name
50
+ end
51
+ assert same_sex?(names, :male)
52
+ end
53
+
54
+ # checks if every name is of the same sex
55
+ def same_sex?(words, sex = :any)
56
+ (sex == :any ? [:male, :female] : [sex]).any? do |sex|
57
+ words.all? do |word|
58
+ [Faker::NameCS::LAST_NAMES, Faker::NameCS::FIRST_NAMES].any? do |names|
59
+ names[sex].include?(word)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -26,13 +26,17 @@ class TestHTMLIpsum < Test::Unit::TestCase
26
26
  # because the Faker::Lorem methods that we are using adds a random
27
27
  # number on top of what we specify for the count argument. We also have to
28
28
  # account for the other HTML that is being returned.
29
- assert_match /^<p>[[:alnum:][:punct:] <>\/]+<\/p>$/i, Faker::HTMLIpsum.p(5, {:fancy => true})
29
+ str = Faker::HTMLIpsum.p(5, {:fancy => true})
30
+ assert_match /^<p>/, str
31
+ assert_match /<\/p>$/, str
32
+ assert str.length > 6, "string contains more than <p></p>"
30
33
  end
31
34
 
32
35
  def test_p_fancy_breaks
33
36
  # Here we can at least test how many <br> tags there are. We also have to
34
37
  # account for the other HTML that is being returned.
35
- assert_match /^<p>(?:[[:alnum:][:punct:] <>\/]+?<br>){9}[[:alnum:][:punct:] <>\/]+?<\/p>/i, Faker::HTMLIpsum.p(10, {:fancy => true, :include_breaks => true})
38
+ str = Faker::HTMLIpsum.p(10, {:fancy => true, :include_breaks => true})
39
+ assert_equal 10, str.split("<br>").length
36
40
  end
37
41
 
38
42
  def test_dl
@@ -72,12 +76,14 @@ class TestHTMLIpsum < Test::Unit::TestCase
72
76
  def test_fancy_string
73
77
  # We can't reliably predict what's going to end up inside, so just ensure
74
78
  # that we have a complete string.
75
- assert_match /^[[:alnum:][:punct:] <>\/]+$/im, Faker::HTMLIpsum.fancy_string
79
+ assert Faker::HTMLIpsum.fancy_string.is_a?(String), "returns a string"
80
+ assert Faker::HTMLIpsum.fancy_string.length > 1, "the string is longer than one char"
76
81
  end
77
82
 
78
83
  def test_fancy_string_breaks
79
84
  # We can't reliably predict what's going to end up inside, so just ensure
80
85
  # that we have a complete string.
81
- assert_match /^(?:[[:alnum:][:punct:] <>\/]+?<br>){2}[[:alnum:][:punct:] <>\/]+?$/im, Faker::HTMLIpsum.fancy_string(3, true)
86
+ str = Faker::HTMLIpsum.fancy_string(3, true)
87
+ assert_equal 3, str.split("<br>").length
82
88
  end
83
89
  end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ class TestFakerIdentificationES < Test::Unit::TestCase
4
+ def setup
5
+ @tester = Faker::IdentificationES
6
+ end
7
+
8
+ def test_gender
9
+ assert_match /(Hombre|Mujer)/, @tester.gender
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ class TestFakerIdentificationESCL < Test::Unit::TestCase
4
+ def setup
5
+ @tester = Faker::IdentificationESCL
6
+ end
7
+
8
+ def test_rut
9
+ assert_match /\b\d{7,8}\-[k|0-9]/i, @tester.rut
10
+ end
11
+
12
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ # => author: lawitschka
4
+ # => email: moritz.lawitschka@urbanvention.com
5
+ require 'helper'
6
+
7
+ class TestPhoneNumberDE < Test::Unit::TestCase
8
+ def setup
9
+ @tester = Faker::PhoneNumberDE
10
+ end
11
+
12
+ def test_mobile_prefix
13
+ assert_match /^01[567]{1}[0-9]{1}$/, Faker::PhoneNumberDE.mobile_prefix
14
+ end
15
+
16
+ def test_mobile_prefix_without_leading_zero
17
+ assert_match /^1[567]{1}[0-9]{1}$/, Faker::PhoneNumberDE.mobile_prefix(false)
18
+ end
19
+
20
+ def test_region_prefix
21
+ assert_match /^0[2-9]{1}[0-9]{1,3}$/, Faker::PhoneNumberDE.region_prefix
22
+ end
23
+
24
+ def test_region_prefix_without_leading_zero
25
+ assert_match /^[2-9]{1}[0-9]{1,3}$/, Faker::PhoneNumberDE.region_prefix(false)
26
+ end
27
+
28
+ def test_mobile_phone_number
29
+ assert_match /^01[567]{1}[0-9]{1} [0-9]{7}$/, Faker::PhoneNumberDE.mobile_phone_number
30
+ end
31
+
32
+ def test_home_work_phone_number
33
+ assert_match /^0[2-9]{1}[0-9]{1,3} [0-9]{7}$/, Faker::PhoneNumberDE.home_work_phone_number
34
+ end
35
+
36
+ def test_country_code
37
+ assert_match '+49', Faker::PhoneNumberDE.country_code
38
+ end
39
+
40
+ def test_international_mobile_phone_number
41
+ assert_match /^\+49 1[567]{1}[0-9]{1} [0-9]{7}$/, Faker::PhoneNumberDE.international_mobile_phone_number
42
+ end
43
+
44
+ def test_international_home_work_phone_number
45
+ assert_match /^\+49 [2-9]{1}[0-9]{1,3} [0-9]{7}$/, Faker::PhoneNumberDE.international_home_work_phone_number
46
+ end
47
+
48
+ end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
5
- prerelease:
4
+ version: 1.19.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Emmanuel Oga
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-06 00:00:00.000000000 Z
11
+ date: 2013-09-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: test-unit
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Faster Faker, generates dummy data.
@@ -80,6 +75,8 @@ files:
80
75
  - lib/ffaker/hipster_ipsum.rb
81
76
  - lib/ffaker/html_ipsum.rb
82
77
  - lib/ffaker/identification.rb
78
+ - lib/ffaker/identification_es.rb
79
+ - lib/ffaker/identification_es_cl.rb
83
80
  - lib/ffaker/internet.rb
84
81
  - lib/ffaker/internet_se.rb
85
82
  - lib/ffaker/job.rb
@@ -89,6 +86,7 @@ files:
89
86
  - lib/ffaker/movie.rb
90
87
  - lib/ffaker/name.rb
91
88
  - lib/ffaker/name_cn.rb
89
+ - lib/ffaker/name_cs.rb
92
90
  - lib/ffaker/name_da.rb
93
91
  - lib/ffaker/name_de.rb
94
92
  - lib/ffaker/name_ga.rb
@@ -103,6 +101,7 @@ files:
103
101
  - lib/ffaker/phone_number.rb
104
102
  - lib/ffaker/phone_number_au.rb
105
103
  - lib/ffaker/phone_number_da.rb
104
+ - lib/ffaker/phone_number_de.rb
106
105
  - lib/ffaker/phone_number_mx.rb
107
106
  - lib/ffaker/phone_number_se.rb
108
107
  - lib/ffaker/phone_number_sg.rb
@@ -141,6 +140,7 @@ files:
141
140
  - test/test_faker_job.rb
142
141
  - test/test_faker_name.rb
143
142
  - test/test_faker_name_cn.rb
143
+ - test/test_faker_name_cs.rb
144
144
  - test/test_faker_name_de.rb
145
145
  - test/test_faker_name_ga.rb
146
146
  - test/test_faker_name_ja.rb
@@ -155,6 +155,8 @@ files:
155
155
  - test/test_hipster_ipsum.rb
156
156
  - test/test_html_ipsum.rb
157
157
  - test/test_identification.rb
158
+ - test/test_identification_es.rb
159
+ - test/test_identification_es_cl.rb
158
160
  - test/test_lorem.rb
159
161
  - test/test_lorem_ar.rb
160
162
  - test/test_lorem_cn.rb
@@ -162,6 +164,7 @@ files:
162
164
  - test/test_movie.rb
163
165
  - test/test_phone_number.rb
164
166
  - test/test_phone_number_au.rb
167
+ - test/test_phone_number_de.rb
165
168
  - test/test_phone_number_mx.rb
166
169
  - test/test_phone_number_se.rb
167
170
  - test/test_phone_number_sg.rb
@@ -173,26 +176,25 @@ files:
173
176
  - test/test_venue.rb
174
177
  homepage: http://github.com/emmanueloga/ffaker
175
178
  licenses: []
179
+ metadata: {}
176
180
  post_install_message:
177
181
  rdoc_options:
178
182
  - --charset=UTF-8
179
183
  require_paths:
180
184
  - lib
181
185
  required_ruby_version: !ruby/object:Gem::Requirement
182
- none: false
183
186
  requirements:
184
- - - ! '>='
187
+ - - '>='
185
188
  - !ruby/object:Gem::Version
186
189
  version: '0'
187
190
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
191
  requirements:
190
- - - ! '>='
192
+ - - '>='
191
193
  - !ruby/object:Gem::Version
192
194
  version: '0'
193
195
  requirements: []
194
196
  rubyforge_project: ffaker
195
- rubygems_version: 1.8.25
197
+ rubygems_version: 2.0.3
196
198
  signing_key:
197
199
  specification_version: 2
198
200
  summary: Faster Faker, generates dummy data.
@@ -219,6 +221,7 @@ test_files:
219
221
  - test/test_faker_job.rb
220
222
  - test/test_faker_name.rb
221
223
  - test/test_faker_name_cn.rb
224
+ - test/test_faker_name_cs.rb
222
225
  - test/test_faker_name_de.rb
223
226
  - test/test_faker_name_ga.rb
224
227
  - test/test_faker_name_ja.rb
@@ -233,6 +236,8 @@ test_files:
233
236
  - test/test_hipster_ipsum.rb
234
237
  - test/test_html_ipsum.rb
235
238
  - test/test_identification.rb
239
+ - test/test_identification_es.rb
240
+ - test/test_identification_es_cl.rb
236
241
  - test/test_lorem.rb
237
242
  - test/test_lorem_ar.rb
238
243
  - test/test_lorem_cn.rb
@@ -240,6 +245,7 @@ test_files:
240
245
  - test/test_movie.rb
241
246
  - test/test_phone_number.rb
242
247
  - test/test_phone_number_au.rb
248
+ - test/test_phone_number_de.rb
243
249
  - test/test_phone_number_mx.rb
244
250
  - test/test_phone_number_se.rb
245
251
  - test/test_phone_number_sg.rb