forgery 0.6.0 → 0.7.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.
@@ -1 +1 @@
1
- #-(###)###-####
1
+ #-###-###-####
@@ -1,3 +1,3 @@
1
1
  class Forgery
2
- VERSION = "0.6.0"
2
+ VERSION = '0.7.0'.freeze
3
3
  end
@@ -6,7 +6,7 @@ describe Forgery::Dictionaries do
6
6
 
7
7
  dictionaries[:colors]
8
8
 
9
- dictionaries.should be_loaded(:colors)
9
+ expect(dictionaries).to be_loaded(:colors)
10
10
  end
11
11
 
12
12
  it "should load a dictionary when called by the key" do
@@ -14,11 +14,11 @@ describe Forgery::Dictionaries do
14
14
 
15
15
  dictionaries.reset!
16
16
 
17
- dictionaries.should_not be_loaded(:colors)
17
+ expect(dictionaries).not_to be_loaded(:colors)
18
18
 
19
19
  dictionaries[:colors]
20
20
 
21
- dictionaries.should be_loaded(:colors)
21
+ expect(dictionaries).to be_loaded(:colors)
22
22
  end
23
23
 
24
24
  it "should clear the loaded dictionaries when calling reset!" do
@@ -26,10 +26,10 @@ describe Forgery::Dictionaries do
26
26
 
27
27
  dictionaries[:colors]
28
28
 
29
- dictionaries.should be_loaded(:colors)
29
+ expect(dictionaries).to be_loaded(:colors)
30
30
 
31
31
  dictionaries.reset!
32
32
 
33
- dictionaries.should_not be_loaded(:colors)
33
+ expect(dictionaries).not_to be_loaded(:colors)
34
34
  end
35
35
  end
@@ -6,20 +6,20 @@ describe Array do
6
6
  end
7
7
 
8
8
  it "should get a random item out of the array" do
9
- 10.times { @array.should include(@array.random) }
9
+ 10.times { expect(@array).to include(@array.random) }
10
10
  end
11
11
 
12
12
  it "should return nil if the array is empty" do
13
- Forgery::Extend([]).random.should be_nil
13
+ expect(Forgery::Extend([]).random).to be_nil
14
14
  end
15
15
 
16
16
  it "should return a random subset of the array" do
17
17
  @array.random_subset(5).each do |i|
18
- @array.should include(i)
18
+ expect(@array).to include(i)
19
19
  end
20
20
  end
21
21
 
22
22
  it "should return a random subset of the array that is 3 long" do
23
- @array.random_subset(3).size.should == 3
23
+ expect(@array.random_subset(3).size).to eq(3)
24
24
  end
25
25
  end
@@ -2,30 +2,32 @@ require 'spec_helper'
2
2
  require 'timeout'
3
3
 
4
4
  describe Range do
5
- it "should get a random number out of the range" do
5
+ it 'should get a random number out of the range' do
6
6
  range = Forgery::Extend(0..9)
7
- 10.times { range.should include(range.random) }
7
+ 10.times { expect(range).to include(range.random) }
8
8
  end
9
9
 
10
- it "should not take a long time when the range is huge" do
11
- Timeout.timeout(1){Forgery::Extend(1234567890..12345678901234567890).random}.should_not raise_error(Timeout::Error)
10
+ it 'should not take a long time when the range is huge' do
11
+ expect do
12
+ Timeout.timeout(1) { Forgery::Extend(1_234_567_890..12_345_678_901_234_567_890).random }
13
+ end.not_to raise_error
12
14
  end
13
15
 
14
- it "should return nil for a random number from a reverse range" do
15
- 10.times { Forgery::Extend(9..0).random.should be_nil }
16
+ it 'should return nil for a random number from a reverse range' do
17
+ 10.times { expect(Forgery::Extend(9..0).random).to be_nil }
16
18
  end
17
19
 
18
- it "should get a random string our of the range" do
19
- range = Forgery::Extend("a".."z")
20
- 10.times { range.should include(range.random) }
20
+ it 'should get a random string our of the range' do
21
+ range = Forgery::Extend('a'..'z')
22
+ 10.times { expect(range).to include(range.random) }
21
23
  end
22
24
 
23
- it "should return nil if the maximum is less than the minimum" do
24
- Forgery::Extend("z".."a").random.should be_nil
25
+ it 'should return nil if the maximum is less than the minimum' do
26
+ expect(Forgery::Extend('z'..'a').random).to be_nil
25
27
  end
26
28
 
27
- it "should not return the maximum at excluded range" do
28
- Kernel.should_receive(:rand).with(9).and_return(8)
29
- Forgery::Extend(0...9).random.should_not be_equal 9
29
+ it 'should not return the maximum at excluded range' do
30
+ expect(Random).to receive(:rand).with(0...9).and_return(8)
31
+ expect(Forgery::Extend(0...9).random).to_not eq(9)
30
32
  end
31
33
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe String do
4
4
  it "should change a single # to a number 0-9" do
5
- (0..9).should include(Integer(Forgery::Extend("#").to_numbers))
5
+ expect(0..9).to include(Integer(Forgery::Extend("#").to_numbers))
6
6
  end
7
7
 
8
8
  it "should change two #'s to two numbers 0-9" do
9
9
  Forgery::Extend("##").to_numbers.split("").each do |s|
10
- (0..9).should include(Integer(s))
10
+ expect(0..9).to include(Integer(s))
11
11
  end
12
12
  end
13
13
 
@@ -16,14 +16,14 @@ describe String do
16
16
  n = s.to_numbers
17
17
  0.upto(s.size - 1) do |i|
18
18
  if s[i, 1] == "#"
19
- ('0'..'9').should include(n[i, 1])
19
+ expect('0'..'9').to include(n[i, 1])
20
20
  else
21
- ('0'..'9').should_not include(n[i, 1])
21
+ expect('0'..'9').not_to include(n[i, 1])
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  it "should allow the replacing of a different character" do
27
- (0..9).should include(Integer(Forgery::Extend("-").to_numbers("-")))
27
+ expect(0..9).to include(Integer(Forgery::Extend("-").to_numbers("-")))
28
28
  end
29
29
  end
@@ -2,27 +2,27 @@ require 'spec_helper'
2
2
 
3
3
  describe Forgery::FileReader do
4
4
  it "should return an array when calling read_dictionary" do
5
- Forgery::FileReader.read_dictionary(:colors).should be_is_a(Array)
5
+ expect(Forgery::FileReader.read_dictionary(:colors)).to be_is_a(Array)
6
6
  end
7
7
 
8
8
  it "should return an array when calling read_format" do
9
- Forgery::FileReader.read_format(:phone).should be_is_a(Array)
9
+ expect(Forgery::FileReader.read_format(:phone)).to be_is_a(Array)
10
10
  end
11
11
 
12
12
  it "should override default dictionaries if Forgery#load_from! was called" do
13
13
  Forgery.load_from! "spec/data"
14
- Forgery::FileReader.read_dictionary(:female_first_names).should == %w(Amber)
14
+ expect(Forgery::FileReader.read_dictionary(:female_first_names)).to eq(%w(Amber))
15
15
  end
16
16
 
17
17
  it "should read dictionaries from custom places if Forgery#load_from! was called" do
18
18
  Forgery.load_from! "spec/data"
19
- Forgery::FileReader.read_dictionary(:code_names).should include('Shiretoko')
19
+ expect(Forgery::FileReader.read_dictionary(:code_names)).to include('Shiretoko')
20
20
  end
21
21
 
22
22
  it "should raise an exception if file wasn't found in load paths" do
23
- lambda {
23
+ expect {
24
24
  Forgery::FileReader.read_dictionary(:non_existing_dictionary)
25
- }.should raise_error(ArgumentError)
25
+ }.to raise_error(ArgumentError)
26
26
  end
27
27
  after do
28
28
  # reset load_paths
@@ -2,16 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe Forgery::Address do
4
4
  it "should return a random street" do
5
- Forgery.dictionaries[:streets].should include(Forgery::Address.street_name)
5
+ expect(Forgery.dictionaries[:streets]).to include(Forgery::Address.street_name)
6
6
  end
7
7
 
8
8
  it "should return a random street number" do
9
9
  original_format = Forgery::Address.street_number.gsub(/\d/, '#')
10
- Forgery.formats[:street_number].should include(original_format)
10
+ expect(Forgery.formats[:street_number]).to include(original_format)
11
11
  end
12
12
 
13
13
  it "should return a random street suffix" do
14
- Forgery.dictionaries[:street_suffixes].should include(Forgery::Address.street_suffix)
14
+ expect(Forgery.dictionaries[:street_suffixes]).to include(Forgery::Address.street_suffix)
15
15
  end
16
16
 
17
17
  describe ".street_address" do
@@ -21,64 +21,64 @@ describe Forgery::Address do
21
21
 
22
22
  it "should return a random street suffix" do
23
23
  street_suffix = @split_address.pop
24
- Forgery.dictionaries[:street_suffixes].should include(street_suffix)
24
+ expect(Forgery.dictionaries[:street_suffixes]).to include(street_suffix)
25
25
  end
26
26
 
27
27
  it "should return a random street number" do
28
28
  street_number_format = @split_address.shift.gsub(/\d/, '#')
29
- Forgery.formats[:street_number].should include(street_number_format)
29
+ expect(Forgery.formats[:street_number]).to include(street_number_format)
30
30
  end
31
31
 
32
32
  it "should return a random street" do
33
33
  @split_address.pop
34
34
  @split_address.shift
35
35
  street = @split_address.join(" ")
36
- Forgery.dictionaries[:streets].should include(street)
36
+ expect(Forgery.dictionaries[:streets]).to include(street)
37
37
  end
38
38
  end
39
39
 
40
40
  it "should return a random city" do
41
41
  city = Forgery::Address.city
42
- Forgery.dictionaries[:cities].should include(city)
42
+ expect(Forgery.dictionaries[:cities]).to include(city)
43
43
  end
44
44
 
45
45
  it "should return a random state" do
46
46
  state = Forgery::Address.state
47
- Forgery.dictionaries[:states].should include(state)
47
+ expect(Forgery.dictionaries[:states]).to include(state)
48
48
  end
49
49
 
50
50
  it "should return a random state abbreviation" do
51
51
  state_abbrev = Forgery::Address.state_abbrev
52
- Forgery.dictionaries[:state_abbrevs].should include(state_abbrev)
52
+ expect(Forgery.dictionaries[:state_abbrevs]).to include(state_abbrev)
53
53
  end
54
54
 
55
55
  it "should return a random Canadian province or territory" do
56
56
  province = Forgery::Address.province
57
- Forgery.dictionaries[:provinces].should include(province)
57
+ expect(Forgery.dictionaries[:provinces]).to include(province)
58
58
  end
59
59
 
60
60
  it "should return a random Canadian province or territory abbreviation" do
61
61
  province_abbrev = Forgery::Address.province_abbrev
62
- Forgery.dictionaries[:province_abbrevs].should include(province_abbrev)
62
+ expect(Forgery.dictionaries[:province_abbrevs]).to include(province_abbrev)
63
63
  end
64
64
 
65
65
  it "should return a random country" do
66
66
  country = Forgery::Address.country
67
- Forgery.dictionaries[:countries].should include(country)
67
+ expect(Forgery.dictionaries[:countries]).to include(country)
68
68
  end
69
69
 
70
70
  it "should return a random continent" do
71
71
  continent = Forgery::Address.continent
72
- Forgery.dictionaries[:continents].should include(continent)
72
+ expect(Forgery.dictionaries[:continents]).to include(continent)
73
73
  end
74
74
 
75
75
  it "should return a random zip code" do
76
76
  zip_format = Forgery::Address.zip.gsub(/\d/, '#')
77
- Forgery.formats[:zip].should include(zip_format)
77
+ expect(Forgery.formats[:zip]).to include(zip_format)
78
78
  end
79
79
 
80
80
  it "should return a random phone number" do
81
81
  phone_format = Forgery::Address.phone.gsub(/\d/, '#')
82
- Forgery.formats[:phone].should include(phone_format)
82
+ expect(Forgery.formats[:phone]).to include(phone_format)
83
83
  end
84
84
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Forgery::BankAccount do
4
+
5
+ describe 'ibans' do
6
+ it 'returns a random iban' do
7
+ expect(Forgery.dictionaries[:ibans]).to include(Forgery::BankAccount.iban)
8
+ end
9
+ end
10
+
11
+ describe 'bics' do
12
+ it 'returns a random bic' do
13
+ expect(Forgery.dictionaries[:bics]).to include(Forgery::BankAccount.bic)
14
+ end
15
+ end
16
+ end
@@ -3,54 +3,54 @@ require 'spec_helper'
3
3
  describe Forgery::Basic do
4
4
  describe ".password" do
5
5
  it "should only uppercase characters" do
6
- Forgery::Basic.password(:allow_lower => false,
6
+ expect(Forgery::Basic.password(:allow_lower => false,
7
7
  :allow_upper => true,
8
8
  :allow_numeric => false,
9
- :allow_special => false).should only_contain(Forgery::Basic::UPPER_ALPHA)
9
+ :allow_special => false)).to only_contain(Forgery::Basic::UPPER_ALPHA)
10
10
  end
11
11
 
12
12
  it "should only contain lowercase characters" do
13
- Forgery::Basic.password(:allow_lower => true,
13
+ expect(Forgery::Basic.password(:allow_lower => true,
14
14
  :allow_upper => false,
15
15
  :allow_numeric => false,
16
- :allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA)
16
+ :allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA)
17
17
  end
18
18
 
19
19
  it "should only contain numeric characters" do
20
- Forgery::Basic.password(:allow_lower => false,
20
+ expect(Forgery::Basic.password(:allow_lower => false,
21
21
  :allow_upper => false,
22
22
  :allow_numeric => true,
23
- :allow_special => false).should only_contain(Forgery::Basic::NUMERIC)
23
+ :allow_special => false)).to only_contain(Forgery::Basic::NUMERIC)
24
24
  end
25
25
 
26
26
  it "should only contain special characters" do
27
- Forgery::Basic.password(:allow_lower => false,
27
+ expect(Forgery::Basic.password(:allow_lower => false,
28
28
  :allow_upper => false,
29
29
  :allow_numeric => false,
30
- :allow_special => true).should only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
30
+ :allow_special => true)).to only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
31
31
  end
32
32
 
33
33
  it "should only contain lower and uppercase characters" do
34
- Forgery::Basic.password(:allow_lower => true,
34
+ expect(Forgery::Basic.password(:allow_lower => true,
35
35
  :allow_upper => true,
36
36
  :allow_numeric => false,
37
- :allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA,
37
+ :allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA,
38
38
  Forgery::Basic::UPPER_ALPHA)
39
39
  end
40
40
 
41
41
  it "should only contain numeric and special characters" do
42
- Forgery::Basic.password(:allow_lower => false,
42
+ expect(Forgery::Basic.password(:allow_lower => false,
43
43
  :allow_upper => false,
44
44
  :allow_numeric => true,
45
- :allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
45
+ :allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
46
46
  Forgery::Basic::SPECIAL_CHARACTERS)
47
47
  end
48
48
 
49
49
  it "should contain any of the defined characters" do
50
- Forgery::Basic.password(:allow_lower => true,
50
+ expect(Forgery::Basic.password(:allow_lower => true,
51
51
  :allow_upper => true,
52
52
  :allow_numeric => true,
53
- :allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
53
+ :allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
54
54
  Forgery::Basic::SPECIAL_CHARACTERS,
55
55
  Forgery::Basic::LOWER_ALPHA,
56
56
  Forgery::Basic::UPPER_ALPHA)
@@ -59,118 +59,118 @@ describe Forgery::Basic do
59
59
 
60
60
  describe ".encrypt" do
61
61
  it "should encrypt to hex digits" do
62
- Forgery::Basic.encrypt("something").should only_contain(Forgery::Basic::HEX_DIGITS)
62
+ expect(Forgery::Basic.encrypt("something")).to only_contain(Forgery::Basic::HEX_DIGITS)
63
63
  end
64
64
 
65
65
  it "should encrypt different words to different output" do
66
- Forgery::Basic.encrypt("foo").should_not == Forgery::Basic.encrypt("bar")
66
+ expect(Forgery::Basic.encrypt("foo")).not_to eq(Forgery::Basic.encrypt("bar"))
67
67
  end
68
68
 
69
69
  it "should allow a salt that changes the output" do
70
- Forgery::Basic.encrypt("foo", "baz").should_not == Forgery::Basic.encrypt("foo", "bar")
70
+ expect(Forgery::Basic.encrypt("foo", "baz")).not_to eq(Forgery::Basic.encrypt("foo", "bar"))
71
71
  end
72
72
 
73
73
  it "should have the same output when encrypting twice" do
74
- Forgery::Basic.encrypt("foo", "bar").should == Forgery::Basic.encrypt("foo", "bar")
74
+ expect(Forgery::Basic.encrypt("foo", "bar")).to eq(Forgery::Basic.encrypt("foo", "bar"))
75
75
  end
76
76
  end
77
77
 
78
78
  describe ".boolean" do
79
79
  it "should return true or false" do
80
- [true, false].should include(Forgery::Basic.boolean)
80
+ expect([true, false]).to include(Forgery::Basic.boolean)
81
81
  end
82
82
  end
83
83
 
84
84
  describe ".color" do
85
85
  it "should return a random color" do
86
- Forgery.dictionaries[:colors].should include(Forgery::Basic.color)
86
+ expect(Forgery.dictionaries[:colors]).to include(Forgery::Basic.color)
87
87
  end
88
88
  end
89
89
 
90
90
  describe ".hex_color" do
91
91
  it "should return a 6-character hex color" do
92
- Forgery::Basic.hex_color.should match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){6}/)
92
+ expect(Forgery::Basic.hex_color).to match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){6}/)
93
93
  end
94
94
  end
95
95
 
96
96
  describe ".short_hex_color" do
97
97
  it "should return a 3-character hex color" do
98
- Forgery::Basic.short_hex_color.should match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){3}/)
98
+ expect(Forgery::Basic.short_hex_color).to match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){3}/)
99
99
  end
100
100
  end
101
101
 
102
102
  describe ".number" do
103
103
  it "should return a number >= the at_least option" do
104
- Forgery::Basic.number(:at_least => 2).should >= 2
104
+ expect(Forgery::Basic.number(:at_least => 2)).to be >= 2
105
105
  end
106
106
 
107
107
  it "should return a number <= the at_most option" do
108
- Forgery::Basic.number(:at_most => 12).should <= 12
108
+ expect(Forgery::Basic.number(:at_most => 12)).to be <= 12
109
109
  end
110
110
  end
111
111
 
112
112
  describe ".text" do
113
113
  it "should return text whose length is >= the at_least option" do
114
- Forgery::Basic.text(:at_least => 5).size.should >= 5
114
+ expect(Forgery::Basic.text(:at_least => 5).size).to be >= 5
115
115
  end
116
116
 
117
117
  it "should return text whose length is <= the at_most option" do
118
- Forgery::Basic.text(:at_most => 15).size.should <= 15
118
+ expect(Forgery::Basic.text(:at_most => 15).size).to be <= 15
119
119
  end
120
120
 
121
121
  it "should return text whose length is == the exactly option" do
122
- Forgery::Basic.text(:exactly => 20).size.should == 20
122
+ expect(Forgery::Basic.text(:exactly => 20).size).to eq(20)
123
123
  end
124
124
 
125
125
  it "should only uppercase characters" do
126
- Forgery::Basic.text(:allow_lower => false,
126
+ expect(Forgery::Basic.text(:allow_lower => false,
127
127
  :allow_upper => true,
128
128
  :allow_numeric => false,
129
- :allow_special => false).should only_contain(Forgery::Basic::UPPER_ALPHA)
129
+ :allow_special => false)).to only_contain(Forgery::Basic::UPPER_ALPHA)
130
130
  end
131
131
 
132
132
  it "should only contain lowercase characters" do
133
- Forgery::Basic.text(:allow_lower => true,
133
+ expect(Forgery::Basic.text(:allow_lower => true,
134
134
  :allow_upper => false,
135
135
  :allow_numeric => false,
136
- :allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA)
136
+ :allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA)
137
137
  end
138
138
 
139
139
  it "should only contain numeric characters" do
140
- Forgery::Basic.text(:allow_lower => false,
140
+ expect(Forgery::Basic.text(:allow_lower => false,
141
141
  :allow_upper => false,
142
142
  :allow_numeric => true,
143
- :allow_special => false).should only_contain(Forgery::Basic::NUMERIC)
143
+ :allow_special => false)).to only_contain(Forgery::Basic::NUMERIC)
144
144
  end
145
145
 
146
146
  it "should only contain special characters" do
147
- Forgery::Basic.text(:allow_lower => false,
147
+ expect(Forgery::Basic.text(:allow_lower => false,
148
148
  :allow_upper => false,
149
149
  :allow_numeric => false,
150
- :allow_special => true).should only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
150
+ :allow_special => true)).to only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
151
151
  end
152
152
 
153
153
  it "should only contain lower and uppercase characters" do
154
- Forgery::Basic.text(:allow_lower => true,
154
+ expect(Forgery::Basic.text(:allow_lower => true,
155
155
  :allow_upper => true,
156
156
  :allow_numeric => false,
157
- :allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA,
157
+ :allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA,
158
158
  Forgery::Basic::UPPER_ALPHA)
159
159
  end
160
160
 
161
161
  it "should only contain numeric and special characters" do
162
- Forgery::Basic.text(:allow_lower => false,
162
+ expect(Forgery::Basic.text(:allow_lower => false,
163
163
  :allow_upper => false,
164
164
  :allow_numeric => true,
165
- :allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
165
+ :allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
166
166
  Forgery::Basic::SPECIAL_CHARACTERS)
167
167
  end
168
168
 
169
169
  it "should contain any of the defined characters" do
170
- Forgery::Basic.text(:allow_lower => true,
170
+ expect(Forgery::Basic.text(:allow_lower => true,
171
171
  :allow_upper => true,
172
172
  :allow_numeric => true,
173
- :allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
173
+ :allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
174
174
  Forgery::Basic::SPECIAL_CHARACTERS,
175
175
  Forgery::Basic::LOWER_ALPHA,
176
176
  Forgery::Basic::UPPER_ALPHA)