forgery 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +22 -18
- data/Rakefile +0 -15
- data/lib/forgery.rb +11 -8
- data/lib/forgery/extensions/range.rb +1 -1
- data/lib/forgery/extensions/string.rb +1 -1
- data/lib/forgery/forgery.rb +3 -3
- data/lib/forgery/forgery/basic.rb +1 -1
- data/lib/forgery/forgery/internet.rb +1 -1
- data/lib/forgery/forgery/lorem_ipsum.rb +12 -12
- data/lib/forgery/version.rb +3 -0
- metadata +41 -56
- data/.gitignore +0 -3
- data/VERSION.yml +0 -5
- data/forgery.gemspec +0 -120
- data/init.rb +0 -1
- data/spec/dictionaries_spec.rb +0 -35
- data/spec/extensions/array_spec.rb +0 -25
- data/spec/extensions/range_spec.rb +0 -26
- data/spec/extensions/string_spec.rb +0 -29
- data/spec/file_reader_spec.rb +0 -11
- data/spec/forgery/address_spec.rb +0 -79
- data/spec/forgery/basic_spec.rb +0 -175
- data/spec/forgery/internet_spec.rb +0 -30
- data/spec/forgery/lorem_ipsum_spec.rb +0 -128
- data/spec/forgery/monetary_spec.rb +0 -4
- data/spec/forgery/name_spec.rb +0 -4
- data/spec/forgery/personal_spec.rb +0 -15
- data/spec/forgery_spec.rb +0 -69
- data/spec/formats_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -32
data/README.markdown
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Forgery
|
2
|
-
=======
|
1
|
+
# Forgery
|
3
2
|
|
4
3
|
The Problem:
|
5
4
|
Making meaningful development data for your application.
|
@@ -12,14 +11,23 @@ Forgery generates fake data from dictionaries, formats, and recipes. The
|
|
12
11
|
plugin includes a generator providing directories to make your own forgeries.
|
13
12
|
|
14
13
|
|
15
|
-
Install
|
16
|
-
=======
|
14
|
+
## Install
|
17
15
|
|
18
|
-
|
16
|
+
### Run
|
19
17
|
|
18
|
+
gem install forgery
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
### Rails 2
|
21
|
+
|
22
|
+
# Add this to your config/environment.rb
|
23
|
+
config.gem 'forgery'
|
24
|
+
|
25
|
+
### Rails 3
|
26
|
+
|
27
|
+
# Add this to your Gemfile
|
28
|
+
gem 'forgery'
|
29
|
+
|
30
|
+
## Rails 2 Generator
|
23
31
|
|
24
32
|
ruby script/generate forgery
|
25
33
|
|
@@ -42,8 +50,7 @@ See the forgeries in the plugin for examples of how to write your own.
|
|
42
50
|
See which dictionaries each forgery uses to override them with your own.
|
43
51
|
|
44
52
|
|
45
|
-
Examples
|
46
|
-
========
|
53
|
+
## Examples
|
47
54
|
|
48
55
|
Here I'll supply a few examples of how it works, in general. See each forgery
|
49
56
|
for individual examples.
|
@@ -66,20 +73,17 @@ for individual examples.
|
|
66
73
|
Forgery(:monetary).formatted_money # => "$3.48"
|
67
74
|
Forgery(:monetary).money :min => 100, :max => 1000 # => "923.36"
|
68
75
|
|
69
|
-
DOCUMENTATION
|
70
|
-
=============
|
76
|
+
## DOCUMENTATION
|
71
77
|
|
72
|
-
Documentation can be found at [http://
|
78
|
+
Documentation can be found at [http://sevenwire.github.com/forgery/](http://sevenwire.github.com/forgery/)
|
73
79
|
|
74
|
-
TODO
|
75
|
-
====
|
80
|
+
## TODO
|
76
81
|
|
77
82
|
* Add instanced forgeries for more relative information generation.
|
78
83
|
* Add markov chains.
|
79
84
|
* Add a way to use probability in forgeries.
|
80
85
|
|
81
|
-
Thanks
|
82
|
-
======
|
86
|
+
## Thanks
|
83
87
|
|
84
88
|
Thanks to the authors and contributors:
|
85
89
|
|
@@ -87,9 +91,9 @@ Thanks to the authors and contributors:
|
|
87
91
|
* Brandon Arbini (brandonarbini)
|
88
92
|
* Josh Nichols (technicalpickles)
|
89
93
|
* Jeremy Stephens (viking aka crookshanks)
|
94
|
+
* Darcy Laycock (Sutto)
|
90
95
|
|
91
|
-
Notes
|
92
|
-
=====
|
96
|
+
## Notes
|
93
97
|
|
94
98
|
This is a work in progress. If you find bugs or have forgeries to contribute,
|
95
99
|
we'll gladly take them and give credit.
|
data/Rakefile
CHANGED
@@ -33,18 +33,3 @@ Rake::RDocTask.new do |t|
|
|
33
33
|
t.options << '--all'
|
34
34
|
t.options << '--line-numbers'
|
35
35
|
end
|
36
|
-
|
37
|
-
begin
|
38
|
-
require 'jeweler'
|
39
|
-
Jeweler::Tasks.new do |s|
|
40
|
-
s.name = "forgery"
|
41
|
-
s.summary = "Easy and customizable generation of forged data."
|
42
|
-
s.email = "nate@sevenwire.com"
|
43
|
-
s.homepage = "http://github.com/sevenwire/forgery"
|
44
|
-
s.description = "Easy and customizable generation of forged data. Can be used as a gem or a rails plugin. Includes rails generators for creating your own forgeries."
|
45
|
-
s.authors = ["Nathan Sutton"]
|
46
|
-
end
|
47
|
-
Jeweler::GemcutterTasks.new
|
48
|
-
rescue LoadError
|
49
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
50
|
-
end
|
data/lib/forgery.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
# Require forgeries at the bottom of the file so Forgery works as a gem both
|
2
2
|
# within rails and outside of it.
|
3
3
|
|
4
|
-
current_path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
current_path = File.expand_path(File.dirname(__FILE__)) + '/'
|
5
5
|
|
6
6
|
# Loading forgery helpers.
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
7
|
+
require 'forgery/file_reader'
|
8
|
+
require 'forgery/dictionaries'
|
9
|
+
require 'forgery/formats'
|
10
10
|
|
11
11
|
# Loading class extensions
|
12
|
-
Dir[current_path + '
|
12
|
+
Dir[current_path + 'forgery/extensions/**/*.rb'].uniq.each do |file|
|
13
13
|
require file
|
14
14
|
end
|
15
15
|
|
16
16
|
# Load the forgery base class
|
17
|
-
require
|
17
|
+
require 'forgery/forgery'
|
18
|
+
|
19
|
+
# Load the forgery version
|
20
|
+
require 'forgery/version'
|
18
21
|
|
19
22
|
# Load the forgery api method
|
20
|
-
require
|
23
|
+
require 'forgery/forgery_api'
|
21
24
|
|
22
25
|
# Loading the other forgeries AFTER the initial forgery class is defined.
|
23
|
-
Dir[current_path + '
|
26
|
+
Dir[current_path + 'forgery/forgery/**/*.rb'].uniq.each do |file|
|
24
27
|
require file
|
25
28
|
end
|
26
29
|
|
data/lib/forgery/forgery.rb
CHANGED
@@ -3,26 +3,26 @@ class Forgery::LoremIpsum < Forgery
|
|
3
3
|
def self.text(what=:sentence, quantity=2, options={})
|
4
4
|
case what
|
5
5
|
when :character
|
6
|
-
|
6
|
+
character(options)
|
7
7
|
when :characters
|
8
|
-
|
8
|
+
characters(quantity, options)
|
9
9
|
when :word
|
10
|
-
|
10
|
+
word(options)
|
11
11
|
when :words
|
12
|
-
|
12
|
+
words(quantity, options)
|
13
13
|
when :sentence
|
14
|
-
|
14
|
+
sentence(options)
|
15
15
|
when :sentences
|
16
|
-
|
16
|
+
sentences(quantity, options)
|
17
17
|
when :paragraph
|
18
|
-
|
18
|
+
paragraph(options)
|
19
19
|
when :paragraphs
|
20
|
-
|
20
|
+
paragraphs(quantity, options)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.character(options={})
|
25
|
-
|
25
|
+
characters(1, options)
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.characters(quantity=10, options={})
|
@@ -32,7 +32,7 @@ class Forgery::LoremIpsum < Forgery
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.word(options={})
|
35
|
-
|
35
|
+
words(1, options)
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.words(quantity=10, options={})
|
@@ -42,7 +42,7 @@ class Forgery::LoremIpsum < Forgery
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.sentence(options={})
|
45
|
-
|
45
|
+
sentences(1, options)
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.sentences(quantity=2, options={})
|
@@ -52,7 +52,7 @@ class Forgery::LoremIpsum < Forgery
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.paragraph(options={})
|
55
|
-
|
55
|
+
paragraphs(1, options)
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.paragraphs(quantity=2, options={})
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forgery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Nathan Sutton
|
@@ -9,31 +14,32 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-09 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
16
32
|
description: Easy and customizable generation of forged data. Can be used as a gem or a rails plugin. Includes rails generators for creating your own forgeries.
|
17
33
|
email: nate@sevenwire.com
|
18
34
|
executables: []
|
19
35
|
|
20
36
|
extensions: []
|
21
37
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
24
|
-
- README.markdown
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
25
40
|
files:
|
26
|
-
- .gitignore
|
27
|
-
- LICENSE
|
28
|
-
- README.markdown
|
29
|
-
- Rakefile
|
30
|
-
- VERSION.yml
|
31
|
-
- forgery.gemspec
|
32
|
-
- generators/forgery/USAGE
|
33
41
|
- generators/forgery/forgery_generator.rb
|
34
|
-
-
|
35
|
-
- lib/forgery.rb
|
36
|
-
- lib/forgery/dictionaries.rb
|
42
|
+
- generators/forgery/USAGE
|
37
43
|
- lib/forgery/dictionaries/cities
|
38
44
|
- lib/forgery/dictionaries/colors
|
39
45
|
- lib/forgery/dictionaries/company_names
|
@@ -56,12 +62,12 @@ files:
|
|
56
62
|
- lib/forgery/dictionaries/street_suffixes
|
57
63
|
- lib/forgery/dictionaries/streets
|
58
64
|
- lib/forgery/dictionaries/top_level_domains
|
65
|
+
- lib/forgery/dictionaries.rb
|
59
66
|
- lib/forgery/extensions/array.rb
|
60
67
|
- lib/forgery/extensions/hash.rb
|
61
68
|
- lib/forgery/extensions/range.rb
|
62
69
|
- lib/forgery/extensions/string.rb
|
63
70
|
- lib/forgery/file_reader.rb
|
64
|
-
- lib/forgery/forgery.rb
|
65
71
|
- lib/forgery/forgery/address.rb
|
66
72
|
- lib/forgery/forgery/basic.rb
|
67
73
|
- lib/forgery/forgery/internet.rb
|
@@ -69,67 +75,46 @@ files:
|
|
69
75
|
- lib/forgery/forgery/monetary.rb
|
70
76
|
- lib/forgery/forgery/name.rb
|
71
77
|
- lib/forgery/forgery/personal.rb
|
78
|
+
- lib/forgery/forgery.rb
|
72
79
|
- lib/forgery/forgery_api.rb
|
73
|
-
- lib/forgery/formats.rb
|
74
80
|
- lib/forgery/formats/phone
|
75
81
|
- lib/forgery/formats/street_number
|
76
82
|
- lib/forgery/formats/zip
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
- spec/forgery/basic_spec.rb
|
84
|
-
- spec/forgery/internet_spec.rb
|
85
|
-
- spec/forgery/lorem_ipsum_spec.rb
|
86
|
-
- spec/forgery/monetary_spec.rb
|
87
|
-
- spec/forgery/name_spec.rb
|
88
|
-
- spec/forgery/personal_spec.rb
|
89
|
-
- spec/forgery_spec.rb
|
90
|
-
- spec/formats_spec.rb
|
91
|
-
- spec/spec_helper.rb
|
83
|
+
- lib/forgery/formats.rb
|
84
|
+
- lib/forgery/version.rb
|
85
|
+
- lib/forgery.rb
|
86
|
+
- LICENSE
|
87
|
+
- README.markdown
|
88
|
+
- Rakefile
|
92
89
|
has_rdoc: true
|
93
90
|
homepage: http://github.com/sevenwire/forgery
|
94
91
|
licenses: []
|
95
92
|
|
96
93
|
post_install_message:
|
97
|
-
rdoc_options:
|
98
|
-
|
94
|
+
rdoc_options: []
|
95
|
+
|
99
96
|
require_paths:
|
100
97
|
- lib
|
101
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
99
|
requirements:
|
103
100
|
- - ">="
|
104
101
|
- !ruby/object:Gem::Version
|
102
|
+
segments:
|
103
|
+
- 0
|
105
104
|
version: "0"
|
106
|
-
version:
|
107
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
106
|
requirements:
|
109
107
|
- - ">="
|
110
108
|
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
111
111
|
version: "0"
|
112
|
-
version:
|
113
112
|
requirements: []
|
114
113
|
|
115
|
-
rubyforge_project:
|
116
|
-
rubygems_version: 1.3.
|
114
|
+
rubyforge_project: forgery
|
115
|
+
rubygems_version: 1.3.6
|
117
116
|
signing_key:
|
118
117
|
specification_version: 3
|
119
118
|
summary: Easy and customizable generation of forged data.
|
120
|
-
test_files:
|
121
|
-
|
122
|
-
- spec/extensions/array_spec.rb
|
123
|
-
- spec/extensions/range_spec.rb
|
124
|
-
- spec/extensions/string_spec.rb
|
125
|
-
- spec/file_reader_spec.rb
|
126
|
-
- spec/forgery/address_spec.rb
|
127
|
-
- spec/forgery/basic_spec.rb
|
128
|
-
- spec/forgery/internet_spec.rb
|
129
|
-
- spec/forgery/lorem_ipsum_spec.rb
|
130
|
-
- spec/forgery/monetary_spec.rb
|
131
|
-
- spec/forgery/name_spec.rb
|
132
|
-
- spec/forgery/personal_spec.rb
|
133
|
-
- spec/forgery_spec.rb
|
134
|
-
- spec/formats_spec.rb
|
135
|
-
- spec/spec_helper.rb
|
119
|
+
test_files: []
|
120
|
+
|
data/.gitignore
DELETED
data/VERSION.yml
DELETED
data/forgery.gemspec
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{forgery}
|
8
|
-
s.version = "0.3.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Nathan Sutton"]
|
12
|
-
s.date = %q{2009-11-13}
|
13
|
-
s.description = %q{Easy and customizable generation of forged data. Can be used as a gem or a rails plugin. Includes rails generators for creating your own forgeries.}
|
14
|
-
s.email = %q{nate@sevenwire.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.markdown"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README.markdown",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION.yml",
|
25
|
-
"forgery.gemspec",
|
26
|
-
"generators/forgery/USAGE",
|
27
|
-
"generators/forgery/forgery_generator.rb",
|
28
|
-
"init.rb",
|
29
|
-
"lib/forgery.rb",
|
30
|
-
"lib/forgery/dictionaries.rb",
|
31
|
-
"lib/forgery/dictionaries/cities",
|
32
|
-
"lib/forgery/dictionaries/colors",
|
33
|
-
"lib/forgery/dictionaries/company_names",
|
34
|
-
"lib/forgery/dictionaries/countries",
|
35
|
-
"lib/forgery/dictionaries/female_first_names",
|
36
|
-
"lib/forgery/dictionaries/frequencies",
|
37
|
-
"lib/forgery/dictionaries/genders",
|
38
|
-
"lib/forgery/dictionaries/languages",
|
39
|
-
"lib/forgery/dictionaries/last_names",
|
40
|
-
"lib/forgery/dictionaries/lorem_ipsum",
|
41
|
-
"lib/forgery/dictionaries/male_first_names",
|
42
|
-
"lib/forgery/dictionaries/name_suffixes",
|
43
|
-
"lib/forgery/dictionaries/name_titles",
|
44
|
-
"lib/forgery/dictionaries/province_abbrevs",
|
45
|
-
"lib/forgery/dictionaries/provinces",
|
46
|
-
"lib/forgery/dictionaries/races",
|
47
|
-
"lib/forgery/dictionaries/shirt_sizes",
|
48
|
-
"lib/forgery/dictionaries/state_abbrevs",
|
49
|
-
"lib/forgery/dictionaries/states",
|
50
|
-
"lib/forgery/dictionaries/street_suffixes",
|
51
|
-
"lib/forgery/dictionaries/streets",
|
52
|
-
"lib/forgery/dictionaries/top_level_domains",
|
53
|
-
"lib/forgery/extensions/array.rb",
|
54
|
-
"lib/forgery/extensions/hash.rb",
|
55
|
-
"lib/forgery/extensions/range.rb",
|
56
|
-
"lib/forgery/extensions/string.rb",
|
57
|
-
"lib/forgery/file_reader.rb",
|
58
|
-
"lib/forgery/forgery.rb",
|
59
|
-
"lib/forgery/forgery/address.rb",
|
60
|
-
"lib/forgery/forgery/basic.rb",
|
61
|
-
"lib/forgery/forgery/internet.rb",
|
62
|
-
"lib/forgery/forgery/lorem_ipsum.rb",
|
63
|
-
"lib/forgery/forgery/monetary.rb",
|
64
|
-
"lib/forgery/forgery/name.rb",
|
65
|
-
"lib/forgery/forgery/personal.rb",
|
66
|
-
"lib/forgery/forgery_api.rb",
|
67
|
-
"lib/forgery/formats.rb",
|
68
|
-
"lib/forgery/formats/phone",
|
69
|
-
"lib/forgery/formats/street_number",
|
70
|
-
"lib/forgery/formats/zip",
|
71
|
-
"spec/dictionaries_spec.rb",
|
72
|
-
"spec/extensions/array_spec.rb",
|
73
|
-
"spec/extensions/range_spec.rb",
|
74
|
-
"spec/extensions/string_spec.rb",
|
75
|
-
"spec/file_reader_spec.rb",
|
76
|
-
"spec/forgery/address_spec.rb",
|
77
|
-
"spec/forgery/basic_spec.rb",
|
78
|
-
"spec/forgery/internet_spec.rb",
|
79
|
-
"spec/forgery/lorem_ipsum_spec.rb",
|
80
|
-
"spec/forgery/monetary_spec.rb",
|
81
|
-
"spec/forgery/name_spec.rb",
|
82
|
-
"spec/forgery/personal_spec.rb",
|
83
|
-
"spec/forgery_spec.rb",
|
84
|
-
"spec/formats_spec.rb",
|
85
|
-
"spec/spec_helper.rb"
|
86
|
-
]
|
87
|
-
s.homepage = %q{http://github.com/sevenwire/forgery}
|
88
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
89
|
-
s.require_paths = ["lib"]
|
90
|
-
s.rubygems_version = %q{1.3.5}
|
91
|
-
s.summary = %q{Easy and customizable generation of forged data.}
|
92
|
-
s.test_files = [
|
93
|
-
"spec/dictionaries_spec.rb",
|
94
|
-
"spec/extensions/array_spec.rb",
|
95
|
-
"spec/extensions/range_spec.rb",
|
96
|
-
"spec/extensions/string_spec.rb",
|
97
|
-
"spec/file_reader_spec.rb",
|
98
|
-
"spec/forgery/address_spec.rb",
|
99
|
-
"spec/forgery/basic_spec.rb",
|
100
|
-
"spec/forgery/internet_spec.rb",
|
101
|
-
"spec/forgery/lorem_ipsum_spec.rb",
|
102
|
-
"spec/forgery/monetary_spec.rb",
|
103
|
-
"spec/forgery/name_spec.rb",
|
104
|
-
"spec/forgery/personal_spec.rb",
|
105
|
-
"spec/forgery_spec.rb",
|
106
|
-
"spec/formats_spec.rb",
|
107
|
-
"spec/spec_helper.rb"
|
108
|
-
]
|
109
|
-
|
110
|
-
if s.respond_to? :specification_version then
|
111
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
112
|
-
s.specification_version = 3
|
113
|
-
|
114
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
115
|
-
else
|
116
|
-
end
|
117
|
-
else
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/lib/forgery'
|
data/spec/dictionaries_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/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
|
-
dictionaries.should 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
|
-
dictionaries.should_not be_loaded(:colors)
|
18
|
-
|
19
|
-
dictionaries[:colors]
|
20
|
-
|
21
|
-
dictionaries.should 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
|
-
dictionaries.should be_loaded(:colors)
|
30
|
-
|
31
|
-
dictionaries.reset!
|
32
|
-
|
33
|
-
dictionaries.should_not be_loaded(:colors)
|
34
|
-
end
|
35
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Array do
|
4
|
-
before do
|
5
|
-
@array = [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 { @array.should include(@array.random) }
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return nil if the array is empty" do
|
13
|
-
[].random.should 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
|
-
@array.should include(i)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should return a random subset of the array that is 3 long" do
|
23
|
-
@array.random_subset(3).size.should == 3
|
24
|
-
end
|
25
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require 'timeout'
|
3
|
-
|
4
|
-
describe Range do
|
5
|
-
it "should get a random number out of the range" do
|
6
|
-
range = (0..9)
|
7
|
-
10.times { range.should include(range.random) }
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should not take a long time when the range is huge" do
|
11
|
-
Timeout.timeout(1){(1234567890..12345678901234567890).random}.should_not raise_error(Timeout::Error)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return nil for a random number from a reverse range" do
|
15
|
-
10.times { (9..0).random.should be_nil }
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should get a random string our of the range" do
|
19
|
-
range = ("a".."z")
|
20
|
-
10.times { range.should include(range.random) }
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return nil if the maximum is less than the minimum" do
|
24
|
-
("z".."a").random.should be_nil
|
25
|
-
end
|
26
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
it "should change a single # to a number 0-9" do
|
5
|
-
(0..9).should include(Integer("#".to_numbers))
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should change two #'s to two numbers 0-9" do
|
9
|
-
"##".to_numbers.split("").each do |s|
|
10
|
-
(0..9).should include(Integer(s))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should only replace #'s in the string with numbers 0-9" do
|
15
|
-
s = '###-###-####'
|
16
|
-
n = s.to_numbers
|
17
|
-
0.upto(s.size - 1) do |i|
|
18
|
-
if s[i, 1] == "#"
|
19
|
-
('0'..'9').should include(n[i, 1])
|
20
|
-
else
|
21
|
-
('0'..'9').should_not include(n[i, 1])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should allow the replacing of a different character" do
|
27
|
-
(0..9).should include(Integer("-".to_numbers("-")))
|
28
|
-
end
|
29
|
-
end
|
data/spec/file_reader_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::FileReader do
|
4
|
-
it "should return an array when calling read_dictionary" do
|
5
|
-
Forgery::FileReader.read_dictionary(:colors).should be_is_a(Array)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return an array when calling read_format" do
|
9
|
-
Forgery::FileReader.read_format(:phone).should be_is_a(Array)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::Address do
|
4
|
-
it "should return a random street" do
|
5
|
-
Forgery.dictionaries[:streets].should 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
|
-
Forgery.formats[:street_number].should include(original_format)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return a random street suffix" do
|
14
|
-
Forgery.dictionaries[:street_suffixes].should 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
|
-
Forgery.dictionaries[:street_suffixes].should 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
|
-
Forgery.formats[:street_number].should 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
|
-
Forgery.dictionaries[:streets].should include(street)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should return a random city" do
|
41
|
-
city = Forgery::Address.city
|
42
|
-
Forgery.dictionaries[:cities].should include(city)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should return a random state" do
|
46
|
-
state = Forgery::Address.state
|
47
|
-
Forgery.dictionaries[:states].should include(state)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should return a random state abbreviation" do
|
51
|
-
state_abbrev = Forgery::Address.state_abbrev
|
52
|
-
Forgery.dictionaries[:state_abbrevs].should include(state_abbrev)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should return a random Canadian province or territory" do
|
56
|
-
province = Forgery::Address.province
|
57
|
-
Forgery.dictionaries[:provinces].should 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
|
-
Forgery.dictionaries[:province_abbrevs].should include(province_abbrev)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should return a random country" do
|
66
|
-
country = Forgery::Address.country
|
67
|
-
Forgery.dictionaries[:countries].should include(country)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should return a random zip code" do
|
71
|
-
zip_format = Forgery::Address.zip.gsub(/\d/, '#')
|
72
|
-
Forgery.formats[:zip].should include(zip_format)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should return a random phone number" do
|
76
|
-
phone_format = Forgery::Address.phone.gsub(/\d/, '#')
|
77
|
-
Forgery.formats[:phone].should include(phone_format)
|
78
|
-
end
|
79
|
-
end
|
data/spec/forgery/basic_spec.rb
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::Basic do
|
4
|
-
describe ".password" do
|
5
|
-
it "should only uppercase characters" do
|
6
|
-
Forgery::Basic.password(:allow_lower => false,
|
7
|
-
:allow_upper => true,
|
8
|
-
:allow_numeric => false,
|
9
|
-
:allow_special => false).should only_contain(Forgery::Basic::UPPER_ALPHA)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should only contain lowercase characters" do
|
13
|
-
Forgery::Basic.password(:allow_lower => true,
|
14
|
-
:allow_upper => false,
|
15
|
-
:allow_numeric => false,
|
16
|
-
:allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should only contain numeric characters" do
|
20
|
-
Forgery::Basic.password(:allow_lower => false,
|
21
|
-
:allow_upper => false,
|
22
|
-
:allow_numeric => true,
|
23
|
-
:allow_special => false).should only_contain(Forgery::Basic::NUMERIC)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should only contain special characters" do
|
27
|
-
Forgery::Basic.password(:allow_lower => false,
|
28
|
-
:allow_upper => false,
|
29
|
-
:allow_numeric => false,
|
30
|
-
:allow_special => true).should only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should only contain lower and uppercase characters" do
|
34
|
-
Forgery::Basic.password(:allow_lower => true,
|
35
|
-
:allow_upper => true,
|
36
|
-
:allow_numeric => false,
|
37
|
-
:allow_special => false).should 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
|
-
Forgery::Basic.password(:allow_lower => false,
|
43
|
-
:allow_upper => false,
|
44
|
-
:allow_numeric => true,
|
45
|
-
:allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
|
46
|
-
Forgery::Basic::SPECIAL_CHARACTERS)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should contain any of the defined characters" do
|
50
|
-
Forgery::Basic.password(:allow_lower => true,
|
51
|
-
:allow_upper => true,
|
52
|
-
:allow_numeric => true,
|
53
|
-
:allow_special => true).should 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
|
-
Forgery::Basic.encrypt("something").should only_contain(Forgery::Basic::HEX_DIGITS)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should encrypt different words to different output" do
|
66
|
-
Forgery::Basic.encrypt("foo").should_not == Forgery::Basic.encrypt("bar")
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should allow a salt that changes the output" do
|
70
|
-
Forgery::Basic.encrypt("foo", "baz").should_not == Forgery::Basic.encrypt("foo", "bar")
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should have the same output when encrypting twice" do
|
74
|
-
Forgery::Basic.encrypt("foo", "bar").should == Forgery::Basic.encrypt("foo", "bar")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe ".boolean" do
|
79
|
-
it "should return true or false" do
|
80
|
-
[true, false].should include(Forgery::Basic.boolean)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe ".color" do
|
85
|
-
it "should return a random color" do
|
86
|
-
Forgery.dictionaries[:colors].should 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
|
-
Forgery::Basic.hex_color.should 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
|
-
Forgery::Basic.short_hex_color.should 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
|
-
Forgery::Basic.number(:at_least => 2).should >= 2
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should return a number <= the at_most option" do
|
108
|
-
Forgery::Basic.number(:at_most => 12).should <= 12
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe ".text" do
|
113
|
-
it "should return text whose length is >= the at_least option" do
|
114
|
-
Forgery::Basic.text(:at_least => 5).size.should >= 5
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should return text whose length is <= the at_most option" do
|
118
|
-
Forgery::Basic.text(:at_least => 15).size.should <= 15
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should only uppercase characters" do
|
122
|
-
Forgery::Basic.text(:allow_lower => false,
|
123
|
-
:allow_upper => true,
|
124
|
-
:allow_numeric => false,
|
125
|
-
:allow_special => false).should only_contain(Forgery::Basic::UPPER_ALPHA)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should only contain lowercase characters" do
|
129
|
-
Forgery::Basic.text(:allow_lower => true,
|
130
|
-
:allow_upper => false,
|
131
|
-
:allow_numeric => false,
|
132
|
-
:allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA)
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should only contain numeric characters" do
|
136
|
-
Forgery::Basic.text(:allow_lower => false,
|
137
|
-
:allow_upper => false,
|
138
|
-
:allow_numeric => true,
|
139
|
-
:allow_special => false).should only_contain(Forgery::Basic::NUMERIC)
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should only contain special characters" do
|
143
|
-
Forgery::Basic.text(:allow_lower => false,
|
144
|
-
:allow_upper => false,
|
145
|
-
:allow_numeric => false,
|
146
|
-
:allow_special => true).should only_contain(Forgery::Basic::SPECIAL_CHARACTERS)
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should only contain lower and uppercase characters" do
|
150
|
-
Forgery::Basic.text(:allow_lower => true,
|
151
|
-
:allow_upper => true,
|
152
|
-
:allow_numeric => false,
|
153
|
-
:allow_special => false).should only_contain(Forgery::Basic::LOWER_ALPHA,
|
154
|
-
Forgery::Basic::UPPER_ALPHA)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should only contain numeric and special characters" do
|
158
|
-
Forgery::Basic.text(:allow_lower => false,
|
159
|
-
:allow_upper => false,
|
160
|
-
:allow_numeric => true,
|
161
|
-
:allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
|
162
|
-
Forgery::Basic::SPECIAL_CHARACTERS)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should contain any of the defined characters" do
|
166
|
-
Forgery::Basic.text(:allow_lower => true,
|
167
|
-
:allow_upper => true,
|
168
|
-
:allow_numeric => true,
|
169
|
-
:allow_special => true).should only_contain(Forgery::Basic::NUMERIC,
|
170
|
-
Forgery::Basic::SPECIAL_CHARACTERS,
|
171
|
-
Forgery::Basic::LOWER_ALPHA,
|
172
|
-
Forgery::Basic::UPPER_ALPHA)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::Internet do
|
4
|
-
describe ".user_name" do
|
5
|
-
it "should return a username that is lowercase" do
|
6
|
-
Forgery::Internet.user_name.should only_contain(Forgery::Basic::LOWER_ALPHA)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should return a top level domain" do
|
11
|
-
Forgery.dictionaries[:top_level_domains].should include(Forgery::Internet.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 = Forgery::Internet.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(Forgery::Internet.domain_name.split('.').last)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe ".email_address" do
|
26
|
-
it "should match the email format" do
|
27
|
-
Forgery::Internet.email_address.should match(/.+@.+\.(#{Forgery.dictionaries[:top_level_domains].join("|")})/)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::LoremIpsum do
|
4
|
-
describe ".paragraphs" do
|
5
|
-
it "should return text" do
|
6
|
-
Forgery::LoremIpsum.paragraphs.should be_a_kind_of(String)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should return text with 1 or more character" do
|
10
|
-
Forgery::LoremIpsum.paragraphs.size.should >= 1
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should default to returning 2 paragraphs separated by \\n\\n" do
|
14
|
-
Forgery::LoremIpsum.paragraphs.split("\n\n").size.should == 2
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should default to returning 3 sentences per paragraph" do
|
18
|
-
paragraphs = Forgery::LoremIpsum.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 = Forgery::LoremIpsum.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 = Forgery::LoremIpsum.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
|
-
Forgery::LoremIpsum.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
|
-
Forgery::LoremIpsum.paragraph.should be_a_kind_of(String)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return text with 1 or more character" do
|
49
|
-
Forgery::LoremIpsum.paragraph.size.should >= 1
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return a single paragraph" do
|
53
|
-
Forgery::LoremIpsum.paragraph.scan("\n\n").size.should == 0
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ".sentences" do
|
58
|
-
it "should return text" do
|
59
|
-
Forgery::LoremIpsum.sentences.should be_a_kind_of(String)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return text with 1 or more character" do
|
63
|
-
Forgery::LoremIpsum.sentences.size.should >= 1
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should return two sentences by default" do
|
67
|
-
Forgery::LoremIpsum.sentences.scan(".").size.should == 2
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should return as many sentences as you specify" do
|
71
|
-
Forgery::LoremIpsum.sentences(4).scan(".").size.should == 4
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe ".sentence" do
|
76
|
-
it "should return text" do
|
77
|
-
Forgery::LoremIpsum.sentence.should be_a_kind_of(String)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should return text with 1 or more character" do
|
81
|
-
Forgery::LoremIpsum.sentence.size.should >= 1
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should return a single sentence" do
|
85
|
-
Forgery::LoremIpsum.sentence.scan(".").size.should == 1
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe ".words" do
|
90
|
-
it "should return text" do
|
91
|
-
Forgery::LoremIpsum.words.should be_a_kind_of(String)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should return text with 1 or more character" do
|
95
|
-
Forgery::LoremIpsum.words.size.should >= 1
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe ".word" do
|
100
|
-
it "should return text" do
|
101
|
-
Forgery::LoremIpsum.word.should be_a_kind_of(String)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should return text with 1 or more character" do
|
105
|
-
Forgery::LoremIpsum.word.size.should >= 1
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe ".characters" do
|
110
|
-
it "should return text" do
|
111
|
-
Forgery::LoremIpsum.characters.should be_a_kind_of(String)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should return text with 1 or more character" do
|
115
|
-
Forgery::LoremIpsum.characters.size.should >= 1
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe ".character" do
|
120
|
-
it "should return text" do
|
121
|
-
Forgery::LoremIpsum.character.should be_a_kind_of(String)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should return text with 1 or more character" do
|
125
|
-
Forgery::LoremIpsum.character.size.should >= 1
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
data/spec/forgery/name_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::Personal do
|
4
|
-
describe '.gender' do
|
5
|
-
it 'should return male or female' do
|
6
|
-
Forgery.dictionaries[:genders].should include(Forgery::Personal.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(Forgery::Personal.shirt_size)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/spec/forgery_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
describe Forgery do
|
5
|
-
it "should load a dictionary when it is requested" do
|
6
|
-
Forgery.dictionaries.reset!
|
7
|
-
|
8
|
-
Forgery.dictionaries.should_not be_loaded(:colors)
|
9
|
-
|
10
|
-
Forgery.dictionaries[:colors]
|
11
|
-
|
12
|
-
Forgery.dictionaries.should be_loaded(:colors)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should load formats when it is requested" do
|
16
|
-
Forgery.formats.reset!
|
17
|
-
|
18
|
-
Forgery.formats.should_not be_loaded(:phone)
|
19
|
-
|
20
|
-
Forgery.formats[:phone]
|
21
|
-
|
22
|
-
Forgery.formats.should be_loaded(:phone)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should accept a symbol and return the appropriate forgery class" do
|
26
|
-
Forgery(:address).should == Forgery::Address
|
27
|
-
Forgery(:basic).should == Forgery::Basic
|
28
|
-
Forgery(:internet).should == Forgery::Internet
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should accept two symbols, finding the right class and calling the appropriate method" do
|
32
|
-
Forgery::Address.should_receive(:street_name)
|
33
|
-
Forgery(:address, :street_name)
|
34
|
-
|
35
|
-
Forgery::Name.should_receive(:full_name)
|
36
|
-
Forgery(:name, :full_name)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should accept two symbols and arguments, passing them along to the appropriate method" do
|
40
|
-
Forgery::LoremIpsum.should_receive(:text).with(:sentences, 2)
|
41
|
-
Forgery(:lorem_ipsum, :text, :sentences, 2)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should return the rails root path if RAILS_ROOT is defined" do
|
45
|
-
RAILS_ROOT = '/path/from/rails/root/const'
|
46
|
-
Forgery.rails_root.should == '/path/from/rails/root/const'
|
47
|
-
Object.instance_eval { remove_const(:RAILS_ROOT) }
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should return the rails root path as a string if Rails.root is defined" do
|
51
|
-
Rails = Object.new
|
52
|
-
Rails.stub!(:root).and_return(Pathname.new('/path/from/rails/dot/root'))
|
53
|
-
Forgery.rails_root.should == '/path/from/rails/dot/root'
|
54
|
-
Object.instance_eval { remove_const(:Rails) }
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should return nil when RAILS_ROOT and Rails.root are not defined" do
|
58
|
-
Forgery.rails_root.should be_nil
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should not be a rails environment when there is not a rails_root" do
|
62
|
-
Forgery.rails?.should be_false
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should be a rails environment when there is a rails_root" do
|
66
|
-
Forgery.stub!(:rails?).and_return(true)
|
67
|
-
Forgery.rails?.should be_true
|
68
|
-
end
|
69
|
-
end
|
data/spec/formats_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Forgery::Formats do
|
4
|
-
it "should check if the dictionary is loaded" do
|
5
|
-
formats = Forgery::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 = Forgery::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 = Forgery::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
DELETED
@@ -1,32 +0,0 @@
|
|
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
|