dutchfaker 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/License.txt +20 -0
- data/Manifest.txt +26 -0
- data/PostInstall.txt +7 -0
- data/README.txt +56 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/dutchfaker/address.rb +43 -0
- data/lib/dutchfaker/company.rb +24 -0
- data/lib/dutchfaker/internet.rb +48 -0
- data/lib/dutchfaker/name.rb +49 -0
- data/lib/dutchfaker/randomify.rb +11 -0
- data/lib/dutchfaker/version.rb +9 -0
- data/lib/dutchfaker.rb +10 -0
- data/lib/ext/array.rb +5 -0
- data/setup.rb +1585 -0
- data/spec/address_spec.rb +118 -0
- data/spec/company_spec.rb +24 -0
- data/spec/internet_spec.rb +116 -0
- data/spec/name_spec.rb +52 -0
- data/spec/shared_fake_examples.rb +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +91 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/shared_fake_examples'
|
3
|
+
|
4
|
+
describe DutchFaker::Address do
|
5
|
+
describe ".address" do
|
6
|
+
before(:each) do
|
7
|
+
@fake = DutchFaker::Address.address
|
8
|
+
end
|
9
|
+
|
10
|
+
def city
|
11
|
+
DutchFaker::Address::CITIES.find { |city| city[0] == @fake[:city] }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should not be nil" do
|
15
|
+
@fake.should_not be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a street address" do
|
19
|
+
@fake[:street_address].should match(/\w+\s\d{1,3}/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a postal code" do
|
23
|
+
@fake[:postal_code].should match(/\d{4}[A-Z]{2}/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a postal code that is valid for the city" do
|
27
|
+
postal_digits = city[2]
|
28
|
+
@fake[:postal_code].should match(/^#{postal_digits}/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should should have a city" do
|
32
|
+
@fake[:city].should_not be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a phone number" do
|
36
|
+
@fake[:phone_number].should match(/\d{3,5}\s\d{5,7}/)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have an area code that is valid for the city" do
|
40
|
+
area_code = city[1]
|
41
|
+
@fake[:phone_number].should match(/^#{area_code}\s/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".city" do
|
46
|
+
it_should_behave_like "a fake"
|
47
|
+
|
48
|
+
before(:each) do
|
49
|
+
@fake = DutchFaker::Address.city
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be a valid city" do
|
53
|
+
cities = DutchFaker::Address::CITIES.map { |city| city[0] }
|
54
|
+
cities.should include(@fake)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".phone_number" do
|
59
|
+
it_should_behave_like "a fake"
|
60
|
+
|
61
|
+
before(:each) do
|
62
|
+
@fake = DutchFaker::Address.phone_number
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be 11 characters long" do
|
66
|
+
@fake.length.should == 11
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should only contain digits" do
|
70
|
+
@fake.should match(/[\d\s]+/)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be a valid Dutch phone number" do
|
74
|
+
@fake.should match(/\d{3,5}\s\d{5,7}/)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".street_address" do
|
79
|
+
it_should_behave_like "a fake"
|
80
|
+
|
81
|
+
before(:each) do
|
82
|
+
@fake = DutchFaker::Address.street_address
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be a street name followed by a number" do
|
86
|
+
@fake.should match(/\w+\s\d{1,3}/)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe ".street_name" do
|
91
|
+
it_should_behave_like "a fake"
|
92
|
+
|
93
|
+
before(:each) do
|
94
|
+
@fake = DutchFaker::Address.street_name
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should end in a valid suffix" do
|
98
|
+
suffixes = DutchFaker::Address::STREET_SUFFIX.uniq.join("|")
|
99
|
+
@fake.should match(/[#{suffixes}]$/)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe ".postal_code" do
|
104
|
+
it_should_behave_like "a fake"
|
105
|
+
|
106
|
+
before(:each) do
|
107
|
+
@fake = DutchFaker::Address.postal_code
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should be 6 characters long" do
|
111
|
+
@fake.length.should == 6
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be 4 digits followed by 2 letters" do
|
115
|
+
@fake.should match(/\d{4}[A-Z]{2}/)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/shared_fake_examples'
|
3
|
+
|
4
|
+
describe DutchFaker::Company do
|
5
|
+
describe ".name" do
|
6
|
+
it_should_behave_like "a fake"
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@fake = DutchFaker::Company.name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".suffix" do
|
14
|
+
it_should_behave_like "a fake"
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
@fake = DutchFaker::Company.suffix
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be a valid suffix" do
|
21
|
+
DutchFaker::Company::SUFFIXES.should include(@fake)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/shared_fake_examples'
|
3
|
+
|
4
|
+
describe DutchFaker::Internet do
|
5
|
+
describe ".email" do
|
6
|
+
it_should_behave_like "a fake"
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@fake = DutchFaker::Internet.email
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should contain exactly one @ character" do
|
13
|
+
@fake.scan(/@/).should have(1).thing
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should end in a valid suffix" do
|
17
|
+
suffix = @fake.split('.').last
|
18
|
+
DutchFaker::Internet::DOMAIN_SUFFIXES.should include(suffix)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".free_mail" do
|
23
|
+
it_should_behave_like "a fake"
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
@fake = DutchFaker::Internet.free_email
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should contain exactly one @ character" do
|
30
|
+
@fake.scan(/@/).should have(1).thing
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a valid free email domain" do
|
34
|
+
domain = @fake.split("@").last
|
35
|
+
DutchFaker::Internet::FREE_EMAIL_SUFFIXES.should include(domain)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".user_name" do
|
40
|
+
it_should_behave_like "a fake"
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@fake = DutchFaker::Internet.user_name
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should replace space with a '.' or a'-'" do
|
47
|
+
@fake = DutchFaker::Internet.user_name('Piet Janssen')
|
48
|
+
@fake.should match(/piet[\._]janssen/)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not contain any spaces" do
|
52
|
+
@fake.should_not include(' ')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".domain_name" do
|
57
|
+
it_should_behave_like "a fake"
|
58
|
+
|
59
|
+
before(:each) do
|
60
|
+
@fake = DutchFaker::Internet.domain_name
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should consist of two parts" do
|
64
|
+
@fake.split('.').should have_at_least(2).things
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should end in a valid suffix" do
|
68
|
+
suffix = @fake.split('.').last
|
69
|
+
DutchFaker::Internet::DOMAIN_SUFFIXES.should include(suffix)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".domain_word" do
|
74
|
+
it_should_behave_like "a fake"
|
75
|
+
|
76
|
+
before(:each) do
|
77
|
+
@fake = DutchFaker::Internet.domain_word
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not contain any spaces" do
|
81
|
+
@fake.should_not include(' ')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should contain only letters or digits" do
|
85
|
+
@fake.should_not match(/[\sW+]/)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe ".domain_suffix" do
|
90
|
+
it_should_behave_like "a fake"
|
91
|
+
|
92
|
+
before(:each) do
|
93
|
+
@fake = DutchFaker::Internet.domain_suffix
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be a valid suffix" do
|
97
|
+
DutchFaker::Internet::DOMAIN_SUFFIXES.should include(@fake)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".web_site" do
|
102
|
+
it_should_behave_like "a fake"
|
103
|
+
|
104
|
+
before(:each) do
|
105
|
+
@fake = DutchFaker::Internet.web_site
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should consist of at least 3 parts" do
|
109
|
+
@fake.split('.').should have_at_least(3).things
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should start with www." do
|
113
|
+
@fake.should match(/^www./)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/spec/name_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/shared_fake_examples'
|
3
|
+
|
4
|
+
describe DutchFaker::Name do
|
5
|
+
describe ".name" do
|
6
|
+
it_should_behave_like "a fake"
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@fake = DutchFaker::Name.name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should contain at least two words" do
|
13
|
+
@fake.should match(/[\w\.]+\s\w+/)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".first_name" do
|
18
|
+
it_should_behave_like "a fake"
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
@fake = DutchFaker::Name.first_name
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be an entry in Faker::Name::FIRST_NAMES" do
|
25
|
+
DutchFaker::Name::FIRST_NAMES.should include(@fake)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".last_name" do
|
30
|
+
it_should_behave_like "a fake"
|
31
|
+
|
32
|
+
before(:each) do
|
33
|
+
@fake = DutchFaker::Name.last_name
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be an entry in Faker::Name::LAST_NAMES" do
|
37
|
+
DutchFaker::Name::LAST_NAMES.should include(@fake)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".prefix" do
|
42
|
+
it_should_behave_like "a fake"
|
43
|
+
|
44
|
+
before(:each) do
|
45
|
+
@fake = DutchFaker::Name.prefix
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be a valid prefix" do
|
49
|
+
DutchFaker::Name::PREFIXES.should include(@fake)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dutchfaker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Onno van Zinderen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-21 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Creates fake Dutch names and addresses
|
17
|
+
email:
|
18
|
+
- onno01@chello.nl
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- History.txt
|
25
|
+
- License.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- PostInstall.txt
|
28
|
+
- README.txt
|
29
|
+
files:
|
30
|
+
- History.txt
|
31
|
+
- License.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- PostInstall.txt
|
34
|
+
- README.txt
|
35
|
+
- Rakefile
|
36
|
+
- config/hoe.rb
|
37
|
+
- config/requirements.rb
|
38
|
+
- lib/dutchfaker.rb
|
39
|
+
- lib/dutchfaker/address.rb
|
40
|
+
- lib/dutchfaker/company.rb
|
41
|
+
- lib/dutchfaker/internet.rb
|
42
|
+
- lib/dutchfaker/name.rb
|
43
|
+
- lib/dutchfaker/randomify.rb
|
44
|
+
- lib/dutchfaker/version.rb
|
45
|
+
- lib/ext/array.rb
|
46
|
+
- setup.rb
|
47
|
+
- spec/address_spec.rb
|
48
|
+
- spec/company_spec.rb
|
49
|
+
- spec/internet_spec.rb
|
50
|
+
- spec/name_spec.rb
|
51
|
+
- spec/shared_fake_examples.rb
|
52
|
+
- spec/spec.opts
|
53
|
+
- spec/spec_helper.rb
|
54
|
+
- tasks/environment.rake
|
55
|
+
- tasks/rspec.rake
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://dutchfaker.rubyforge.org
|
58
|
+
post_install_message: |+
|
59
|
+
|
60
|
+
For more information on dutchfaker, see http://dutchfaker.rubyforge.org
|
61
|
+
|
62
|
+
NOTE: Change this information in PostInstall.txt
|
63
|
+
You can also delete it if you don't want it.
|
64
|
+
|
65
|
+
|
66
|
+
rdoc_options:
|
67
|
+
- --main
|
68
|
+
- README.txt
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: dutchfaker
|
86
|
+
rubygems_version: 1.1.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 2
|
89
|
+
summary: Creates fake Dutch names and addresses
|
90
|
+
test_files: []
|
91
|
+
|