forgery 0.4.3 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +12 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +35 -0
- data/LICENSE +1 -1
- data/README.markdown +196 -60
- data/Rakefile +10 -54
- data/forgery.gemspec +23 -0
- data/lib/forgery.rb +0 -1
- data/lib/forgery/dictionaries/bics +7 -0
- data/lib/forgery/dictionaries/company_names +0 -1
- data/lib/forgery/dictionaries/currency_descriptions +2 -2
- 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/extend.rb +0 -2
- data/lib/forgery/extensions/range.rb +1 -1
- data/lib/forgery/file_reader.rb +2 -1
- data/lib/forgery/forgery/bank_account.rb +25 -0
- data/lib/forgery/forgery/basic.rb +1 -1
- data/lib/forgery/forgery/credit_card.rb +71 -0
- data/lib/forgery/forgery/geo.rb +54 -0
- data/lib/forgery/forgery/internet.rb +7 -0
- data/lib/forgery/forgery/lorem_ipsum.rb +4 -4
- data/lib/forgery/forgery/russian_tax.rb +57 -0
- data/lib/forgery/forgery_railtie.rb +0 -29
- data/lib/forgery/formats/phone +1 -1
- data/lib/forgery/version.rb +3 -1
- data/spec/data/dictionaries/code_names +6 -0
- data/spec/data/dictionaries/female_first_names +1 -0
- data/spec/data/documents/mock_web_page.html +17 -0
- data/spec/data/documents/mock_xml_doc.xml +5 -0
- data/spec/dictionaries_spec.rb +35 -0
- data/spec/extensions/array_spec.rb +25 -0
- data/spec/extensions/range_spec.rb +33 -0
- data/spec/extensions/string_spec.rb +29 -0
- data/spec/file_reader_spec.rb +32 -0
- data/spec/forgery/address_spec.rb +84 -0
- data/spec/forgery/bank_account_spec.rb +16 -0
- data/spec/forgery/basic_spec.rb +179 -0
- data/spec/forgery/credit_card_spec.rb +68 -0
- data/spec/forgery/currency_spec.rb +15 -0
- data/spec/forgery/date_spec.rb +134 -0
- data/spec/forgery/internet_spec.rb +62 -0
- data/spec/forgery/lorem_ipsum_spec.rb +132 -0
- data/spec/forgery/monetary_spec.rb +14 -0
- data/spec/forgery/name_spec.rb +11 -0
- data/spec/forgery/personal_spec.rb +15 -0
- data/spec/forgery/russian_tax_spec.rb +81 -0
- data/spec/forgery/time_spec.rb +7 -0
- data/spec/forgery_spec.rb +63 -0
- data/spec/formats_spec.rb +35 -0
- data/spec/spec_helper.rb +39 -0
- metadata +89 -38
- data/lib/forgery/file_writer.rb +0 -54
@@ -3,36 +3,7 @@ require 'rails'
|
|
3
3
|
require 'rake'
|
4
4
|
|
5
5
|
class ForgeryRailtie < Rails::Railtie
|
6
|
-
extend Rake::DSL
|
7
|
-
|
8
6
|
config.to_prepare do
|
9
7
|
Forgery.load_from! "#{Rails.root}/lib/forgery"
|
10
8
|
end
|
11
|
-
|
12
|
-
rake_tasks do
|
13
|
-
namespace :forgery do
|
14
|
-
desc %q{
|
15
|
-
Create a dictionary file from web content (xml or html).
|
16
|
-
Writes to the directory specified by Forgery::FileWriter#write_to!
|
17
|
-
'${GEM_HOME}/lib/forgery/dictionaries' by default (standalone)
|
18
|
-
'${Rails.root}/lib/forgery/dictionaries' by default (as a Rails 3 plugin)
|
19
|
-
|
20
|
-
Parameters:
|
21
|
-
:dictionary_name -- the name of your new dictionary file
|
22
|
-
:source_url -- web page containing the data for your dictionary file
|
23
|
-
:css_or_xpath -- css or xpath selector(s) to element(s) containing the desired data
|
24
|
-
|
25
|
-
Usage:
|
26
|
-
rake forgery:create_dictionary[name_of_file,'http://www.html_or_xml_page.com','li']
|
27
|
-
}
|
28
|
-
task :create_dictionary, :dictionary_name, :source_url, :css_or_xpath do |t, args|
|
29
|
-
dictionary_name = args[:dictionary_name].to_s || raise("parameter :dictionary_name is required")
|
30
|
-
source_url = args[:source_url].to_s || raise("parameter :source_url is required")
|
31
|
-
css_or_xpath = args[:css_or_xpath].to_s || raise("parameter :css_or_xpath is required")
|
32
|
-
|
33
|
-
Forgery::FileWriter.write_to! "#{Rails.root}/lib/forgery/dictionaries"
|
34
|
-
Forgery::FileWriter.create_dictionary dictionary_name, source_url, css_or_xpath
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
9
|
end
|
data/lib/forgery/formats/phone
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
#-###-###-####
|
data/lib/forgery/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Amber
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Mock Web Page</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>Title</h1>
|
9
|
+
<h2>Subtitle</h2>
|
10
|
+
<p>Paragraph.</p>
|
11
|
+
<ul id="list">
|
12
|
+
<li>uno</li>
|
13
|
+
<li>dos</li>
|
14
|
+
<li>tres</li>
|
15
|
+
</ul>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Forgery::Dictionaries do
|
4
|
+
it "should check if the dictionary is loaded" do
|
5
|
+
dictionaries = Forgery::Dictionaries.new
|
6
|
+
|
7
|
+
dictionaries[:colors]
|
8
|
+
|
9
|
+
expect(dictionaries).to be_loaded(:colors)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should load a dictionary when called by the key" do
|
13
|
+
dictionaries = Forgery::Dictionaries.new
|
14
|
+
|
15
|
+
dictionaries.reset!
|
16
|
+
|
17
|
+
expect(dictionaries).not_to be_loaded(:colors)
|
18
|
+
|
19
|
+
dictionaries[:colors]
|
20
|
+
|
21
|
+
expect(dictionaries).to be_loaded(:colors)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should clear the loaded dictionaries when calling reset!" do
|
25
|
+
dictionaries = Forgery::Dictionaries.new
|
26
|
+
|
27
|
+
dictionaries[:colors]
|
28
|
+
|
29
|
+
expect(dictionaries).to be_loaded(:colors)
|
30
|
+
|
31
|
+
dictionaries.reset!
|
32
|
+
|
33
|
+
expect(dictionaries).not_to be_loaded(:colors)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Array do
|
4
|
+
before do
|
5
|
+
@array = Forgery::Extend([0,1,2,3,4,5,6,7,8,9])
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should get a random item out of the array" do
|
9
|
+
10.times { expect(@array).to include(@array.random) }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return nil if the array is empty" do
|
13
|
+
expect(Forgery::Extend([]).random).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a random subset of the array" do
|
17
|
+
@array.random_subset(5).each do |i|
|
18
|
+
expect(@array).to include(i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return a random subset of the array that is 3 long" do
|
23
|
+
expect(@array.random_subset(3).size).to eq(3)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
describe Range do
|
5
|
+
it 'should get a random number out of the range' do
|
6
|
+
range = Forgery::Extend(0..9)
|
7
|
+
10.times { expect(range).to include(range.random) }
|
8
|
+
end
|
9
|
+
|
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
|
14
|
+
end
|
15
|
+
|
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 }
|
18
|
+
end
|
19
|
+
|
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) }
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return nil if the maximum is less than the minimum' do
|
26
|
+
expect(Forgery::Extend('z'..'a').random).to be_nil
|
27
|
+
end
|
28
|
+
|
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)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
it "should change a single # to a number 0-9" do
|
5
|
+
expect(0..9).to include(Integer(Forgery::Extend("#").to_numbers))
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should change two #'s to two numbers 0-9" do
|
9
|
+
Forgery::Extend("##").to_numbers.split("").each do |s|
|
10
|
+
expect(0..9).to include(Integer(s))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should only replace #'s in the string with numbers 0-9" do
|
15
|
+
s = Forgery::Extend('###-###-####')
|
16
|
+
n = s.to_numbers
|
17
|
+
0.upto(s.size - 1) do |i|
|
18
|
+
if s[i, 1] == "#"
|
19
|
+
expect('0'..'9').to include(n[i, 1])
|
20
|
+
else
|
21
|
+
expect('0'..'9').not_to include(n[i, 1])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should allow the replacing of a different character" do
|
27
|
+
expect(0..9).to include(Integer(Forgery::Extend("-").to_numbers("-")))
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Forgery::FileReader do
|
4
|
+
it "should return an array when calling read_dictionary" do
|
5
|
+
expect(Forgery::FileReader.read_dictionary(:colors)).to be_is_a(Array)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return an array when calling read_format" do
|
9
|
+
expect(Forgery::FileReader.read_format(:phone)).to be_is_a(Array)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should override default dictionaries if Forgery#load_from! was called" do
|
13
|
+
Forgery.load_from! "spec/data"
|
14
|
+
expect(Forgery::FileReader.read_dictionary(:female_first_names)).to eq(%w(Amber))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should read dictionaries from custom places if Forgery#load_from! was called" do
|
18
|
+
Forgery.load_from! "spec/data"
|
19
|
+
expect(Forgery::FileReader.read_dictionary(:code_names)).to include('Shiretoko')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should raise an exception if file wasn't found in load paths" do
|
23
|
+
expect {
|
24
|
+
Forgery::FileReader.read_dictionary(:non_existing_dictionary)
|
25
|
+
}.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
after do
|
28
|
+
# reset load_paths
|
29
|
+
Forgery.load_paths.clear
|
30
|
+
Forgery.load_paths << File.expand_path("lib/forgery")
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Forgery::Address do
|
4
|
+
it "should return a random street" do
|
5
|
+
expect(Forgery.dictionaries[:streets]).to include(Forgery::Address.street_name)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return a random street number" do
|
9
|
+
original_format = Forgery::Address.street_number.gsub(/\d/, '#')
|
10
|
+
expect(Forgery.formats[:street_number]).to include(original_format)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return a random street suffix" do
|
14
|
+
expect(Forgery.dictionaries[:street_suffixes]).to include(Forgery::Address.street_suffix)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".street_address" do
|
18
|
+
before do
|
19
|
+
@split_address = Forgery::Address.street_address.split
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return a random street suffix" do
|
23
|
+
street_suffix = @split_address.pop
|
24
|
+
expect(Forgery.dictionaries[:street_suffixes]).to include(street_suffix)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return a random street number" do
|
28
|
+
street_number_format = @split_address.shift.gsub(/\d/, '#')
|
29
|
+
expect(Forgery.formats[:street_number]).to include(street_number_format)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return a random street" do
|
33
|
+
@split_address.pop
|
34
|
+
@split_address.shift
|
35
|
+
street = @split_address.join(" ")
|
36
|
+
expect(Forgery.dictionaries[:streets]).to include(street)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return a random city" do
|
41
|
+
city = Forgery::Address.city
|
42
|
+
expect(Forgery.dictionaries[:cities]).to include(city)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return a random state" do
|
46
|
+
state = Forgery::Address.state
|
47
|
+
expect(Forgery.dictionaries[:states]).to include(state)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return a random state abbreviation" do
|
51
|
+
state_abbrev = Forgery::Address.state_abbrev
|
52
|
+
expect(Forgery.dictionaries[:state_abbrevs]).to include(state_abbrev)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return a random Canadian province or territory" do
|
56
|
+
province = Forgery::Address.province
|
57
|
+
expect(Forgery.dictionaries[:provinces]).to include(province)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return a random Canadian province or territory abbreviation" do
|
61
|
+
province_abbrev = Forgery::Address.province_abbrev
|
62
|
+
expect(Forgery.dictionaries[:province_abbrevs]).to include(province_abbrev)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return a random country" do
|
66
|
+
country = Forgery::Address.country
|
67
|
+
expect(Forgery.dictionaries[:countries]).to include(country)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return a random continent" do
|
71
|
+
continent = Forgery::Address.continent
|
72
|
+
expect(Forgery.dictionaries[:continents]).to include(continent)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should return a random zip code" do
|
76
|
+
zip_format = Forgery::Address.zip.gsub(/\d/, '#')
|
77
|
+
expect(Forgery.formats[:zip]).to include(zip_format)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return a random phone number" do
|
81
|
+
phone_format = Forgery::Address.phone.gsub(/\d/, '#')
|
82
|
+
expect(Forgery.formats[:phone]).to include(phone_format)
|
83
|
+
end
|
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
|
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Forgery::Basic do
|
4
|
+
describe ".password" do
|
5
|
+
it "should only uppercase characters" do
|
6
|
+
expect(Forgery::Basic.password(:allow_lower => false,
|
7
|
+
:allow_upper => true,
|
8
|
+
:allow_numeric => false,
|
9
|
+
:allow_special => false)).to only_contain(Forgery::Basic::UPPER_ALPHA)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should only contain lowercase characters" do
|
13
|
+
expect(Forgery::Basic.password(:allow_lower => true,
|
14
|
+
:allow_upper => false,
|
15
|
+
:allow_numeric => false,
|
16
|
+
:allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should only contain numeric characters" do
|
20
|
+
expect(Forgery::Basic.password(:allow_lower => false,
|
21
|
+
:allow_upper => false,
|
22
|
+
:allow_numeric => true,
|
23
|
+
:allow_special => false)).to only_contain(Forgery::Basic::NUMERIC)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should only contain special characters" do
|
27
|
+
expect(Forgery::Basic.password(:allow_lower => false,
|
28
|
+
:allow_upper => false,
|
29
|
+
:allow_numeric => false,
|
30
|
+
:allow_special => true)).to only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should only contain lower and uppercase characters" do
|
34
|
+
expect(Forgery::Basic.password(:allow_lower => true,
|
35
|
+
:allow_upper => true,
|
36
|
+
:allow_numeric => false,
|
37
|
+
:allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA,
|
38
|
+
Forgery::Basic::UPPER_ALPHA)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should only contain numeric and special characters" do
|
42
|
+
expect(Forgery::Basic.password(:allow_lower => false,
|
43
|
+
:allow_upper => false,
|
44
|
+
:allow_numeric => true,
|
45
|
+
:allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
|
46
|
+
Forgery::Basic::SPECIAL_CHARACTERS)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should contain any of the defined characters" do
|
50
|
+
expect(Forgery::Basic.password(:allow_lower => true,
|
51
|
+
:allow_upper => true,
|
52
|
+
:allow_numeric => true,
|
53
|
+
:allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
|
54
|
+
Forgery::Basic::SPECIAL_CHARACTERS,
|
55
|
+
Forgery::Basic::LOWER_ALPHA,
|
56
|
+
Forgery::Basic::UPPER_ALPHA)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ".encrypt" do
|
61
|
+
it "should encrypt to hex digits" do
|
62
|
+
expect(Forgery::Basic.encrypt("something")).to only_contain(Forgery::Basic::HEX_DIGITS)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should encrypt different words to different output" do
|
66
|
+
expect(Forgery::Basic.encrypt("foo")).not_to eq(Forgery::Basic.encrypt("bar"))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should allow a salt that changes the output" do
|
70
|
+
expect(Forgery::Basic.encrypt("foo", "baz")).not_to eq(Forgery::Basic.encrypt("foo", "bar"))
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should have the same output when encrypting twice" do
|
74
|
+
expect(Forgery::Basic.encrypt("foo", "bar")).to eq(Forgery::Basic.encrypt("foo", "bar"))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".boolean" do
|
79
|
+
it "should return true or false" do
|
80
|
+
expect([true, false]).to include(Forgery::Basic.boolean)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ".color" do
|
85
|
+
it "should return a random color" do
|
86
|
+
expect(Forgery.dictionaries[:colors]).to include(Forgery::Basic.color)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe ".hex_color" do
|
91
|
+
it "should return a 6-character hex color" do
|
92
|
+
expect(Forgery::Basic.hex_color).to match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){6}/)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".short_hex_color" do
|
97
|
+
it "should return a 3-character hex color" do
|
98
|
+
expect(Forgery::Basic.short_hex_color).to match(/#(#{Forgery::Basic::HEX_DIGITS.join('|')}){3}/)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe ".number" do
|
103
|
+
it "should return a number >= the at_least option" do
|
104
|
+
expect(Forgery::Basic.number(:at_least => 2)).to be >= 2
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should return a number <= the at_most option" do
|
108
|
+
expect(Forgery::Basic.number(:at_most => 12)).to be <= 12
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe ".text" do
|
113
|
+
it "should return text whose length is >= the at_least option" do
|
114
|
+
expect(Forgery::Basic.text(:at_least => 5).size).to be >= 5
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return text whose length is <= the at_most option" do
|
118
|
+
expect(Forgery::Basic.text(:at_most => 15).size).to be <= 15
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return text whose length is == the exactly option" do
|
122
|
+
expect(Forgery::Basic.text(:exactly => 20).size).to eq(20)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should only uppercase characters" do
|
126
|
+
expect(Forgery::Basic.text(:allow_lower => false,
|
127
|
+
:allow_upper => true,
|
128
|
+
:allow_numeric => false,
|
129
|
+
:allow_special => false)).to only_contain(Forgery::Basic::UPPER_ALPHA)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should only contain lowercase characters" do
|
133
|
+
expect(Forgery::Basic.text(:allow_lower => true,
|
134
|
+
:allow_upper => false,
|
135
|
+
:allow_numeric => false,
|
136
|
+
:allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should only contain numeric characters" do
|
140
|
+
expect(Forgery::Basic.text(:allow_lower => false,
|
141
|
+
:allow_upper => false,
|
142
|
+
:allow_numeric => true,
|
143
|
+
:allow_special => false)).to only_contain(Forgery::Basic::NUMERIC)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should only contain special characters" do
|
147
|
+
expect(Forgery::Basic.text(:allow_lower => false,
|
148
|
+
:allow_upper => false,
|
149
|
+
:allow_numeric => false,
|
150
|
+
:allow_special => true)).to only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should only contain lower and uppercase characters" do
|
154
|
+
expect(Forgery::Basic.text(:allow_lower => true,
|
155
|
+
:allow_upper => true,
|
156
|
+
:allow_numeric => false,
|
157
|
+
:allow_special => false)).to only_contain(Forgery::Basic::LOWER_ALPHA,
|
158
|
+
Forgery::Basic::UPPER_ALPHA)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should only contain numeric and special characters" do
|
162
|
+
expect(Forgery::Basic.text(:allow_lower => false,
|
163
|
+
:allow_upper => false,
|
164
|
+
:allow_numeric => true,
|
165
|
+
:allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
|
166
|
+
Forgery::Basic::SPECIAL_CHARACTERS)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should contain any of the defined characters" do
|
170
|
+
expect(Forgery::Basic.text(:allow_lower => true,
|
171
|
+
:allow_upper => true,
|
172
|
+
:allow_numeric => true,
|
173
|
+
:allow_special => true)).to only_contain(Forgery::Basic::NUMERIC,
|
174
|
+
Forgery::Basic::SPECIAL_CHARACTERS,
|
175
|
+
Forgery::Basic::LOWER_ALPHA,
|
176
|
+
Forgery::Basic::UPPER_ALPHA)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|