factory_girl 3.6.2 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,7 @@
1
- require 'active_support/deprecation'
2
-
3
1
  require 'factory_girl/syntax/methods'
4
2
  require 'factory_girl/syntax/default'
5
- require 'factory_girl/syntax/vintage'
6
3
 
7
4
  module FactoryGirl
8
- # Provides alternate syntaxes for factory_girl. If you don't like the default
9
- # syntax for defining or using factories, look at one of the
10
- # FactoryGirl::Syntax modules:
11
- #
12
- # * FactoryGirl::Syntax::Blueprint: definition syntax similar to Machinist
13
- # * FactoryGirl::Syntax::Generate: usage syntax similar to Object Daddy
14
- # * FactoryGirl::Syntax::Make: usage syntax similar to Machinist
15
- # * FactoryGirl::Syntax::Sham: sequence syntax similar to Machinist
16
5
  module Syntax
17
6
  end
18
7
  end
@@ -1,3 +1,3 @@
1
1
  module FactoryGirl
2
- VERSION = '3.6.2'
2
+ VERSION = '4.0.0.rc1'
3
3
  end
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe 'global initialize_with' do
4
4
  before do
5
- ActiveSupport::Deprecation.silenced = true
6
-
7
5
  define_class('User') do
8
6
  attr_accessor:name
9
7
 
@@ -4,8 +4,6 @@ describe "initialize_with with non-FG attributes" do
4
4
  include FactoryGirl::Syntax::Methods
5
5
 
6
6
  before do
7
- ActiveSupport::Deprecation.silenced = true
8
-
9
7
  define_model("User", name: :string, age: :integer) do
10
8
  def self.construct(name, age)
11
9
  new(name: name, age: age)
@@ -28,8 +26,6 @@ describe "initialize_with with FG attributes that are ignored" do
28
26
  include FactoryGirl::Syntax::Methods
29
27
 
30
28
  before do
31
- ActiveSupport::Deprecation.silenced = true
32
-
33
29
  define_model("User", name: :string) do
34
30
  def self.construct(name)
35
31
  new(name: "#{name} from .construct")
@@ -51,38 +47,10 @@ describe "initialize_with with FG attributes that are ignored" do
51
47
  its(:name) { should == "Handsome Chap from .construct" }
52
48
  end
53
49
 
54
- describe "initialize_with with FG attributes that are not ignored" do
55
- include FactoryGirl::Syntax::Methods
56
-
57
- before do
58
- ActiveSupport::Deprecation.silenced = true
59
-
60
- define_model("User", name: :string) do
61
- def self.construct(name)
62
- new(name: "#{name} from .construct")
63
- end
64
- end
65
-
66
- FactoryGirl.define do
67
- factory :user do
68
- name { "Handsome Chap" }
69
-
70
- initialize_with { User.construct(name) }
71
- end
72
- end
73
- end
74
-
75
- it "assigns each attribute even if the attribute has been used in the constructor" do
76
- build(:user).name.should == "Handsome Chap"
77
- end
78
- end
79
-
80
50
  describe "initialize_with non-ORM-backed objects" do
81
51
  include FactoryGirl::Syntax::Methods
82
52
 
83
53
  before do
84
- ActiveSupport::Deprecation.silenced = true
85
-
86
54
  define_class("ReportGenerator") do
87
55
  attr_reader :name, :data
88
56
 
@@ -116,8 +84,6 @@ end
116
84
 
117
85
  describe "initialize_with parent and child factories" do
118
86
  before do
119
- ActiveSupport::Deprecation.silenced = true
120
-
121
87
  define_class("Awesome") do
122
88
  attr_reader :name
123
89
 
@@ -158,8 +124,6 @@ end
158
124
 
159
125
  describe "initialize_with implicit constructor" do
160
126
  before do
161
- ActiveSupport::Deprecation.silenced = true
162
-
163
127
  define_class("Awesome") do
164
128
  attr_reader :name
165
129
 
@@ -186,8 +150,6 @@ end
186
150
 
187
151
  describe "initialize_with doesn't duplicate assignment on attributes accessed from initialize_with" do
188
152
  before do
189
- ActiveSupport::Deprecation.silenced = true
190
-
191
153
  define_class("User") do
192
154
  attr_reader :name
193
155
  attr_accessor :email
@@ -211,8 +173,6 @@ describe "initialize_with doesn't duplicate assignment on attributes accessed fr
211
173
  end
212
174
 
213
175
  it "instantiates the correct object" do
214
- FactoryGirl.duplicate_attribute_assignment_from_initialize_with = false
215
-
216
176
  built_user = FactoryGirl.build(:user)
217
177
  built_user.name.should == "person1"
218
178
  built_user.email.should == "person1@example.com"
@@ -221,8 +181,6 @@ end
221
181
 
222
182
  describe "initialize_with has access to all attributes for construction" do
223
183
  before do
224
- ActiveSupport::Deprecation.silenced = true
225
-
226
184
  define_class("User") do
227
185
  attr_reader :name, :email, :ignored
228
186
 
@@ -251,8 +209,6 @@ describe "initialize_with has access to all attributes for construction" do
251
209
  end
252
210
 
253
211
  it "assigns attributes correctly" do
254
- FactoryGirl.duplicate_attribute_assignment_from_initialize_with = false
255
-
256
212
  user_with_attributes = FactoryGirl.build(:user)
257
213
  user_with_attributes.email.should == "person1@example.com"
258
214
  user_with_attributes.name.should == "person1"
@@ -490,8 +490,6 @@ end
490
490
 
491
491
  describe "traits with initialize_with" do
492
492
  before do
493
- ActiveSupport::Deprecation.silenced = true
494
-
495
493
  define_class("User") do
496
494
  attr_reader :name
497
495
 
@@ -19,7 +19,7 @@ describe FactoryGirl, "aliases" do
19
19
  end
20
20
  end
21
21
 
22
- describe Factory, "after defining an alias" do
22
+ describe FactoryGirl, "after defining an alias" do
23
23
  before do
24
24
  FactoryGirl.aliases << [/(.*)_suffix/, '\1']
25
25
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.2
5
- prerelease:
4
+ version: 4.0.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Clayton
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-24 00:00:00.000000000 Z
13
+ date: 2012-08-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -215,7 +215,6 @@ files:
215
215
  - Rakefile
216
216
  - cucumber.yml
217
217
  - factory_girl.gemspec
218
- - features/factory_girl_steps.feature
219
218
  - features/find_definitions.feature
220
219
  - features/step_definitions/database_steps.rb
221
220
  - features/step_definitions/factory_girl_steps.rb
@@ -249,7 +248,6 @@ files:
249
248
  - lib/factory_girl/decorator/attribute_hash.rb
250
249
  - lib/factory_girl/decorator/class_key_hash.rb
251
250
  - lib/factory_girl/decorator/disallows_duplicates_registry.rb
252
- - lib/factory_girl/decorator/invocation_ignorer.rb
253
251
  - lib/factory_girl/decorator/invocation_tracker.rb
254
252
  - lib/factory_girl/decorator/new_constructor.rb
255
253
  - lib/factory_girl/definition.rb
@@ -267,7 +265,6 @@ files:
267
265
  - lib/factory_girl/registry.rb
268
266
  - lib/factory_girl/reload.rb
269
267
  - lib/factory_girl/sequence.rb
270
- - lib/factory_girl/step_definitions.rb
271
268
  - lib/factory_girl/strategy/attributes_for.rb
272
269
  - lib/factory_girl/strategy/build.rb
273
270
  - lib/factory_girl/strategy/create.rb
@@ -276,13 +273,8 @@ files:
276
273
  - lib/factory_girl/strategy_calculator.rb
277
274
  - lib/factory_girl/strategy_syntax_method_registrar.rb
278
275
  - lib/factory_girl/syntax.rb
279
- - lib/factory_girl/syntax/blueprint.rb
280
276
  - lib/factory_girl/syntax/default.rb
281
- - lib/factory_girl/syntax/generate.rb
282
- - lib/factory_girl/syntax/make.rb
283
277
  - lib/factory_girl/syntax/methods.rb
284
- - lib/factory_girl/syntax/sham.rb
285
- - lib/factory_girl/syntax/vintage.rb
286
278
  - lib/factory_girl/syntax_runner.rb
287
279
  - lib/factory_girl/trait.rb
288
280
  - lib/factory_girl/version.rb
@@ -315,11 +307,6 @@ files:
315
307
  - spec/acceptance/sequence_spec.rb
316
308
  - spec/acceptance/skip_create_spec.rb
317
309
  - spec/acceptance/stub_spec.rb
318
- - spec/acceptance/syntax/blueprint_spec.rb
319
- - spec/acceptance/syntax/generate_spec.rb
320
- - spec/acceptance/syntax/make_spec.rb
321
- - spec/acceptance/syntax/sham_spec.rb
322
- - spec/acceptance/syntax/vintage_spec.rb
323
310
  - spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
324
311
  - spec/acceptance/traits_spec.rb
325
312
  - spec/acceptance/transient_attributes_spec.rb
@@ -371,9 +358,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
371
358
  required_rubygems_version: !ruby/object:Gem::Requirement
372
359
  none: false
373
360
  requirements:
374
- - - ! '>='
361
+ - - ! '>'
375
362
  - !ruby/object:Gem::Version
376
- version: '0'
363
+ version: 1.3.1
377
364
  requirements: []
378
365
  rubyforge_project:
379
366
  rubygems_version: 1.8.23
@@ -383,7 +370,6 @@ summary: factory_girl provides a framework and DSL for defining and using model
383
370
  factories.
384
371
  test_files:
385
372
  - Appraisals
386
- - features/factory_girl_steps.feature
387
373
  - features/find_definitions.feature
388
374
  - features/step_definitions/database_steps.rb
389
375
  - features/step_definitions/factory_girl_steps.rb
@@ -424,11 +410,6 @@ test_files:
424
410
  - spec/acceptance/sequence_spec.rb
425
411
  - spec/acceptance/skip_create_spec.rb
426
412
  - spec/acceptance/stub_spec.rb
427
- - spec/acceptance/syntax/blueprint_spec.rb
428
- - spec/acceptance/syntax/generate_spec.rb
429
- - spec/acceptance/syntax/make_spec.rb
430
- - spec/acceptance/syntax/sham_spec.rb
431
- - spec/acceptance/syntax/vintage_spec.rb
432
413
  - spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
433
414
  - spec/acceptance/traits_spec.rb
434
415
  - spec/acceptance/transient_attributes_spec.rb
@@ -1,241 +0,0 @@
1
- Feature: Use step definitions generated by factories
2
-
3
- Scenario: create a post and verify its attributes
4
- Given the following post exists:
5
- | Title | Body |
6
- | a fun title | here is the content |
7
- Then I should find the following for the last post:
8
- | title | body |
9
- | a fun title | here is the content |
10
-
11
- Scenario: create a post and verify its attributes without the trailing colon
12
- Given the following post exists
13
- | Title | Body |
14
- | a fun title | here is the content |
15
- Then I should find the following for the last post:
16
- | title | body |
17
- | a fun title | here is the content |
18
-
19
- Scenario: create a post without a table and verify its attributes
20
- Given a post exists with a title of "a fun title"
21
- Then I should find the following for the last post:
22
- | title |
23
- | a fun title |
24
-
25
- Scenario: flexible English when creating posts
26
- Given an post exists with an title of "a fun title"
27
- Then I should find the following for the last post:
28
- | title |
29
- | a fun title |
30
-
31
- Scenario: create a post with an underscore in an attribute name
32
- Given a post exists with an author ID of "5"
33
- Then I should find the following for the last post:
34
- | author_id |
35
- | 5 |
36
-
37
- Scenario: create several posts
38
- Given the following posts exist:
39
- | Title | Body |
40
- | one | first |
41
- | two | second |
42
- | three | third |
43
- Then I should find the following for the last post:
44
- | title | body |
45
- | three | third |
46
- And there should be 3 posts
47
-
48
- Scenario: create a post with a new author
49
- Given the following post exists:
50
- | Title | Author |
51
- | a title | ID: 123 |
52
- Then I should find the following for the last post:
53
- | title | author_id |
54
- | a title | 123 |
55
- And I should find the following for the last user:
56
- | id |
57
- | 123 |
58
-
59
- Scenario: create a post with an existing author
60
- Given the following user exists:
61
- | ID | Name |
62
- | 123 | Joe |
63
- And the following post exists:
64
- | Title | Author |
65
- | a title | Name: Joe |
66
- Then I should find the following for the last post:
67
- | title | author_id |
68
- | a title | 123 |
69
- And there should be 1 user
70
-
71
- Scenario: create a titled post with a new author (inherited association)
72
- Given the following titled post exists:
73
- | Title | Author |
74
- | A Post with a Title | ID: 123 |
75
- Then I should find the following for the last post:
76
- | title | author_id |
77
- | A Post with a Title | 123 |
78
-
79
- Scenario: create post with and without a category association
80
- Given the following users exist:
81
- | ID | Name |
82
- | 123 | Joe |
83
- And the following posts exist:
84
- | Title | Author | Category |
85
- | a title | Name: Joe | Name: programming |
86
- | a title without a category | Name: Joe | |
87
- Then I should find the following for the last post:
88
- | title | category_id |
89
- | a title without a category | |
90
-
91
- Scenario: create a user without attributes
92
- Given a user exists
93
- Then there should be 1 user
94
-
95
- Scenario: create several users without attributes
96
- Given 3 users exist
97
- Then there should be 3 users
98
-
99
- Scenario: create several users with one attribute
100
- Given 3 users exist with a name of "John"
101
- Then there should be 3 users
102
- And I should find the following for the last user:
103
- | name |
104
- | John |
105
-
106
- Scenario: create instances of a factory with an underscore in its name
107
- Given an admin user exists with a name of "John"
108
- Then I should find the following for the last user:
109
- | name | admin |
110
- | John | true |
111
-
112
- Scenario: create a several instances of a factory with an underscore in its name
113
- Given 3 admin users exist
114
- Then I should find the following for the last user:
115
- | admin |
116
- | true |
117
-
118
- Scenario: use true values when creating instances
119
- Given the following user exists:
120
- | name | admin |
121
- | Bill | true |
122
- Then I should find the following for the last user:
123
- | name | admin |
124
- | Bill | true |
125
-
126
- Scenario: use false values when creating instances
127
- Given the following user exists:
128
- | name | admin |
129
- | Mike | false |
130
- Then I should find the following for the last user:
131
- | name | admin |
132
- | Mike | false |
133
-
134
- Scenario: Properly pluralize words
135
- Given the following categories exist:
136
- | name |
137
- | Bed |
138
- | Test Drive |
139
- And 2 categories exist
140
- And 2 categories exist with a name of "Future"
141
- Then there should be 6 categories
142
-
143
- Scenario: create a post with an existing category group
144
- Given the following category exists:
145
- | ID | name | category group |
146
- | 123 | fiction | Name: books |
147
- And the following post exists:
148
- | Title | Author | Category |
149
- | a title | Name: Joe | Category Group: Name: books |
150
- Then I should find the following for the last post:
151
- | title | category_id |
152
- | a title | 123 |
153
-
154
- Scenario: create a post with an existing category group and a new category
155
- Given the following category group exists:
156
- | ID | name |
157
- | 456 | books |
158
- And the following post exists:
159
- | Title | Author | Category |
160
- | a title | Name: Joe | Category Group: Name: books |
161
- Then I should find the following for the last post:
162
- | title |
163
- | a title |
164
- And I should find the following for the last category:
165
- | category_group_id |
166
- | 456 |
167
-
168
- Scenario: factory name and attributes should not be case sensitive
169
- Given the following category exists:
170
- | name | category group |
171
- | fiction | Name: books |
172
- Then there should be 1 category
173
- Given the following Category exists:
174
- | name | category group |
175
- | science | Name: books |
176
- Then there should be 2 categories
177
-
178
- Scenario: factory name and attributes should not be case sensitive
179
- Given a user exists
180
- Then there should be 1 user
181
- Given a User exists
182
- Then there should be 2 Users
183
-
184
- Scenario: factory name and attributes should not be case sensitive
185
- Given 3 users exist
186
- Then there should be 3 users
187
- Given 3 Users exist
188
- Then there should be 6 Users
189
-
190
- Scenario: factory name and attributes should not be case sensitive
191
- Given a category exists with a name of "fiction"
192
- Then there should be 1 category
193
- Given a Category exists with a name of "science"
194
- Then there should be 2 Categories
195
-
196
- Scenario: factory name and attributes should not be case sensitive
197
- Given 3 categories exist with a name of "fiction"
198
- Then there should be 3 categories
199
- Given 3 Categories exist with a name of "science"
200
- Then there should be 6 Categories
201
-
202
- Scenario: step definitions work correctly with aliases
203
- Given the following person exists:
204
- | ID | Name |
205
- | 123 | Joe |
206
- Then I should find the following for the last user:
207
- | id | name |
208
- | 123 | Joe |
209
-
210
- Scenario: pass a FactoryGirl table as an argument and modify it
211
- Given these super users exist:
212
- | id | Name |
213
- | 123 | Joe |
214
- Then I should find the following for the last user:
215
- | id | name | admin |
216
- | 123 | Joe | true |
217
-
218
- Scenario: Transform parses string data into array before assigning to an association
219
- Given the following tags exist:
220
- | name |
221
- | funky |
222
- | cool |
223
- | hip |
224
- And the following post exists:
225
- | title | tags |
226
- | Tagged post | cool, hip |
227
- Then the post "Tagged post" should have the following tags:
228
- | name |
229
- | cool |
230
- | hip |
231
- And the post "Tagged post" should not have the following tags:
232
- | name |
233
- | funky |
234
-
235
- Scenario: step definitions work correctly with ORMs that have simple `columns`
236
- Given a simple column exists
237
- Then there should be 1 SimpleColumn
238
-
239
- Scenario: step definitions work correctly with model classes that simply have attribute names
240
- Given a named attribute model exists with a title of "a fun title"
241
- Then there should be 1 NamedAttributeModel