factory_girl 2.0.0.beta2 → 2.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/Appraisals +1 -0
- data/CONTRIBUTION_GUIDELINES.md +7 -7
- data/GETTING_STARTED.md +36 -11
- data/Gemfile +2 -2
- data/Gemfile.lock +28 -21
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/features/factory_girl_steps.feature +33 -0
- data/features/support/factories.rb +25 -18
- data/features/support/test.db +0 -0
- data/lib/factory_girl.rb +27 -0
- data/lib/factory_girl/attribute.rb +4 -0
- data/lib/factory_girl/attribute/association.rb +4 -0
- data/lib/factory_girl/attribute/dynamic.rb +1 -1
- data/lib/factory_girl/attribute/implicit.rb +36 -0
- data/lib/factory_girl/attribute/sequence.rb +16 -0
- data/lib/factory_girl/definition_proxy.rb +2 -2
- data/lib/factory_girl/factory.rb +1 -13
- data/lib/factory_girl/find_definitions.rb +1 -3
- data/lib/factory_girl/proxy/build.rb +2 -2
- data/lib/factory_girl/proxy/stub.rb +6 -2
- data/lib/factory_girl/rails2.rb +7 -1
- data/lib/factory_girl/registry.rb +7 -21
- data/lib/factory_girl/sequence.rb +3 -14
- data/lib/factory_girl/step_definitions.rb +5 -5
- data/lib/factory_girl/syntax/blueprint.rb +1 -1
- data/lib/factory_girl/syntax/default.rb +3 -3
- data/lib/factory_girl/syntax/generate.rb +3 -3
- data/lib/factory_girl/syntax/make.rb +5 -1
- data/lib/factory_girl/syntax/methods.rb +51 -4
- data/lib/factory_girl/syntax/sham.rb +2 -2
- data/lib/factory_girl/syntax/vintage.rb +31 -12
- data/lib/factory_girl/version.rb +1 -1
- data/spec/acceptance/build_list_spec.rb +42 -0
- data/spec/acceptance/create_list_spec.rb +42 -0
- data/spec/acceptance/sequence_spec.rb +6 -4
- data/spec/acceptance/syntax/blueprint_spec.rb +3 -3
- data/spec/acceptance/syntax/make_spec.rb +19 -1
- data/spec/acceptance/syntax/vintage_spec.rb +4 -4
- data/spec/factory_girl/attribute/association_spec.rb +4 -0
- data/spec/factory_girl/attribute/implicit_spec.rb +50 -0
- data/spec/factory_girl/attribute/sequence_spec.rb +21 -0
- data/spec/factory_girl/attribute_spec.rb +4 -0
- data/spec/factory_girl/definition_proxy_spec.rb +2 -13
- data/spec/factory_girl/factory_spec.rb +4 -2
- data/spec/factory_girl/find_definitions_spec.rb +9 -0
- data/spec/factory_girl/proxy/build_spec.rb +2 -2
- data/spec/factory_girl/proxy/create_spec.rb +2 -2
- data/spec/factory_girl/proxy/stub_spec.rb +5 -1
- data/spec/factory_girl/registry_spec.rb +11 -20
- data/spec/factory_girl/sequence_spec.rb +15 -19
- data/spec/factory_girl_spec.rb +17 -0
- data/spec/spec_helper.rb +2 -1
- metadata +45 -73
@@ -7,15 +7,15 @@ describe FactoryGirl::Sequence do
|
|
7
7
|
@sequence = FactoryGirl::Sequence.new(@name) {|n| "=#{n}" }
|
8
8
|
end
|
9
9
|
|
10
|
+
it "has a name" do
|
11
|
+
@sequence.name.should == @name
|
12
|
+
end
|
13
|
+
|
10
14
|
it "has names" do
|
11
15
|
@sequence.names.should == [@name]
|
12
16
|
end
|
13
17
|
|
14
18
|
it "should start with a value of 1" do
|
15
|
-
@sequence.run.should == "=1"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "responds to next" do
|
19
19
|
@sequence.next.should == "=1"
|
20
20
|
end
|
21
21
|
|
@@ -23,17 +23,13 @@ describe FactoryGirl::Sequence do
|
|
23
23
|
@sequence.default_strategy.should == :create
|
24
24
|
end
|
25
25
|
|
26
|
-
it "runs compatible with the Factory interface" do
|
27
|
-
@sequence.run(nil, nil).should == "=1"
|
28
|
-
end
|
29
|
-
|
30
26
|
describe "after being called" do
|
31
27
|
before do
|
32
|
-
@sequence.
|
28
|
+
@sequence.next
|
33
29
|
end
|
34
30
|
|
35
31
|
it "should use the next value" do
|
36
|
-
@sequence.
|
32
|
+
@sequence.next.should == "=2"
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -44,16 +40,16 @@ describe FactoryGirl::Sequence do
|
|
44
40
|
end
|
45
41
|
|
46
42
|
it "should start with a value of A" do
|
47
|
-
@sequence.
|
43
|
+
@sequence.next.should == "=A"
|
48
44
|
end
|
49
45
|
|
50
46
|
describe "after being called" do
|
51
47
|
before do
|
52
|
-
@sequence.
|
48
|
+
@sequence.next
|
53
49
|
end
|
54
50
|
|
55
51
|
it "should use the next value" do
|
56
|
-
@sequence.
|
52
|
+
@sequence.next.should == "=B"
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
@@ -64,16 +60,16 @@ describe FactoryGirl::Sequence do
|
|
64
60
|
end
|
65
61
|
|
66
62
|
it "should start with a value of 1" do
|
67
|
-
@sequence.
|
63
|
+
@sequence.next.should == 1
|
68
64
|
end
|
69
65
|
|
70
66
|
describe "after being called" do
|
71
67
|
before do
|
72
|
-
@sequence.
|
68
|
+
@sequence.next
|
73
69
|
end
|
74
70
|
|
75
71
|
it "should use the next value" do
|
76
|
-
@sequence.
|
72
|
+
@sequence.next.should == 2
|
77
73
|
end
|
78
74
|
end
|
79
75
|
end
|
@@ -84,16 +80,16 @@ describe FactoryGirl::Sequence do
|
|
84
80
|
end
|
85
81
|
|
86
82
|
it "should start with a value of A" do
|
87
|
-
@sequence.
|
83
|
+
@sequence.next.should == "A"
|
88
84
|
end
|
89
85
|
|
90
86
|
describe "after being called" do
|
91
87
|
before do
|
92
|
-
@sequence.
|
88
|
+
@sequence.next
|
93
89
|
end
|
94
90
|
|
95
91
|
it "should use the next value" do
|
96
|
-
@sequence.
|
92
|
+
@sequence.next.should == "B"
|
97
93
|
end
|
98
94
|
end
|
99
95
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FactoryGirl do
|
4
|
+
let(:factory) { FactoryGirl::Factory.new(:object) }
|
5
|
+
let(:sequence) { FactoryGirl::Sequence.new(:email) }
|
6
|
+
|
7
|
+
it "finds a registered a factory" do
|
8
|
+
FactoryGirl.register_factory(factory)
|
9
|
+
FactoryGirl.factory_by_name(factory.name).should == factory
|
10
|
+
end
|
11
|
+
|
12
|
+
it "finds a registered a sequence" do
|
13
|
+
FactoryGirl.register_sequence(sequence)
|
14
|
+
FactoryGirl.sequence_by_name(sequence.name).should == sequence
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -22,7 +22,8 @@ RSpec.configure do |config|
|
|
22
22
|
config.mock_framework = :rr
|
23
23
|
RSpec::Core::ExampleGroup.send(:include, RR::Adapters::Rspec)
|
24
24
|
config.after do
|
25
|
-
FactoryGirl.
|
25
|
+
FactoryGirl.factories.clear
|
26
|
+
FactoryGirl.sequences.clear
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
metadata
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
- beta2
|
11
|
-
version: 2.0.0.beta2
|
4
|
+
prerelease: 6
|
5
|
+
version: 2.0.0.beta3
|
12
6
|
platform: ruby
|
13
7
|
authors:
|
14
8
|
- Joe Ferris
|
@@ -16,112 +10,86 @@ autorequire:
|
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
12
|
|
19
|
-
date: 2011-
|
13
|
+
date: 2011-06-29 00:00:00 -04:00
|
20
14
|
default_executable:
|
21
15
|
dependencies:
|
22
16
|
- !ruby/object:Gem::Dependency
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
17
|
name: rcov
|
26
|
-
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
20
|
none: false
|
28
21
|
requirements:
|
29
22
|
- - ">="
|
30
23
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 3
|
32
|
-
segments:
|
33
|
-
- 0
|
34
24
|
version: "0"
|
35
|
-
requirement: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
25
|
type: :development
|
38
|
-
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
39
28
|
name: rspec
|
40
|
-
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
31
|
none: false
|
42
32
|
requirements:
|
43
33
|
- - ">="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
|
-
segments:
|
47
|
-
- 0
|
48
35
|
version: "0"
|
49
|
-
requirement: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
36
|
type: :development
|
52
|
-
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
53
39
|
name: cucumber
|
54
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
42
|
none: false
|
56
43
|
requirements:
|
57
44
|
- - ">="
|
58
45
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
|
-
- 0
|
62
46
|
version: "0"
|
63
|
-
requirement: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
47
|
type: :development
|
66
|
-
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
67
50
|
name: activerecord
|
68
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
53
|
none: false
|
70
54
|
requirements:
|
71
55
|
- - ~>
|
72
56
|
- !ruby/object:Gem::Version
|
73
|
-
hash: 9
|
74
|
-
segments:
|
75
|
-
- 2
|
76
|
-
- 3
|
77
|
-
- 5
|
78
57
|
version: 2.3.5
|
79
|
-
requirement: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
58
|
type: :development
|
82
|
-
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
83
61
|
name: activerecord
|
84
|
-
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
64
|
none: false
|
86
65
|
requirements:
|
87
66
|
- - ~>
|
88
67
|
- !ruby/object:Gem::Version
|
89
|
-
hash: 299253627
|
90
|
-
segments:
|
91
|
-
- 3
|
92
|
-
- 0
|
93
|
-
- 0
|
94
|
-
- beta3
|
95
68
|
version: 3.0.0.beta3
|
96
|
-
requirement: *id005
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
69
|
type: :development
|
99
|
-
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
100
72
|
name: rr
|
101
|
-
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
75
|
none: false
|
103
76
|
requirements:
|
104
77
|
- - ">="
|
105
78
|
- !ruby/object:Gem::Version
|
106
|
-
hash: 3
|
107
|
-
segments:
|
108
|
-
- 0
|
109
79
|
version: "0"
|
110
|
-
requirement: *id006
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
80
|
type: :development
|
113
|
-
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
114
83
|
name: sqlite3
|
115
|
-
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
86
|
none: false
|
117
87
|
requirements:
|
118
88
|
- - ">="
|
119
89
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
|
-
segments:
|
122
|
-
- 0
|
123
90
|
version: "0"
|
124
|
-
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id007
|
125
93
|
description: |-
|
126
94
|
factory_girl provides a framework and DSL for defining and
|
127
95
|
using factories - less error-prone, more explicit, and
|
@@ -147,6 +115,8 @@ files:
|
|
147
115
|
- lib/factory_girl/attribute/association.rb
|
148
116
|
- lib/factory_girl/attribute/callback.rb
|
149
117
|
- lib/factory_girl/attribute/dynamic.rb
|
118
|
+
- lib/factory_girl/attribute/implicit.rb
|
119
|
+
- lib/factory_girl/attribute/sequence.rb
|
150
120
|
- lib/factory_girl/attribute/static.rb
|
151
121
|
- lib/factory_girl/attribute.rb
|
152
122
|
- lib/factory_girl/definition_proxy.rb
|
@@ -175,9 +145,11 @@ files:
|
|
175
145
|
- spec/acceptance/acceptance_helper.rb
|
176
146
|
- spec/acceptance/attribute_aliases_spec.rb
|
177
147
|
- spec/acceptance/attributes_for_spec.rb
|
148
|
+
- spec/acceptance/build_list_spec.rb
|
178
149
|
- spec/acceptance/build_spec.rb
|
179
150
|
- spec/acceptance/build_stubbed_spec.rb
|
180
151
|
- spec/acceptance/callbacks_spec.rb
|
152
|
+
- spec/acceptance/create_list_spec.rb
|
181
153
|
- spec/acceptance/create_spec.rb
|
182
154
|
- spec/acceptance/default_strategy_spec.rb
|
183
155
|
- spec/acceptance/definition_spec.rb
|
@@ -192,6 +164,8 @@ files:
|
|
192
164
|
- spec/factory_girl/attribute/association_spec.rb
|
193
165
|
- spec/factory_girl/attribute/callback_spec.rb
|
194
166
|
- spec/factory_girl/attribute/dynamic_spec.rb
|
167
|
+
- spec/factory_girl/attribute/implicit_spec.rb
|
168
|
+
- spec/factory_girl/attribute/sequence_spec.rb
|
195
169
|
- spec/factory_girl/attribute/static_spec.rb
|
196
170
|
- spec/factory_girl/attribute_spec.rb
|
197
171
|
- spec/factory_girl/definition_proxy_spec.rb
|
@@ -205,6 +179,7 @@ files:
|
|
205
179
|
- spec/factory_girl/proxy_spec.rb
|
206
180
|
- spec/factory_girl/registry_spec.rb
|
207
181
|
- spec/factory_girl/sequence_spec.rb
|
182
|
+
- spec/factory_girl_spec.rb
|
208
183
|
- spec/spec_helper.rb
|
209
184
|
- features/factory_girl_steps.feature
|
210
185
|
- features/step_definitions/database_steps.rb
|
@@ -212,7 +187,7 @@ files:
|
|
212
187
|
- features/support/factories.rb
|
213
188
|
- features/support/test.db
|
214
189
|
has_rdoc: true
|
215
|
-
homepage:
|
190
|
+
homepage: https://github.com/thoughtbot/factory_girl
|
216
191
|
licenses: []
|
217
192
|
|
218
193
|
post_install_message:
|
@@ -225,34 +200,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
225
200
|
requirements:
|
226
201
|
- - ">="
|
227
202
|
- !ruby/object:Gem::Version
|
228
|
-
hash: 3
|
229
|
-
segments:
|
230
|
-
- 0
|
231
203
|
version: "0"
|
232
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
205
|
none: false
|
234
206
|
requirements:
|
235
207
|
- - ">"
|
236
208
|
- !ruby/object:Gem::Version
|
237
|
-
hash: 25
|
238
|
-
segments:
|
239
|
-
- 1
|
240
|
-
- 3
|
241
|
-
- 1
|
242
209
|
version: 1.3.1
|
243
210
|
requirements: []
|
244
211
|
|
245
212
|
rubyforge_project:
|
246
|
-
rubygems_version: 1.
|
213
|
+
rubygems_version: 1.6.2
|
247
214
|
signing_key:
|
248
215
|
specification_version: 3
|
249
216
|
summary: factory_girl provides a framework and DSL for defining and using model instance factories.
|
250
217
|
test_files:
|
251
218
|
- spec/acceptance/attribute_aliases_spec.rb
|
252
219
|
- spec/acceptance/attributes_for_spec.rb
|
220
|
+
- spec/acceptance/build_list_spec.rb
|
253
221
|
- spec/acceptance/build_spec.rb
|
254
222
|
- spec/acceptance/build_stubbed_spec.rb
|
255
223
|
- spec/acceptance/callbacks_spec.rb
|
224
|
+
- spec/acceptance/create_list_spec.rb
|
256
225
|
- spec/acceptance/create_spec.rb
|
257
226
|
- spec/acceptance/default_strategy_spec.rb
|
258
227
|
- spec/acceptance/definition_spec.rb
|
@@ -267,6 +236,8 @@ test_files:
|
|
267
236
|
- spec/factory_girl/attribute/association_spec.rb
|
268
237
|
- spec/factory_girl/attribute/callback_spec.rb
|
269
238
|
- spec/factory_girl/attribute/dynamic_spec.rb
|
239
|
+
- spec/factory_girl/attribute/implicit_spec.rb
|
240
|
+
- spec/factory_girl/attribute/sequence_spec.rb
|
270
241
|
- spec/factory_girl/attribute/static_spec.rb
|
271
242
|
- spec/factory_girl/attribute_spec.rb
|
272
243
|
- spec/factory_girl/definition_proxy_spec.rb
|
@@ -280,6 +251,7 @@ test_files:
|
|
280
251
|
- spec/factory_girl/proxy_spec.rb
|
281
252
|
- spec/factory_girl/registry_spec.rb
|
282
253
|
- spec/factory_girl/sequence_spec.rb
|
254
|
+
- spec/factory_girl_spec.rb
|
283
255
|
- features/factory_girl_steps.feature
|
284
256
|
- features/step_definitions/database_steps.rb
|
285
257
|
- features/support/env.rb
|