fabrication 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.markdown +1 -1
- data/Rakefile +1 -5
- data/lib/fabrication.rb +7 -6
- data/lib/fabrication/generator/active_record.rb +5 -3
- data/lib/fabrication/generator/active_record_4.rb +17 -0
- data/lib/fabrication/schematic/definition.rb +1 -0
- data/lib/fabrication/version.rb +1 -1
- metadata +38 -87
- data/lib/rails/generators/fabrication/turnip_steps/templates/fabrication_steps.rb +0 -57
- data/lib/rails/generators/fabrication/turnip_steps/turnip_steps_generator.rb +0 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f0f5573caa099c8f92ea459569ffc47dd494dc6
|
4
|
+
data.tar.gz: 4de52e357b08de2e4990517d66f93249a3f1256b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e27ade3d385c0fe2fb035521a689b76cc58fe00e8150c92b38a9dc00f2456610af59ac9dbfd1bf5ed79054b9d2d619cd1b2456c636c653c1441d1ae3a8d8e18
|
7
|
+
data.tar.gz: 992794de30ecf4c63d1bbf6e81b35f0c601f3c24876a2043cfca65d7ca5a11747c635abbcd8832f5534928da48382aaed4797c66072a2ee428f5df8402195068
|
data/README.markdown
CHANGED
@@ -9,7 +9,7 @@ Fabrication is an object generation framework for Ruby.
|
|
9
9
|
Fabrication is tested against Ruby 1.9.2, 1.9.3, and Rubinius.
|
10
10
|
|
11
11
|
[![Build Status](https://secure.travis-ci.org/paulelliott/fabrication.png)](http://travis-ci.org/paulelliott/fabrication)
|
12
|
-
[![Code Climate](https://codeclimate.com/
|
12
|
+
[![Code Climate](https://codeclimate.com/github/paulelliott/fabrication.png)](https://codeclimate.com/github/paulelliott/fabrication)
|
13
13
|
|
14
14
|
## Documentation
|
15
15
|
|
data/Rakefile
CHANGED
@@ -8,8 +8,4 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
|
|
8
8
|
t.cucumber_opts = "--format progress --tags ~@wip"
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
spec.pattern = "turnip/**/*.feature"
|
13
|
-
end
|
14
|
-
|
15
|
-
task :default => [:spec, :cucumber, :turnip]
|
11
|
+
task :default => [:spec, :cucumber]
|
data/lib/fabrication.rb
CHANGED
@@ -21,12 +21,13 @@ module Fabrication
|
|
21
21
|
autoload :Cucumber, 'fabrication/cucumber/step_fabricator'
|
22
22
|
|
23
23
|
module Generator
|
24
|
-
autoload :ActiveRecord,
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :
|
28
|
-
autoload :
|
29
|
-
autoload :
|
24
|
+
autoload :ActiveRecord, 'fabrication/generator/active_record'
|
25
|
+
autoload :ActiveRecord4, 'fabrication/generator/active_record_4'
|
26
|
+
autoload :DataMapper, 'fabrication/generator/data_mapper'
|
27
|
+
autoload :Mongoid, 'fabrication/generator/mongoid'
|
28
|
+
autoload :Sequel, 'fabrication/generator/sequel'
|
29
|
+
autoload :Keymaker, 'fabrication/generator/keymaker'
|
30
|
+
autoload :Base, 'fabrication/generator/base'
|
30
31
|
end
|
31
32
|
|
32
33
|
def self.clear_definitions
|
@@ -4,12 +4,14 @@ class Fabrication::Generator::ActiveRecord < Fabrication::Generator::Base
|
|
4
4
|
defined?(ActiveRecord) && klass.ancestors.include?(ActiveRecord::Base)
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
self.__instance = __klass.new(__attributes, without_protection: true)
|
9
|
-
end
|
7
|
+
private
|
10
8
|
|
11
9
|
def validate_instance
|
12
10
|
__instance.valid?
|
13
11
|
end
|
14
12
|
|
13
|
+
def build_instance
|
14
|
+
self.__instance = __klass.new(__attributes, without_protection: true)
|
15
|
+
end
|
16
|
+
|
15
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Fabrication::Generator::ActiveRecord4 < Fabrication::Generator::ActiveRecord
|
2
|
+
|
3
|
+
def self.supports?(klass)
|
4
|
+
super && active_record_4?
|
5
|
+
end
|
6
|
+
|
7
|
+
def build_instance
|
8
|
+
self.__instance = __klass.new(__attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.active_record_4?
|
14
|
+
ActiveRecord::VERSION::MAJOR == 4
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/fabrication/version.rb
CHANGED
metadata
CHANGED
@@ -1,270 +1,223 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabrication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
5
|
-
prerelease:
|
4
|
+
version: 2.6.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Elliott
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bson_ext
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: cucumber
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: sqlite3
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: dm-active_model
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: dm-core
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: dm-migrations
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: dm-sqlite-adapter
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: turnip
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0.3'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0.3'
|
158
125
|
- !ruby/object:Gem::Dependency
|
159
126
|
name: ffaker
|
160
127
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
128
|
requirements:
|
163
|
-
- -
|
129
|
+
- - '>='
|
164
130
|
- !ruby/object:Gem::Version
|
165
131
|
version: '0'
|
166
132
|
type: :development
|
167
133
|
prerelease: false
|
168
134
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
135
|
requirements:
|
171
|
-
- -
|
136
|
+
- - '>='
|
172
137
|
- !ruby/object:Gem::Version
|
173
138
|
version: '0'
|
174
139
|
- !ruby/object:Gem::Dependency
|
175
140
|
name: keymaker
|
176
141
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
142
|
requirements:
|
179
|
-
- -
|
143
|
+
- - '>='
|
180
144
|
- !ruby/object:Gem::Version
|
181
145
|
version: '0'
|
182
146
|
type: :development
|
183
147
|
prerelease: false
|
184
148
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
149
|
requirements:
|
187
|
-
- -
|
150
|
+
- - '>='
|
188
151
|
- !ruby/object:Gem::Version
|
189
152
|
version: '0'
|
190
153
|
- !ruby/object:Gem::Dependency
|
191
154
|
name: mongoid
|
192
155
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
156
|
requirements:
|
195
|
-
- -
|
157
|
+
- - '>='
|
196
158
|
- !ruby/object:Gem::Version
|
197
159
|
version: '0'
|
198
160
|
type: :development
|
199
161
|
prerelease: false
|
200
162
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
163
|
requirements:
|
203
|
-
- -
|
164
|
+
- - '>='
|
204
165
|
- !ruby/object:Gem::Version
|
205
166
|
version: '0'
|
206
167
|
- !ruby/object:Gem::Dependency
|
207
168
|
name: pry
|
208
169
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
170
|
requirements:
|
211
|
-
- -
|
171
|
+
- - '>='
|
212
172
|
- !ruby/object:Gem::Version
|
213
173
|
version: '0'
|
214
174
|
type: :development
|
215
175
|
prerelease: false
|
216
176
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
177
|
requirements:
|
219
|
-
- -
|
178
|
+
- - '>='
|
220
179
|
- !ruby/object:Gem::Version
|
221
180
|
version: '0'
|
222
181
|
- !ruby/object:Gem::Dependency
|
223
182
|
name: rake
|
224
183
|
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
184
|
requirements:
|
227
|
-
- -
|
185
|
+
- - '>='
|
228
186
|
- !ruby/object:Gem::Version
|
229
187
|
version: '0'
|
230
188
|
type: :development
|
231
189
|
prerelease: false
|
232
190
|
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
191
|
requirements:
|
235
|
-
- -
|
192
|
+
- - '>='
|
236
193
|
- !ruby/object:Gem::Version
|
237
194
|
version: '0'
|
238
195
|
- !ruby/object:Gem::Dependency
|
239
196
|
name: rspec
|
240
197
|
requirement: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
198
|
requirements:
|
243
|
-
- -
|
199
|
+
- - '>='
|
244
200
|
- !ruby/object:Gem::Version
|
245
201
|
version: '0'
|
246
202
|
type: :development
|
247
203
|
prerelease: false
|
248
204
|
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
205
|
requirements:
|
251
|
-
- -
|
206
|
+
- - '>='
|
252
207
|
- !ruby/object:Gem::Version
|
253
208
|
version: '0'
|
254
209
|
- !ruby/object:Gem::Dependency
|
255
210
|
name: sequel
|
256
211
|
requirement: !ruby/object:Gem::Requirement
|
257
|
-
none: false
|
258
212
|
requirements:
|
259
|
-
- -
|
213
|
+
- - '>='
|
260
214
|
- !ruby/object:Gem::Version
|
261
215
|
version: '0'
|
262
216
|
type: :development
|
263
217
|
prerelease: false
|
264
218
|
version_requirements: !ruby/object:Gem::Requirement
|
265
|
-
none: false
|
266
219
|
requirements:
|
267
|
-
- -
|
220
|
+
- - '>='
|
268
221
|
- !ruby/object:Gem::Version
|
269
222
|
version: '0'
|
270
223
|
description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
|
@@ -283,6 +236,7 @@ files:
|
|
283
236
|
- lib/fabrication/errors/unknown_fabricator_error.rb
|
284
237
|
- lib/fabrication/fabricator.rb
|
285
238
|
- lib/fabrication/generator/active_record.rb
|
239
|
+
- lib/fabrication/generator/active_record_4.rb
|
286
240
|
- lib/fabrication/generator/base.rb
|
287
241
|
- lib/fabrication/generator/data_mapper.rb
|
288
242
|
- lib/fabrication/generator/keymaker.rb
|
@@ -303,33 +257,30 @@ files:
|
|
303
257
|
- lib/rails/generators/fabrication/cucumber_steps/templates/fabrication_steps.rb
|
304
258
|
- lib/rails/generators/fabrication/model/model_generator.rb
|
305
259
|
- lib/rails/generators/fabrication/model/templates/fabricator.rb
|
306
|
-
- lib/rails/generators/fabrication/turnip_steps/templates/fabrication_steps.rb
|
307
|
-
- lib/rails/generators/fabrication/turnip_steps/turnip_steps_generator.rb
|
308
260
|
- LICENSE
|
309
261
|
- README.markdown
|
310
262
|
- Rakefile
|
311
263
|
homepage: http://fabricationgem.org
|
312
264
|
licenses: []
|
265
|
+
metadata: {}
|
313
266
|
post_install_message:
|
314
267
|
rdoc_options: []
|
315
268
|
require_paths:
|
316
269
|
- lib
|
317
270
|
required_ruby_version: !ruby/object:Gem::Requirement
|
318
|
-
none: false
|
319
271
|
requirements:
|
320
|
-
- -
|
272
|
+
- - '>='
|
321
273
|
- !ruby/object:Gem::Version
|
322
274
|
version: '0'
|
323
275
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
324
|
-
none: false
|
325
276
|
requirements:
|
326
|
-
- -
|
277
|
+
- - '>='
|
327
278
|
- !ruby/object:Gem::Version
|
328
279
|
version: '0'
|
329
280
|
requirements: []
|
330
281
|
rubyforge_project:
|
331
|
-
rubygems_version:
|
282
|
+
rubygems_version: 2.0.0
|
332
283
|
signing_key:
|
333
|
-
specification_version:
|
284
|
+
specification_version: 4
|
334
285
|
summary: Fabrication provides a simple solution for test object generation.
|
335
286
|
test_files: []
|
@@ -1,57 +0,0 @@
|
|
1
|
-
placeholder :fabrication_count do
|
2
|
-
match /\d+/ do |count|
|
3
|
-
count.to_i
|
4
|
-
end
|
5
|
-
match /a/ do
|
6
|
-
1
|
7
|
-
end
|
8
|
-
match /no/ do
|
9
|
-
0
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
steps_for :global do
|
14
|
-
def with_ivars(fabricator)
|
15
|
-
@they = yield fabricator
|
16
|
-
instance_variable_set("@#{fabricator.model}", @they)
|
17
|
-
end
|
18
|
-
|
19
|
-
step ':fabrication_count :model_name' do |count, model_name|
|
20
|
-
with_ivars Fabrication::Cucumber::StepFabricator.new(model_name) do |fab|
|
21
|
-
fab.n(count)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
step 'the following :model_name:' do |model_name, table|
|
26
|
-
with_ivars Fabrication::Cucumber::StepFabricator.new(model_name) do |fab|
|
27
|
-
fab.from_table(table)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
step 'that :parent has the following :child:' do |parent, child, table|
|
32
|
-
with_ivars Fabrication::Cucumber::StepFabricator.new(child, :parent => parent) do |fab|
|
33
|
-
fab.from_table(table)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
step 'that :parent has :fabrication_count :child' do |parent, count, child|
|
38
|
-
with_ivars Fabrication::Cucumber::StepFabricator.new(child, :parent => parent) do |fab|
|
39
|
-
fab.n(count)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
step 'that/those :children belong/belongs to that :parent' do |children, parent|
|
44
|
-
with_ivars Fabrication::Cucumber::StepFabricator.new(parent) do |fab|
|
45
|
-
fab.has_many(children)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
step 'I should see :fabrication_count :model_name in the database' do |count, model_name|
|
50
|
-
Fabrication::Cucumber::StepFabricator.new(model_name).klass.count.should == count
|
51
|
-
end
|
52
|
-
|
53
|
-
step 'I should see the following :model_name in the database:' do |model_name, table|
|
54
|
-
klass = Fabrication::Cucumber::StepFabricator.new(model_name).klass
|
55
|
-
klass.where(table.rows_hash).count.should == 1
|
56
|
-
end
|
57
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
|
-
module Fabrication
|
4
|
-
module Generators
|
5
|
-
class TurnipStepsGenerator < Rails::Generators::Base
|
6
|
-
argument :step_dir, :type => :string, :default => "spec/acceptance/steps/"
|
7
|
-
|
8
|
-
def generate
|
9
|
-
template 'fabrication_steps.rb', turnip_step_directory
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.source_root
|
13
|
-
@_fabrication_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def turnip_step_directory
|
19
|
-
File.join(step_dir, 'fabrication_steps.rb')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|