fabrication 2.9.8 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +13 -4
- data/lib/fabrication/cucumber/step_fabricator.rb +2 -2
- data/lib/fabrication/errors/unfabricatable_error.rb +2 -2
- data/lib/fabrication/schematic/attribute.rb +14 -3
- data/lib/fabrication/schematic/definition.rb +1 -1
- data/lib/fabrication/support.rb +8 -3
- data/lib/fabrication/version.rb +1 -1
- metadata +5 -201
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e953b16555d4952d603134e3a609f2e18351a01
|
4
|
+
data.tar.gz: 88df71f9858b36e5911193238d5711ece3058fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c128fe8be585de63e07538b52743672449980bf8c9b09a0c7ec7e105a04a9eb9795ab186315182eaed2b89e1250efcaa1df6f369513ceb264b41968292d5e812
|
7
|
+
data.tar.gz: c89cf69b9395208ab787f58d9141db782ea37ab1c9ffda90e30a09729250edb045d71cd00c0f985fbd9adfc4d6ef2ce1028ab116d418f4fd777d19eeccccfb04
|
data/Rakefile
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
1
6
|
require "rspec/core/rake_task"
|
2
7
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
3
8
|
spec.pattern = "spec/**/*_spec.rb"
|
4
9
|
end
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
desc 'All cucumber features with kitchen sink appraisal'
|
12
|
+
task :cucumber do
|
13
|
+
system('appraisal kitchen-sink cucumber -f progress')
|
9
14
|
end
|
10
15
|
|
11
|
-
|
16
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
17
|
+
task default: %i(cucumber appraisal)
|
18
|
+
else
|
19
|
+
task default: :spec
|
20
|
+
end
|
@@ -5,7 +5,7 @@ module Fabrication
|
|
5
5
|
|
6
6
|
def initialize(model_name, opts ={})
|
7
7
|
@model = dehumanize(model_name)
|
8
|
-
@fabricator = @model.
|
8
|
+
@fabricator = Fabrication::Support.singularize(@model).to_sym
|
9
9
|
@parent_name = opts.delete(:parent)
|
10
10
|
end
|
11
11
|
|
@@ -50,7 +50,7 @@ module Fabrication
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def singular?
|
53
|
-
@model == @model
|
53
|
+
@model == Fabrication::Support.singularize(@model)
|
54
54
|
end
|
55
55
|
|
56
56
|
def dehumanize(string)
|
@@ -22,8 +22,8 @@ class Fabrication::Schematic::Attribute
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def processed_value(processed_attributes)
|
25
|
-
if
|
26
|
-
(1..
|
25
|
+
if process_count
|
26
|
+
(1..process_count).map { |i| execute(processed_attributes, i, &value) }
|
27
27
|
elsif value_proc?
|
28
28
|
execute(processed_attributes, &value)
|
29
29
|
else
|
@@ -37,7 +37,18 @@ class Fabrication::Schematic::Attribute
|
|
37
37
|
Fabrication::Schematic::Runner.new(klass).instance_exec(*args, &block)
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def process_count
|
41
|
+
count || rand
|
42
|
+
end
|
43
|
+
|
44
|
+
def count
|
45
|
+
params[:count]
|
46
|
+
end
|
47
|
+
|
48
|
+
def rand
|
49
|
+
Kernel.rand((1..params[:rand])) if params[:rand]
|
50
|
+
end
|
51
|
+
|
41
52
|
def value_proc?; Proc === value end
|
42
53
|
|
43
54
|
end
|
@@ -108,7 +108,7 @@ class Fabrication::Schematic::Definition
|
|
108
108
|
|
109
109
|
def generate_value(name, params)
|
110
110
|
if params[:count]
|
111
|
-
name =
|
111
|
+
name = Fabrication::Support.singularize(name.to_s)
|
112
112
|
proc { Fabricate.build(params[:fabricator] || name) }
|
113
113
|
else
|
114
114
|
proc { Fabricate(params[:fabricator] || name) }
|
data/lib/fabrication/support.rb
CHANGED
@@ -11,9 +11,8 @@ class Fabrication::Support
|
|
11
11
|
klass = class_name.split('::').inject(Object) do |object, string|
|
12
12
|
object.const_get(string)
|
13
13
|
end
|
14
|
-
rescue NameError
|
15
|
-
|
16
|
-
raise Fabrication::UnfabricatableError.new(class_or_to_s) unless klass
|
14
|
+
rescue NameError => original_error
|
15
|
+
raise Fabrication::UnfabricatableError.new(class_or_to_s, original_error)
|
17
16
|
end
|
18
17
|
|
19
18
|
def extract_options!(args)
|
@@ -43,6 +42,12 @@ class Fabrication::Support
|
|
43
42
|
@hash_class ||= defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : Hash
|
44
43
|
end
|
45
44
|
|
45
|
+
def singularize(string)
|
46
|
+
string.singularize
|
47
|
+
rescue
|
48
|
+
string.end_with?('s') ? string[0..-2] : string
|
49
|
+
end
|
50
|
+
|
46
51
|
end
|
47
52
|
|
48
53
|
end
|
data/lib/fabrication/version.rb
CHANGED
metadata
CHANGED
@@ -1,215 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabrication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Elliott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activerecord
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bson_ext
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: cucumber
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: sqlite3
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: dm-core
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: dm-migrations
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: dm-sqlite-adapter
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: dm-validations
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: ffaker
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: mongoid
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '3.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '3.0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: pry
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: rake
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: rspec
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: sequel
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
209
13
|
description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
|
210
14
|
DataMapper, Sequel, or any other Ruby object.
|
211
15
|
email:
|
212
|
-
- paul@
|
16
|
+
- paul@codingfrontier.com
|
213
17
|
executables: []
|
214
18
|
extensions: []
|
215
19
|
extra_rdoc_files: []
|
@@ -268,5 +72,5 @@ rubyforge_project:
|
|
268
72
|
rubygems_version: 2.2.1
|
269
73
|
signing_key:
|
270
74
|
specification_version: 4
|
271
|
-
summary:
|
75
|
+
summary: Implementing the factory pattern in Ruby so you don't have to.
|
272
76
|
test_files: []
|