factory_girl 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +4 -0
- data/Gemfile.lock +1 -1
- data/factory_girl.gemspec +3 -2
- data/gemfiles/2.3.gemfile.lock +1 -1
- data/gemfiles/3.0.gemfile.lock +1 -1
- data/gemfiles/3.1.gemfile.lock +1 -1
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/lib/factory_girl/attribute_assigner.rb +2 -2
- data/lib/factory_girl/version.rb +1 -1
- data/spec/acceptance/nested_attributes_spec.rb +32 -0
- data/spec/acceptance/transient_attributes_spec.rb +33 -0
- metadata +32 -27
data/Changelog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
2.6.4 (March 16, 2012)
|
2
|
+
Do not ignore names of transient attributes
|
3
|
+
Ensure attributes set on instance are calculated uniquely
|
4
|
+
|
1
5
|
2.6.3 (March 9, 2012)
|
2
6
|
Fix issue with traits not being present the first time a factory is accessed
|
3
7
|
Update available Cucumber step definitions to not require a trialing colon
|
data/Gemfile.lock
CHANGED
data/factory_girl.gemspec
CHANGED
@@ -16,8 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
18
18
|
|
19
|
-
s.authors = ["Joe Ferris"]
|
20
|
-
s.email =
|
19
|
+
s.authors = ["Josh Clayton", "Joe Ferris"]
|
20
|
+
s.email = ["jclayton@thoughtbot.com", "jferris@thoughtbot.com"]
|
21
|
+
|
21
22
|
s.homepage = "https://github.com/thoughtbot/factory_girl"
|
22
23
|
|
23
24
|
s.add_dependency("activesupport", ">= 2.3.9")
|
data/gemfiles/2.3.gemfile.lock
CHANGED
data/gemfiles/3.0.gemfile.lock
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
@@ -37,7 +37,7 @@ module FactoryGirl
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def attributes_to_set_on_instance
|
40
|
-
attribute_names_to_assign - @attribute_names_assigned
|
40
|
+
(attribute_names_to_assign - @attribute_names_assigned).uniq
|
41
41
|
end
|
42
42
|
|
43
43
|
def attributes_to_set_on_hash
|
@@ -66,7 +66,7 @@ module FactoryGirl
|
|
66
66
|
|
67
67
|
def alias_names_to_ignore
|
68
68
|
@attribute_list.reject(&:ignored).map do |attribute|
|
69
|
-
override_names.map {|override| attribute.name if attribute.alias_for?(override) && attribute.name != override }
|
69
|
+
override_names.map {|override| attribute.name if attribute.alias_for?(override) && attribute.name != override && !ignored_attribute_names.include?(override) }
|
70
70
|
end.flatten.compact
|
71
71
|
end
|
72
72
|
end
|
data/lib/factory_girl/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "association assignment from nested attributes" do
|
4
|
+
before do
|
5
|
+
define_model("Post", :title => :string) do
|
6
|
+
has_many :comments
|
7
|
+
accepts_nested_attributes_for :comments
|
8
|
+
end
|
9
|
+
|
10
|
+
define_model("Comment", :post_id => :integer, :body => :text) do
|
11
|
+
belongs_to :post
|
12
|
+
end
|
13
|
+
|
14
|
+
FactoryGirl.define do
|
15
|
+
factory :post do
|
16
|
+
comments_attributes { [FactoryGirl.attributes_for(:comment), FactoryGirl.attributes_for(:comment)] }
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :comment do
|
20
|
+
sequence(:body) {|n| "Body #{n}" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "assigns the correct amount of comments" do
|
26
|
+
FactoryGirl.create(:post).comments.count.should == 2
|
27
|
+
end
|
28
|
+
|
29
|
+
it "assigns the correct amount of comments when overridden" do
|
30
|
+
FactoryGirl.create(:post, :comments_attributes => [FactoryGirl.attributes_for(:comment)]).comments.count.should == 1
|
31
|
+
end
|
32
|
+
end
|
@@ -108,3 +108,36 @@ describe "transient sequences" do
|
|
108
108
|
FactoryGirl.build(:user).name.should == "John Doe 2"
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
describe "assigning values from a transient attribute" do
|
113
|
+
before do
|
114
|
+
define_class("User") do
|
115
|
+
attr_accessor :foo_id, :foo_name
|
116
|
+
end
|
117
|
+
|
118
|
+
define_class("Foo") do
|
119
|
+
attr_accessor :id, :name
|
120
|
+
def initialize(id, name)
|
121
|
+
@id = id
|
122
|
+
@name = name
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
FactoryGirl.define do
|
127
|
+
factory :user do
|
128
|
+
ignore do
|
129
|
+
foo { Foo.new('id-of-foo', 'name-of-foo')}
|
130
|
+
end
|
131
|
+
|
132
|
+
foo_id { foo.id }
|
133
|
+
foo_name { foo.name }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it "does not ignore an _id attribute that is an alias for a transient attribute" do
|
139
|
+
user = FactoryGirl.build(:user, :foo => Foo.new('passed-in-id-of-foo', 'passed-in-name-of-foo'))
|
140
|
+
user.foo_id.should == 'passed-in-id-of-foo'
|
141
|
+
user.foo_name.should == 'passed-in-name-of-foo'
|
142
|
+
end
|
143
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
+
- Josh Clayton
|
8
9
|
- Joe Ferris
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: activesupport
|
16
|
-
requirement: &
|
17
|
+
requirement: &70301124622100 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: 2.3.9
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *70301124622100
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: rspec
|
27
|
-
requirement: &
|
28
|
+
requirement: &70301124620680 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
version: '2.0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *70301124620680
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
38
|
name: cucumber
|
38
|
-
requirement: &
|
39
|
+
requirement: &70301124619560 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ~>
|
@@ -43,10 +44,10 @@ dependencies:
|
|
43
44
|
version: 1.0.0
|
44
45
|
type: :development
|
45
46
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
+
version_requirements: *70301124619560
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: timecop
|
49
|
-
requirement: &
|
50
|
+
requirement: &70301124635340 !ruby/object:Gem::Requirement
|
50
51
|
none: false
|
51
52
|
requirements:
|
52
53
|
- - ! '>='
|
@@ -54,10 +55,10 @@ dependencies:
|
|
54
55
|
version: '0'
|
55
56
|
type: :development
|
56
57
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
+
version_requirements: *70301124635340
|
58
59
|
- !ruby/object:Gem::Dependency
|
59
60
|
name: rcov
|
60
|
-
requirement: &
|
61
|
+
requirement: &70301124634520 !ruby/object:Gem::Requirement
|
61
62
|
none: false
|
62
63
|
requirements:
|
63
64
|
- - ! '>='
|
@@ -65,10 +66,10 @@ dependencies:
|
|
65
66
|
version: '0'
|
66
67
|
type: :development
|
67
68
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
+
version_requirements: *70301124634520
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: aruba
|
71
|
-
requirement: &
|
72
|
+
requirement: &70301124633060 !ruby/object:Gem::Requirement
|
72
73
|
none: false
|
73
74
|
requirements:
|
74
75
|
- - ! '>='
|
@@ -76,10 +77,10 @@ dependencies:
|
|
76
77
|
version: '0'
|
77
78
|
type: :development
|
78
79
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
+
version_requirements: *70301124633060
|
80
81
|
- !ruby/object:Gem::Dependency
|
81
82
|
name: mocha
|
82
|
-
requirement: &
|
83
|
+
requirement: &70301124631940 !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
85
86
|
- - ! '>='
|
@@ -87,10 +88,10 @@ dependencies:
|
|
87
88
|
version: '0'
|
88
89
|
type: :development
|
89
90
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
+
version_requirements: *70301124631940
|
91
92
|
- !ruby/object:Gem::Dependency
|
92
93
|
name: bourne
|
93
|
-
requirement: &
|
94
|
+
requirement: &70301124630000 !ruby/object:Gem::Requirement
|
94
95
|
none: false
|
95
96
|
requirements:
|
96
97
|
- - ! '>='
|
@@ -98,10 +99,10 @@ dependencies:
|
|
98
99
|
version: '0'
|
99
100
|
type: :development
|
100
101
|
prerelease: false
|
101
|
-
version_requirements: *
|
102
|
+
version_requirements: *70301124630000
|
102
103
|
- !ruby/object:Gem::Dependency
|
103
104
|
name: appraisal
|
104
|
-
requirement: &
|
105
|
+
requirement: &70301124629000 !ruby/object:Gem::Requirement
|
105
106
|
none: false
|
106
107
|
requirements:
|
107
108
|
- - ~>
|
@@ -109,10 +110,10 @@ dependencies:
|
|
109
110
|
version: 0.3.8
|
110
111
|
type: :development
|
111
112
|
prerelease: false
|
112
|
-
version_requirements: *
|
113
|
+
version_requirements: *70301124629000
|
113
114
|
- !ruby/object:Gem::Dependency
|
114
115
|
name: sqlite3-ruby
|
115
|
-
requirement: &
|
116
|
+
requirement: &70301124628220 !ruby/object:Gem::Requirement
|
116
117
|
none: false
|
117
118
|
requirements:
|
118
119
|
- - ! '>='
|
@@ -120,10 +121,10 @@ dependencies:
|
|
120
121
|
version: '0'
|
121
122
|
type: :development
|
122
123
|
prerelease: false
|
123
|
-
version_requirements: *
|
124
|
+
version_requirements: *70301124628220
|
124
125
|
- !ruby/object:Gem::Dependency
|
125
126
|
name: yard
|
126
|
-
requirement: &
|
127
|
+
requirement: &70301124642860 !ruby/object:Gem::Requirement
|
127
128
|
none: false
|
128
129
|
requirements:
|
129
130
|
- - ! '>='
|
@@ -131,10 +132,10 @@ dependencies:
|
|
131
132
|
version: '0'
|
132
133
|
type: :development
|
133
134
|
prerelease: false
|
134
|
-
version_requirements: *
|
135
|
+
version_requirements: *70301124642860
|
135
136
|
- !ruby/object:Gem::Dependency
|
136
137
|
name: bluecloth
|
137
|
-
requirement: &
|
138
|
+
requirement: &70301124641880 !ruby/object:Gem::Requirement
|
138
139
|
none: false
|
139
140
|
requirements:
|
140
141
|
- - ! '>='
|
@@ -142,11 +143,13 @@ dependencies:
|
|
142
143
|
version: '0'
|
143
144
|
type: :development
|
144
145
|
prerelease: false
|
145
|
-
version_requirements: *
|
146
|
+
version_requirements: *70301124641880
|
146
147
|
description: ! "factory_girl provides a framework and DSL for defining and\n using
|
147
148
|
factories - less error-prone, more explicit, and\n all-around
|
148
149
|
easier to work with than fixtures."
|
149
|
-
email:
|
150
|
+
email:
|
151
|
+
- jclayton@thoughtbot.com
|
152
|
+
- jferris@thoughtbot.com
|
150
153
|
executables: []
|
151
154
|
extensions: []
|
152
155
|
extra_rdoc_files: []
|
@@ -248,6 +251,7 @@ files:
|
|
248
251
|
- spec/acceptance/initialize_with_spec.rb
|
249
252
|
- spec/acceptance/modify_factories_spec.rb
|
250
253
|
- spec/acceptance/modify_inherited_spec.rb
|
254
|
+
- spec/acceptance/nested_attributes_spec.rb
|
251
255
|
- spec/acceptance/overrides_spec.rb
|
252
256
|
- spec/acceptance/parent_spec.rb
|
253
257
|
- spec/acceptance/sequence_spec.rb
|
@@ -353,6 +357,7 @@ test_files:
|
|
353
357
|
- spec/acceptance/initialize_with_spec.rb
|
354
358
|
- spec/acceptance/modify_factories_spec.rb
|
355
359
|
- spec/acceptance/modify_inherited_spec.rb
|
360
|
+
- spec/acceptance/nested_attributes_spec.rb
|
356
361
|
- spec/acceptance/overrides_spec.rb
|
357
362
|
- spec/acceptance/parent_spec.rb
|
358
363
|
- spec/acceptance/sequence_spec.rb
|