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.
Files changed (54) hide show
  1. data/Appraisals +1 -0
  2. data/CONTRIBUTION_GUIDELINES.md +7 -7
  3. data/GETTING_STARTED.md +36 -11
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +28 -21
  6. data/README.md +2 -2
  7. data/Rakefile +2 -2
  8. data/features/factory_girl_steps.feature +33 -0
  9. data/features/support/factories.rb +25 -18
  10. data/features/support/test.db +0 -0
  11. data/lib/factory_girl.rb +27 -0
  12. data/lib/factory_girl/attribute.rb +4 -0
  13. data/lib/factory_girl/attribute/association.rb +4 -0
  14. data/lib/factory_girl/attribute/dynamic.rb +1 -1
  15. data/lib/factory_girl/attribute/implicit.rb +36 -0
  16. data/lib/factory_girl/attribute/sequence.rb +16 -0
  17. data/lib/factory_girl/definition_proxy.rb +2 -2
  18. data/lib/factory_girl/factory.rb +1 -13
  19. data/lib/factory_girl/find_definitions.rb +1 -3
  20. data/lib/factory_girl/proxy/build.rb +2 -2
  21. data/lib/factory_girl/proxy/stub.rb +6 -2
  22. data/lib/factory_girl/rails2.rb +7 -1
  23. data/lib/factory_girl/registry.rb +7 -21
  24. data/lib/factory_girl/sequence.rb +3 -14
  25. data/lib/factory_girl/step_definitions.rb +5 -5
  26. data/lib/factory_girl/syntax/blueprint.rb +1 -1
  27. data/lib/factory_girl/syntax/default.rb +3 -3
  28. data/lib/factory_girl/syntax/generate.rb +3 -3
  29. data/lib/factory_girl/syntax/make.rb +5 -1
  30. data/lib/factory_girl/syntax/methods.rb +51 -4
  31. data/lib/factory_girl/syntax/sham.rb +2 -2
  32. data/lib/factory_girl/syntax/vintage.rb +31 -12
  33. data/lib/factory_girl/version.rb +1 -1
  34. data/spec/acceptance/build_list_spec.rb +42 -0
  35. data/spec/acceptance/create_list_spec.rb +42 -0
  36. data/spec/acceptance/sequence_spec.rb +6 -4
  37. data/spec/acceptance/syntax/blueprint_spec.rb +3 -3
  38. data/spec/acceptance/syntax/make_spec.rb +19 -1
  39. data/spec/acceptance/syntax/vintage_spec.rb +4 -4
  40. data/spec/factory_girl/attribute/association_spec.rb +4 -0
  41. data/spec/factory_girl/attribute/implicit_spec.rb +50 -0
  42. data/spec/factory_girl/attribute/sequence_spec.rb +21 -0
  43. data/spec/factory_girl/attribute_spec.rb +4 -0
  44. data/spec/factory_girl/definition_proxy_spec.rb +2 -13
  45. data/spec/factory_girl/factory_spec.rb +4 -2
  46. data/spec/factory_girl/find_definitions_spec.rb +9 -0
  47. data/spec/factory_girl/proxy/build_spec.rb +2 -2
  48. data/spec/factory_girl/proxy/create_spec.rb +2 -2
  49. data/spec/factory_girl/proxy/stub_spec.rb +5 -1
  50. data/spec/factory_girl/registry_spec.rb +11 -20
  51. data/spec/factory_girl/sequence_spec.rb +15 -19
  52. data/spec/factory_girl_spec.rb +17 -0
  53. data/spec/spec_helper.rb +2 -1
  54. 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.run
28
+ @sequence.next
33
29
  end
34
30
 
35
31
  it "should use the next value" do
36
- @sequence.run.should == "=2"
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.run.should == "=A"
43
+ @sequence.next.should == "=A"
48
44
  end
49
45
 
50
46
  describe "after being called" do
51
47
  before do
52
- @sequence.run
48
+ @sequence.next
53
49
  end
54
50
 
55
51
  it "should use the next value" do
56
- @sequence.run.should == "=B"
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.run.should == 1
63
+ @sequence.next.should == 1
68
64
  end
69
65
 
70
66
  describe "after being called" do
71
67
  before do
72
- @sequence.run
68
+ @sequence.next
73
69
  end
74
70
 
75
71
  it "should use the next value" do
76
- @sequence.run.should == 2
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.run.should == "A"
83
+ @sequence.next.should == "A"
88
84
  end
89
85
 
90
86
  describe "after being called" do
91
87
  before do
92
- @sequence.run
88
+ @sequence.next
93
89
  end
94
90
 
95
91
  it "should use the next value" do
96
- @sequence.run.should == "B"
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
+
@@ -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.registry = FactoryGirl::Registry.new
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
- hash: 299253610
5
- prerelease: true
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-02-17 00:00:00 -05:00
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
- version_requirements: &id001 !ruby/object:Gem::Requirement
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
- prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
39
28
  name: rspec
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
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
- prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
53
39
  name: cucumber
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
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
- prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
67
50
  name: activerecord
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
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
- prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
83
61
  name: activerecord
84
- version_requirements: &id005 !ruby/object:Gem::Requirement
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
- prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
100
72
  name: rr
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
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
- prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
114
83
  name: sqlite3
115
- version_requirements: &id007 !ruby/object:Gem::Requirement
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
- requirement: *id007
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: http://thoughtbot.com/projects/factory_girl
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.3.7
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