factory_girl 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ 2.4.1 (January 17, 2012)
2
+ Deprecate build_stubbed and attributes_for
3
+ Fix inline traits
4
+
1
5
  2.4.0 (January 13, 2012)
2
6
  Refactor internals of Factory Girl to use anonymous class on which attributes
3
7
  get defined
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.4.0)
4
+ factory_girl (2.4.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -152,6 +152,7 @@ module FactoryGirl
152
152
  def initialize_copy(source)
153
153
  super
154
154
  @definition = @definition.clone
155
+ @evaluator_class = nil
155
156
  end
156
157
  end
157
158
  end
@@ -5,6 +5,10 @@ module FactoryGirl
5
5
  # can be individually overridden by passing in a Hash of attribute => value
6
6
  # pairs.
7
7
  #
8
+ # DEPRECATED
9
+ #
10
+ # Use build or create instead, calling attributes on the result
11
+ #
8
12
  # Arguments:
9
13
  # * name: +Symbol+ or +String+
10
14
  # The name of the factory that should be used.
@@ -18,6 +22,7 @@ module FactoryGirl
18
22
  # A set of attributes that can be used to build an instance of the class
19
23
  # this factory generates.
20
24
  def attributes_for(name, *traits_and_overrides, &block)
25
+ $stderr.puts "DEPRECATION WARNING: FactoryGirl.attributes_for is deprecated; use FactoryGirl.build or FactoryGirl.create and call #attributes on the result instead."
21
26
  run_factory_girl_proxy(name, traits_and_overrides, Proxy::AttributesFor, &block)
22
27
  end
23
28
 
@@ -67,6 +72,10 @@ module FactoryGirl
67
72
  # stubbed out. Attributes can be individually overridden by passing in a Hash
68
73
  # of attribute => value pairs.
69
74
  #
75
+ # DEPRECATED
76
+ #
77
+ # Use build instead
78
+ #
70
79
  # Arguments:
71
80
  # * name: +Symbol+ or +String+
72
81
  # The name of the factory that should be used.
@@ -79,6 +88,7 @@ module FactoryGirl
79
88
  # Returns: +Object+
80
89
  # An object with generated attributes stubbed out.
81
90
  def build_stubbed(name, *traits_and_overrides, &block)
91
+ $stderr.puts "DEPRECATION WARNING: FactoryGirl.build_stubbed is deprecated; use FactoryGirl.build instead."
82
92
  run_factory_girl_proxy(name, traits_and_overrides, Proxy::Stub, &block)
83
93
  end
84
94
 
@@ -110,6 +110,10 @@ module FactoryGirl
110
110
  end
111
111
 
112
112
  # Alias for FactoryGirl.attributes_for
113
+ #
114
+ # DEPRECATED
115
+ #
116
+ # Use build or create instead, calling attributes on the result
113
117
  def self.attributes_for(name, overrides = {})
114
118
  FactoryGirl.attributes_for(name, overrides)
115
119
  end
@@ -125,6 +129,10 @@ module FactoryGirl
125
129
  end
126
130
 
127
131
  # Alias for FactoryGirl.build_stubbed.
132
+ #
133
+ # DEPRECATED
134
+ #
135
+ # Use build instead
128
136
  def self.stub(name, overrides = {})
129
137
  FactoryGirl.build_stubbed(name, overrides)
130
138
  end
@@ -1,4 +1,4 @@
1
1
  module FactoryGirl
2
- VERSION = "2.4.0"
2
+ VERSION = "2.4.1"
3
3
  end
4
4
 
@@ -286,3 +286,29 @@ describe "traits and dynamic attributes that are applied simultaneously" do
286
286
  its(:email) { should == "John@example.com" }
287
287
  its(:combined) { should == "John <John@example.com>" }
288
288
  end
289
+
290
+ describe "applying inline traits" do
291
+ before do
292
+ define_model("User") do
293
+ has_many :posts
294
+ end
295
+
296
+ define_model("Post", :user_id => :integer) do
297
+ belongs_to :user
298
+ end
299
+
300
+ FactoryGirl.define do
301
+ factory :user do
302
+ trait :with_post do
303
+ posts { [ Post.new ] }
304
+ end
305
+ end
306
+ end
307
+ end
308
+
309
+ it "applies traits only to the instance generated for that call" do
310
+ FactoryGirl.create(:user, :with_post).posts.should_not be_empty
311
+ FactoryGirl.create(:user).posts.should be_empty
312
+ FactoryGirl.create(:user, :with_post).posts.should_not be_empty
313
+ end
314
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-13 00:00:00.000000000 Z
12
+ date: 2012-01-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70203557477340 !ruby/object:Gem::Requirement
16
+ requirement: &70308695491200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70203557477340
24
+ version_requirements: *70308695491200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70203557470340 !ruby/object:Gem::Requirement
27
+ requirement: &70308695490500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70203557470340
35
+ version_requirements: *70308695490500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &70203557469400 !ruby/object:Gem::Requirement
38
+ requirement: &70308695489400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70203557469400
46
+ version_requirements: *70308695489400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: timecop
49
- requirement: &70203557468720 !ruby/object:Gem::Requirement
49
+ requirement: &70308695489000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70203557468720
57
+ version_requirements: *70308695489000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70203557467720 !ruby/object:Gem::Requirement
60
+ requirement: &70308695488540 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70203557467720
68
+ version_requirements: *70308695488540
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: aruba
71
- requirement: &70203557466180 !ruby/object:Gem::Requirement
71
+ requirement: &70308695488000 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70203557466180
79
+ version_requirements: *70308695488000
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: mocha
82
- requirement: &70203557465420 !ruby/object:Gem::Requirement
82
+ requirement: &70308695487580 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70203557465420
90
+ version_requirements: *70308695487580
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bourne
93
- requirement: &70203557464620 !ruby/object:Gem::Requirement
93
+ requirement: &70308695481180 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70203557464620
101
+ version_requirements: *70308695481180
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: appraisal
104
- requirement: &70203557456720 !ruby/object:Gem::Requirement
104
+ requirement: &70308695480520 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.3.8
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70203557456720
112
+ version_requirements: *70308695480520
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: sqlite3-ruby
115
- requirement: &70203557455540 !ruby/object:Gem::Requirement
115
+ requirement: &70308695479860 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70203557455540
123
+ version_requirements: *70308695479860
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: yard
126
- requirement: &70203557454880 !ruby/object:Gem::Requirement
126
+ requirement: &70308695479120 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70203557454880
134
+ version_requirements: *70308695479120
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: bluecloth
137
- requirement: &70203557453700 !ruby/object:Gem::Requirement
137
+ requirement: &70308695478620 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70203557453700
145
+ version_requirements: *70308695478620
146
146
  description: ! "factory_girl provides a framework and DSL for defining and\n using
147
147
  factories - less error-prone, more explicit, and\n all-around
148
148
  easier to work with than fixtures."