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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -5
- data/Gemfile.lock +20 -12
- data/README.markdown +147 -0
- data/forgery.gemspec +15 -15
- data/lib/forgery/dictionaries/bics +7 -0
- data/lib/forgery/dictionaries/ibans +61 -0
- data/lib/forgery/dictionaries/job_titles +1 -1
- data/lib/forgery/dictionaries/zones +1 -2
- data/lib/forgery/extensions/range.rb +1 -1
- data/lib/forgery/file_reader.rb +1 -1
- data/lib/forgery/forgery/bank_account.rb +25 -0
- data/lib/forgery/forgery/credit_card.rb +1 -1
- data/lib/forgery/forgery/lorem_ipsum.rb +4 -4
- data/lib/forgery/formats/phone +1 -1
- data/lib/forgery/version.rb +1 -1
- data/spec/dictionaries_spec.rb +5 -5
- data/spec/extensions/array_spec.rb +4 -4
- data/spec/extensions/range_spec.rb +16 -14
- data/spec/extensions/string_spec.rb +5 -5
- data/spec/file_reader_spec.rb +6 -6
- data/spec/forgery/address_spec.rb +15 -15
- data/spec/forgery/bank_account_spec.rb +16 -0
- data/spec/forgery/basic_spec.rb +41 -41
- data/spec/forgery/credit_card_spec.rb +9 -9
- data/spec/forgery/currency_spec.rb +2 -2
- data/spec/forgery/date_spec.rb +21 -21
- data/spec/forgery/internet_spec.rb +11 -11
- data/spec/forgery/lorem_ipsum_spec.rb +25 -25
- data/spec/forgery/monetary_spec.rb +2 -2
- data/spec/forgery/name_spec.rb +2 -2
- data/spec/forgery/personal_spec.rb +2 -2
- data/spec/forgery/russian_tax_spec.rb +13 -13
- data/spec/forgery/time_spec.rb +1 -1
- data/spec/forgery_spec.rb +25 -25
- data/spec/formats_spec.rb +5 -5
- metadata +10 -5
data/spec/forgery/name_spec.rb
CHANGED
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Forgery::Name do
|
4
4
|
it "should return a random first name" do
|
5
|
-
(Forgery.dictionaries[:male_first_names] + Forgery.dictionaries[:female_first_names]).
|
5
|
+
expect(Forgery.dictionaries[:male_first_names] + Forgery.dictionaries[:female_first_names]).to include(Forgery::Name.first_name)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should return a random last name" do
|
9
|
-
Forgery.dictionaries[:last_names].
|
9
|
+
expect(Forgery.dictionaries[:last_names]).to include(Forgery::Name.last_name)
|
10
10
|
end
|
11
11
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Forgery::Personal do
|
4
4
|
describe '.gender' do
|
5
5
|
it 'should return male or female' do
|
6
|
-
Forgery.dictionaries[:genders].
|
6
|
+
expect(Forgery.dictionaries[:genders]).to include(Forgery::Personal.gender)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '.shirt_size' do
|
11
11
|
it 'should return a sane size' do
|
12
|
-
Forgery.dictionaries[:shirt_sizes].
|
12
|
+
expect(Forgery.dictionaries[:shirt_sizes]).to include(Forgery::Personal.shirt_size)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,31 +3,31 @@ require 'spec_helper'
|
|
3
3
|
describe Forgery::RussianTax do
|
4
4
|
|
5
5
|
it 'bik should be 9 symbols' do
|
6
|
-
Forgery::RussianTax.bik.length.
|
6
|
+
expect(Forgery::RussianTax.bik.length).to eq 9
|
7
7
|
end
|
8
8
|
|
9
9
|
it "bik should start with 04" do
|
10
|
-
Forgery::RussianTax.bik[0,2].
|
10
|
+
expect(Forgery::RussianTax.bik[0,2]).to eq '04'
|
11
11
|
end
|
12
12
|
|
13
13
|
it "bik should have valid last part" do
|
14
|
-
Forgery::RussianTax.bik[6,8].to_i.
|
14
|
+
expect(Forgery::RussianTax.bik[6,8].to_i).to be > 50
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'bik should be 20 symbols' do
|
18
|
-
Forgery::RussianTax.account_number.length.
|
18
|
+
expect(Forgery::RussianTax.account_number.length).to eq 20
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'legal inn' do
|
22
22
|
let(:inn) { Forgery::RussianTax.inn({ :type =>:legal }) }
|
23
23
|
|
24
24
|
it 'legal inn should be 10 symbols' do
|
25
|
-
inn.length.
|
25
|
+
expect(inn.length).to eq 10
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'leagl inn crc' do
|
29
29
|
mask = [2, 4, 10, 3, 5, 9, 4, 6, 8]
|
30
|
-
((0..(inn.length-2)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).
|
30
|
+
expect((0..(inn.length-2)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).to eq inn[9].chr.to_i
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -36,17 +36,17 @@ describe Forgery::RussianTax do
|
|
36
36
|
let(:inn) { Forgery::RussianTax.inn({ :type => :person }) }
|
37
37
|
|
38
38
|
it 'person inn should be 12 symbols' do
|
39
|
-
inn.length.
|
39
|
+
expect(inn.length).to eq 12
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'person inn crc 10' do
|
43
43
|
mask = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8]
|
44
|
-
((0..(inn.length-3)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).
|
44
|
+
expect((0..(inn.length-3)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).to eq inn[10].chr.to_i
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'person inn crc 11' do
|
48
48
|
mask = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8]
|
49
|
-
((0..(inn.length-2)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).
|
49
|
+
expect((0..(inn.length-2)).inject(0) {|crc, i| crc + inn[i].to_i*mask[i].to_i} % 11 % 10).to eq inn[11].chr.to_i
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -55,11 +55,11 @@ describe Forgery::RussianTax do
|
|
55
55
|
let(:ogrn) { Forgery::RussianTax.ogrn({ :type => :legal }) }
|
56
56
|
|
57
57
|
it 'legal ogrn should be 13 symbols' do
|
58
|
-
ogrn.length.
|
58
|
+
expect(ogrn.length).to eq 13
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'legal ogrn should have valid crc' do
|
62
|
-
(ogrn[0..-2].to_i%11%10).
|
62
|
+
expect(ogrn[0..-2].to_i%11%10).to eq ogrn[-1].chr.to_i
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -67,11 +67,11 @@ describe Forgery::RussianTax do
|
|
67
67
|
let(:ogrn) { Forgery::RussianTax.ogrn({ :type => :person }) }
|
68
68
|
|
69
69
|
it 'person ogrn should be 15 symbols' do
|
70
|
-
ogrn.length.
|
70
|
+
expect(ogrn.length).to eq 15
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'person ogrn should have valid crc' do
|
74
|
-
(ogrn[0..-2].to_i%13%10).
|
74
|
+
expect(ogrn[0..-2].to_i%13%10).to eq ogrn[-1].chr.to_i
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
data/spec/forgery/time_spec.rb
CHANGED
data/spec/forgery_spec.rb
CHANGED
@@ -2,62 +2,62 @@ require 'spec_helper'
|
|
2
2
|
require 'pathname'
|
3
3
|
|
4
4
|
describe Forgery do
|
5
|
-
it
|
5
|
+
it 'should load a dictionary when it is requested' do
|
6
6
|
Forgery.dictionaries.reset!
|
7
7
|
|
8
|
-
Forgery.dictionaries.
|
8
|
+
expect(Forgery.dictionaries).not_to be_loaded(:colors)
|
9
9
|
|
10
10
|
Forgery.dictionaries[:colors]
|
11
11
|
|
12
|
-
Forgery.dictionaries.
|
12
|
+
expect(Forgery.dictionaries).to be_loaded(:colors)
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should load formats when it is requested' do
|
16
16
|
Forgery.formats.reset!
|
17
17
|
|
18
|
-
Forgery.formats.
|
18
|
+
expect(Forgery.formats).not_to be_loaded(:phone)
|
19
19
|
|
20
20
|
Forgery.formats[:phone]
|
21
21
|
|
22
|
-
Forgery.formats.
|
22
|
+
expect(Forgery.formats).to be_loaded(:phone)
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
Forgery(:address).
|
27
|
-
Forgery(:basic).
|
28
|
-
Forgery(:internet).
|
25
|
+
it 'should accept a symbol and return the appropriate forgery class' do
|
26
|
+
expect(Forgery(:address)).to eq(Forgery::Address)
|
27
|
+
expect(Forgery(:basic)).to eq(Forgery::Basic)
|
28
|
+
expect(Forgery(:internet)).to eq(Forgery::Internet)
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
Forgery::Address.
|
31
|
+
it 'should accept two symbols, finding the right class and calling the appropriate method' do
|
32
|
+
expect(Forgery::Address).to receive(:street_name)
|
33
33
|
Forgery(:address, :street_name)
|
34
34
|
|
35
|
-
Forgery::Name.
|
35
|
+
expect(Forgery::Name).to receive(:full_name)
|
36
36
|
Forgery(:name, :full_name)
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
Forgery::LoremIpsum.
|
39
|
+
it 'should accept two symbols and arguments, passing them along to the appropriate method' do
|
40
|
+
expect(Forgery::LoremIpsum).to receive(:text).with(:sentences, 2)
|
41
41
|
Forgery(:lorem_ipsum, :text, :sentences, 2)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it 'should return the rails root path as a string if Rails.root is defined' do
|
45
45
|
Rails = Object.new
|
46
|
-
Rails.
|
47
|
-
Forgery.rails_root.
|
46
|
+
allow(Rails).to receive(:root).and_return(Pathname.new('/path/from/rails/dot/root'))
|
47
|
+
expect(Forgery.rails_root).to eq('/path/from/rails/dot/root')
|
48
48
|
Object.instance_eval { remove_const(:Rails) }
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
Forgery.rails_root.
|
51
|
+
it 'should return nil when Rails.root and Rails.root are not defined' do
|
52
|
+
expect(Forgery.rails_root).to be_nil
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
Forgery.rails
|
55
|
+
it 'should not be a rails environment when there is not a rails_root' do
|
56
|
+
expect(Forgery.rails?).to be false
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
Forgery.
|
61
|
-
Forgery.rails
|
59
|
+
it 'should be a rails environment when there is a rails_root' do
|
60
|
+
allow(Forgery).to receive(:rails?).and_return(true)
|
61
|
+
expect(Forgery.rails?).to be true
|
62
62
|
end
|
63
63
|
end
|
data/spec/formats_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Forgery::Formats do
|
|
6
6
|
|
7
7
|
formats[:phone]
|
8
8
|
|
9
|
-
formats.
|
9
|
+
expect(formats).to be_loaded(:phone)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should load a dictionary when called by the key" do
|
@@ -14,11 +14,11 @@ describe Forgery::Formats do
|
|
14
14
|
|
15
15
|
formats.reset!
|
16
16
|
|
17
|
-
formats.
|
17
|
+
expect(formats).not_to be_loaded(:phone)
|
18
18
|
|
19
19
|
formats[:phone]
|
20
20
|
|
21
|
-
formats.
|
21
|
+
expect(formats).to be_loaded(:phone)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should clear the loaded formats when calling reset!" do
|
@@ -26,10 +26,10 @@ describe Forgery::Formats do
|
|
26
26
|
|
27
27
|
formats[:phone]
|
28
28
|
|
29
|
-
formats.
|
29
|
+
expect(formats).to be_loaded(:phone)
|
30
30
|
|
31
31
|
formats.reset!
|
32
32
|
|
33
|
-
formats.
|
33
|
+
expect(formats).not_to be_loaded(:phone)
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forgery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Sutton
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.16.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 1.16.0
|
29
29
|
description: Easy and customizable generation of forged data. Can be used as a gem
|
30
30
|
or a rails plugin. Includes rails generators for creating your own forgeries.
|
31
31
|
email:
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- generators/forgery/forgery_generator.rb
|
49
49
|
- lib/forgery.rb
|
50
50
|
- lib/forgery/dictionaries.rb
|
51
|
+
- lib/forgery/dictionaries/bics
|
51
52
|
- lib/forgery/dictionaries/cities
|
52
53
|
- lib/forgery/dictionaries/colors
|
53
54
|
- lib/forgery/dictionaries/company_names
|
@@ -59,6 +60,7 @@ files:
|
|
59
60
|
- lib/forgery/dictionaries/female_first_names
|
60
61
|
- lib/forgery/dictionaries/frequencies
|
61
62
|
- lib/forgery/dictionaries/genders
|
63
|
+
- lib/forgery/dictionaries/ibans
|
62
64
|
- lib/forgery/dictionaries/industries
|
63
65
|
- lib/forgery/dictionaries/job_title_suffixes
|
64
66
|
- lib/forgery/dictionaries/job_titles
|
@@ -86,6 +88,7 @@ files:
|
|
86
88
|
- lib/forgery/file_reader.rb
|
87
89
|
- lib/forgery/forgery.rb
|
88
90
|
- lib/forgery/forgery/address.rb
|
91
|
+
- lib/forgery/forgery/bank_account.rb
|
89
92
|
- lib/forgery/forgery/basic.rb
|
90
93
|
- lib/forgery/forgery/credit_card.rb
|
91
94
|
- lib/forgery/forgery/currency.rb
|
@@ -117,6 +120,7 @@ files:
|
|
117
120
|
- spec/extensions/string_spec.rb
|
118
121
|
- spec/file_reader_spec.rb
|
119
122
|
- spec/forgery/address_spec.rb
|
123
|
+
- spec/forgery/bank_account_spec.rb
|
120
124
|
- spec/forgery/basic_spec.rb
|
121
125
|
- spec/forgery/credit_card_spec.rb
|
122
126
|
- spec/forgery/currency_spec.rb
|
@@ -150,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
154
|
version: 1.3.6
|
151
155
|
requirements: []
|
152
156
|
rubyforge_project: forgery
|
153
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.6.13
|
154
158
|
signing_key:
|
155
159
|
specification_version: 4
|
156
160
|
summary: Easy and customizable generation of forged data.
|
@@ -165,6 +169,7 @@ test_files:
|
|
165
169
|
- spec/extensions/string_spec.rb
|
166
170
|
- spec/file_reader_spec.rb
|
167
171
|
- spec/forgery/address_spec.rb
|
172
|
+
- spec/forgery/bank_account_spec.rb
|
168
173
|
- spec/forgery/basic_spec.rb
|
169
174
|
- spec/forgery/credit_card_spec.rb
|
170
175
|
- spec/forgery/currency_spec.rb
|