forgery 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +99 -0
- data/VERSION.yml +4 -0
- data/generators/forgery/USAGE +6 -0
- data/generators/forgery/forgery_generator.rb +12 -0
- data/lib/dictionaries.rb +24 -0
- data/lib/dictionaries/cities +478 -0
- data/lib/dictionaries/colors +19 -0
- data/lib/dictionaries/company_names +400 -0
- data/lib/dictionaries/countries +249 -0
- data/lib/dictionaries/female_first_names +100 -0
- data/lib/dictionaries/frequencies +8 -0
- data/lib/dictionaries/genders +2 -0
- data/lib/dictionaries/languages +97 -0
- data/lib/dictionaries/last_names +250 -0
- data/lib/dictionaries/lorem_ipsum +151 -0
- data/lib/dictionaries/male_first_names +100 -0
- data/lib/dictionaries/name_suffixes +5 -0
- data/lib/dictionaries/name_titles +6 -0
- data/lib/dictionaries/province_abbrevs +13 -0
- data/lib/dictionaries/provinces +13 -0
- data/lib/dictionaries/races +93 -0
- data/lib/dictionaries/shirt_sizes +7 -0
- data/lib/dictionaries/state_abbrevs +50 -0
- data/lib/dictionaries/states +50 -0
- data/lib/dictionaries/street_suffixes +21 -0
- data/lib/dictionaries/streets +500 -0
- data/lib/dictionaries/top_level_domains +9 -0
- data/lib/extensions/array.rb +11 -0
- data/lib/extensions/hash.rb +12 -0
- data/lib/extensions/range.rb +9 -0
- data/lib/extensions/string.rb +48 -0
- data/lib/file_reader.rb +53 -0
- data/lib/forgeries/address_forgery.rb +136 -0
- data/lib/forgeries/basic_forgery.rb +71 -0
- data/lib/forgeries/internet_forgery.rb +17 -0
- data/lib/forgeries/lorem_ipsum_forgery.rb +112 -0
- data/lib/forgeries/monetary_forgery.rb +13 -0
- data/lib/forgeries/name_forgery.rb +34 -0
- data/lib/forgeries/personal_forgery.rb +22 -0
- data/lib/forgery.rb +47 -0
- data/lib/formats.rb +24 -0
- data/lib/formats/phone +1 -0
- data/lib/formats/street_number +5 -0
- data/lib/formats/zip +2 -0
- data/spec/dictionaries_spec.rb +35 -0
- data/spec/extensions/array_spec.rb +25 -0
- data/spec/extensions/range_spec.rb +26 -0
- data/spec/extensions/string_spec.rb +29 -0
- data/spec/file_reader_spec.rb +11 -0
- data/spec/forgeries/address_forgery_spec.rb +79 -0
- data/spec/forgeries/basic_forgery_spec.rb +175 -0
- data/spec/forgeries/internet_forgery_spec.rb +30 -0
- data/spec/forgeries/lorem_ipsum_forgery_spec.rb +128 -0
- data/spec/forgeries/monetary_forgery_spec.rb +4 -0
- data/spec/forgeries/name_forgery_spec.rb +4 -0
- data/spec/forgeries/personal_forgery_spec.rb +15 -0
- data/spec/forgery_spec.rb +42 -0
- data/spec/formats_spec.rb +35 -0
- data/spec/spec_helper.rb +32 -0
- metadata +114 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe InternetForgery do
|
4
|
+
describe ".user_name" do
|
5
|
+
it "should return a username that is lowercase" do
|
6
|
+
InternetForgery.user_name.should only_contain(BasicForgery::LOWER_ALPHA)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return a top level domain" do
|
11
|
+
Forgery.dictionaries[:top_level_domains].should include(InternetForgery.top_level_domain)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".domain_name" do
|
15
|
+
it "should return a domain name that contains a lowercase company name" do
|
16
|
+
downcase_company_name = InternetForgery.domain_name.split('.').first
|
17
|
+
Forgery.dictionaries[:company_names].any?{ |cn| cn =~ /#{downcase_company_name}/i }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return a domain name that contains a top level domain" do
|
21
|
+
Forgery.dictionaries[:top_level_domains].should include(InternetForgery.domain_name.split('.').last)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".email_address" do
|
26
|
+
it "should match the email format" do
|
27
|
+
InternetForgery.email_address.should match(/.+@.+\.(#{Forgery.dictionaries[:top_level_domains].join("|")})/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe LoremIpsumForgery do
|
4
|
+
describe ".paragraphs" do
|
5
|
+
it "should return text" do
|
6
|
+
LoremIpsumForgery.paragraphs.should be_a_kind_of(String)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return text with 1 or more character" do
|
10
|
+
LoremIpsumForgery.paragraphs.size.should >= 1
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should default to returning 2 paragraphs separated by \\n\\n" do
|
14
|
+
LoremIpsumForgery.paragraphs.split("\n\n").size.should == 2
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should default to returning 3 sentences per paragraph" do
|
18
|
+
paragraphs = LoremIpsumForgery.paragraphs.split("\n\n")
|
19
|
+
paragraphs.each do |paragraph|
|
20
|
+
paragraph.scan(".").size.should == 3
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should wrap paragraphs in html paragraph tags when the :html option is true" do
|
25
|
+
paragraphs = LoremIpsumForgery.paragraphs(2, :html => true).split("\n\n")
|
26
|
+
paragraphs.each do |paragraph|
|
27
|
+
paragraph.should match(/<p>.+?<\/p>/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should wrap paragraphs in specified wrapping text" do
|
32
|
+
paragraphs = LoremIpsumForgery.paragraphs(2, :wrap => {:start => "foo", :end => "bar"}).split("\n\n")
|
33
|
+
paragraphs.each do |paragraph|
|
34
|
+
paragraph.should match(/foo.+bar/)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should separate paragraphs with the specified string" do
|
39
|
+
LoremIpsumForgery.paragraphs(2, :separator => "foo").split("foo").size.should == 2
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".paragraph" do
|
44
|
+
it "should return text" do
|
45
|
+
LoremIpsumForgery.paragraph.should be_a_kind_of(String)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return text with 1 or more character" do
|
49
|
+
LoremIpsumForgery.paragraph.size.should >= 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return a single paragraph" do
|
53
|
+
LoremIpsumForgery.paragraph.scan("\n\n").size.should == 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe ".sentences" do
|
58
|
+
it "should return text" do
|
59
|
+
LoremIpsumForgery.sentences.should be_a_kind_of(String)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return text with 1 or more character" do
|
63
|
+
LoremIpsumForgery.sentences.size.should >= 1
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return two sentences by default" do
|
67
|
+
LoremIpsumForgery.sentences.scan(".").size.should == 2
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return as many sentences as you specify" do
|
71
|
+
LoremIpsumForgery.sentences(4).scan(".").size.should == 4
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".sentence" do
|
76
|
+
it "should return text" do
|
77
|
+
LoremIpsumForgery.sentence.should be_a_kind_of(String)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return text with 1 or more character" do
|
81
|
+
LoremIpsumForgery.sentence.size.should >= 1
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return a single sentence" do
|
85
|
+
LoremIpsumForgery.sentence.scan(".").size.should == 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe ".words" do
|
90
|
+
it "should return text" do
|
91
|
+
LoremIpsumForgery.words.should be_a_kind_of(String)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should return text with 1 or more character" do
|
95
|
+
LoremIpsumForgery.words.size.should >= 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe ".word" do
|
100
|
+
it "should return text" do
|
101
|
+
LoremIpsumForgery.word.should be_a_kind_of(String)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return text with 1 or more character" do
|
105
|
+
LoremIpsumForgery.word.size.should >= 1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe ".characters" do
|
110
|
+
it "should return text" do
|
111
|
+
LoremIpsumForgery.characters.should be_a_kind_of(String)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should return text with 1 or more character" do
|
115
|
+
LoremIpsumForgery.characters.size.should >= 1
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe ".character" do
|
120
|
+
it "should return text" do
|
121
|
+
LoremIpsumForgery.character.should be_a_kind_of(String)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return text with 1 or more character" do
|
125
|
+
LoremIpsumForgery.character.size.should >= 1
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe PersonalForgery do
|
4
|
+
describe '.gender' do
|
5
|
+
it 'should return male or female' do
|
6
|
+
Forgery.dictionaries[:genders].should include(PersonalForgery.gender)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.shirt_size' do
|
11
|
+
it 'should return a sane size' do
|
12
|
+
Forgery.dictionaries[:shirt_sizes].should include(PersonalForgery.shirt_size)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Forgery do
|
4
|
+
it "should load a dictionary when it is requested" do
|
5
|
+
Forgery.dictionaries.reset!
|
6
|
+
|
7
|
+
Forgery.dictionaries.should_not be_loaded(:colors)
|
8
|
+
|
9
|
+
Forgery.dictionaries[:colors]
|
10
|
+
|
11
|
+
Forgery.dictionaries.should be_loaded(:colors)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should load formats when it is requested" do
|
15
|
+
Forgery.formats.reset!
|
16
|
+
|
17
|
+
Forgery.formats.should_not be_loaded(:phone)
|
18
|
+
|
19
|
+
Forgery.formats[:phone]
|
20
|
+
|
21
|
+
Forgery.formats.should be_loaded(:phone)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should accept a symbol and return the appropriate forgery class" do
|
25
|
+
Forgery(:address).should == AddressForgery
|
26
|
+
Forgery(:basic).should == BasicForgery
|
27
|
+
Forgery(:internet).should == InternetForgery
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept two symbols, finding the right class and calling the appropriate method" do
|
31
|
+
AddressForgery.should_receive(:street_name)
|
32
|
+
Forgery(:address, :street_name)
|
33
|
+
|
34
|
+
NameForgery.should_receive(:full_name)
|
35
|
+
Forgery(:name, :full_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should accept two symbols and arguments, passing them along to the appropriate method" do
|
39
|
+
LoremIpsumForgery.should_receive(:text).with(:sentences, 2)
|
40
|
+
Forgery(:lorem_ipsum, :text, :sentences, 2)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Formats do
|
4
|
+
it "should check if the dictionary is loaded" do
|
5
|
+
formats = Formats.new
|
6
|
+
|
7
|
+
formats[:phone]
|
8
|
+
|
9
|
+
formats.should be_loaded(:phone)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should load a dictionary when called by the key" do
|
13
|
+
formats = Formats.new
|
14
|
+
|
15
|
+
formats.reset!
|
16
|
+
|
17
|
+
formats.should_not be_loaded(:phone)
|
18
|
+
|
19
|
+
formats[:phone]
|
20
|
+
|
21
|
+
formats.should be_loaded(:phone)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should clear the loaded formats when calling reset!" do
|
25
|
+
formats = Formats.new
|
26
|
+
|
27
|
+
formats[:phone]
|
28
|
+
|
29
|
+
formats.should be_loaded(:phone)
|
30
|
+
|
31
|
+
formats.reset!
|
32
|
+
|
33
|
+
formats.should_not be_loaded(:phone)
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec'
|
2
|
+
require File.dirname(__FILE__) + '/../init'
|
3
|
+
|
4
|
+
Spec::Runner.configure do |config|
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
class OnlyContain
|
9
|
+
def initialize(*expected)
|
10
|
+
@expected = [expected].flatten
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(target)
|
14
|
+
@target = target.dup
|
15
|
+
@expected.each do |e|
|
16
|
+
target.gsub!(e, '')
|
17
|
+
end
|
18
|
+
target.size == 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def failure_message
|
22
|
+
"expected #{@target} to only contain #{@expected.join(', ')}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def failure_message
|
26
|
+
"expected #{@target} to not only contain #{@expected.join(', ')}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def only_contain(*expected)
|
31
|
+
OnlyContain.new(expected)
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: forgery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Sutton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-07 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Forgery generates fake data from dictionaries, formats, and recipes. The plugin includes a generator providing directories to make your own forgeries.
|
17
|
+
email: nate@sevenwire.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.markdown
|
26
|
+
- VERSION.yml
|
27
|
+
- generators/forgery/forgery_generator.rb
|
28
|
+
- generators/forgery/USAGE
|
29
|
+
- lib/dictionaries/cities
|
30
|
+
- lib/dictionaries/colors
|
31
|
+
- lib/dictionaries/company_names
|
32
|
+
- lib/dictionaries/countries
|
33
|
+
- lib/dictionaries/female_first_names
|
34
|
+
- lib/dictionaries/frequencies
|
35
|
+
- lib/dictionaries/genders
|
36
|
+
- lib/dictionaries/languages
|
37
|
+
- lib/dictionaries/last_names
|
38
|
+
- lib/dictionaries/lorem_ipsum
|
39
|
+
- lib/dictionaries/male_first_names
|
40
|
+
- lib/dictionaries/name_suffixes
|
41
|
+
- lib/dictionaries/name_titles
|
42
|
+
- lib/dictionaries/province_abbrevs
|
43
|
+
- lib/dictionaries/provinces
|
44
|
+
- lib/dictionaries/races
|
45
|
+
- lib/dictionaries/shirt_sizes
|
46
|
+
- lib/dictionaries/state_abbrevs
|
47
|
+
- lib/dictionaries/states
|
48
|
+
- lib/dictionaries/street_suffixes
|
49
|
+
- lib/dictionaries/streets
|
50
|
+
- lib/dictionaries/top_level_domains
|
51
|
+
- lib/dictionaries.rb
|
52
|
+
- lib/extensions/array.rb
|
53
|
+
- lib/extensions/hash.rb
|
54
|
+
- lib/extensions/range.rb
|
55
|
+
- lib/extensions/string.rb
|
56
|
+
- lib/file_reader.rb
|
57
|
+
- lib/forgeries/address_forgery.rb
|
58
|
+
- lib/forgeries/basic_forgery.rb
|
59
|
+
- lib/forgeries/internet_forgery.rb
|
60
|
+
- lib/forgeries/lorem_ipsum_forgery.rb
|
61
|
+
- lib/forgeries/monetary_forgery.rb
|
62
|
+
- lib/forgeries/name_forgery.rb
|
63
|
+
- lib/forgeries/personal_forgery.rb
|
64
|
+
- lib/forgery.rb
|
65
|
+
- lib/formats/phone
|
66
|
+
- lib/formats/street_number
|
67
|
+
- lib/formats/zip
|
68
|
+
- lib/formats.rb
|
69
|
+
- spec/dictionaries_spec.rb
|
70
|
+
- spec/extensions/array_spec.rb
|
71
|
+
- spec/extensions/range_spec.rb
|
72
|
+
- spec/extensions/string_spec.rb
|
73
|
+
- spec/file_reader_spec.rb
|
74
|
+
- spec/forgeries/address_forgery_spec.rb
|
75
|
+
- spec/forgeries/basic_forgery_spec.rb
|
76
|
+
- spec/forgeries/internet_forgery_spec.rb
|
77
|
+
- spec/forgeries/lorem_ipsum_forgery_spec.rb
|
78
|
+
- spec/forgeries/monetary_forgery_spec.rb
|
79
|
+
- spec/forgeries/name_forgery_spec.rb
|
80
|
+
- spec/forgeries/personal_forgery_spec.rb
|
81
|
+
- spec/forgery_spec.rb
|
82
|
+
- spec/formats_spec.rb
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://github.com/sevenwire/forgery
|
86
|
+
licenses: []
|
87
|
+
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options:
|
90
|
+
- --inline-source
|
91
|
+
- --charset=UTF-8
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
99
|
+
version:
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
105
|
+
version:
|
106
|
+
requirements: []
|
107
|
+
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 1.3.5
|
110
|
+
signing_key:
|
111
|
+
specification_version: 2
|
112
|
+
summary: Forgery generates fake data from dictionaries, formats, and recipes. The plugin includes a generator providing directories to make your own forgeries.
|
113
|
+
test_files: []
|
114
|
+
|