factory_girl 2.6.4 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.travis.yml +0 -3
  2. data/Appraisals +0 -4
  3. data/Changelog +0 -4
  4. data/Gemfile.lock +7 -4
  5. data/Rakefile +0 -12
  6. data/factory_girl.gemspec +3 -3
  7. data/features/support/env.rb +3 -0
  8. data/gemfiles/3.0.gemfile.lock +8 -4
  9. data/gemfiles/3.1.gemfile.lock +7 -4
  10. data/gemfiles/3.2.gemfile.lock +7 -4
  11. data/lib/factory_girl.rb +0 -1
  12. data/lib/factory_girl/attribute_assigner.rb +2 -2
  13. data/lib/factory_girl/declaration.rb +0 -5
  14. data/lib/factory_girl/definition.rb +1 -1
  15. data/lib/factory_girl/definition_proxy.rb +1 -1
  16. data/lib/factory_girl/errors.rb +1 -1
  17. data/lib/factory_girl/evaluator.rb +2 -5
  18. data/lib/factory_girl/factory.rb +4 -20
  19. data/lib/factory_girl/null_factory.rb +1 -2
  20. data/lib/factory_girl/null_object.rb +3 -15
  21. data/lib/factory_girl/sequence.rb +0 -4
  22. data/lib/factory_girl/step_definitions.rb +1 -1
  23. data/lib/factory_girl/syntax/blueprint.rb +2 -2
  24. data/lib/factory_girl/syntax/default.rb +1 -1
  25. data/lib/factory_girl/syntax/generate.rb +1 -1
  26. data/lib/factory_girl/syntax/make.rb +1 -1
  27. data/lib/factory_girl/syntax/vintage.rb +13 -32
  28. data/lib/factory_girl/trait.rb +1 -1
  29. data/lib/factory_girl/version.rb +1 -1
  30. data/spec/acceptance/aliases_spec.rb +3 -3
  31. data/spec/acceptance/attribute_aliases_spec.rb +5 -5
  32. data/spec/acceptance/attribute_existing_on_object_spec.rb +5 -5
  33. data/spec/acceptance/attributes_for_spec.rb +8 -8
  34. data/spec/acceptance/attributes_from_instance_spec.rb +5 -5
  35. data/spec/acceptance/attributes_ordered_spec.rb +5 -5
  36. data/spec/acceptance/build_list_spec.rb +2 -2
  37. data/spec/acceptance/build_spec.rb +6 -6
  38. data/spec/acceptance/build_stubbed_spec.rb +7 -7
  39. data/spec/acceptance/callbacks_spec.rb +3 -3
  40. data/spec/acceptance/create_list_spec.rb +6 -6
  41. data/spec/acceptance/create_spec.rb +13 -42
  42. data/spec/acceptance/define_child_before_parent_spec.rb +2 -2
  43. data/spec/acceptance/definition_spec.rb +2 -2
  44. data/spec/acceptance/initialize_with_spec.rb +7 -7
  45. data/spec/acceptance/modify_factories_spec.rb +5 -5
  46. data/spec/acceptance/modify_inherited_spec.rb +8 -8
  47. data/spec/acceptance/overrides_spec.rb +4 -4
  48. data/spec/acceptance/parent_spec.rb +3 -3
  49. data/spec/acceptance/stub_spec.rb +12 -41
  50. data/spec/acceptance/syntax/blueprint_spec.rb +6 -3
  51. data/spec/acceptance/syntax/generate_spec.rb +4 -4
  52. data/spec/acceptance/syntax/make_spec.rb +3 -3
  53. data/spec/acceptance/syntax/sham_spec.rb +5 -5
  54. data/spec/acceptance/syntax/vintage_spec.rb +28 -46
  55. data/spec/acceptance/traits_spec.rb +33 -33
  56. data/spec/acceptance/transient_attributes_spec.rb +7 -59
  57. data/spec/factory_girl/aliases_spec.rb +1 -1
  58. data/spec/factory_girl/attribute/association_spec.rb +2 -2
  59. data/spec/factory_girl/attribute/dynamic_spec.rb +2 -2
  60. data/spec/factory_girl/declaration_list_spec.rb +7 -7
  61. data/spec/factory_girl/definition_proxy_spec.rb +6 -6
  62. data/spec/factory_girl/definition_spec.rb +3 -3
  63. data/spec/factory_girl/evaluator_class_definer_spec.rb +5 -5
  64. data/spec/factory_girl/factory_spec.rb +19 -69
  65. data/spec/factory_girl/null_factory_spec.rb +4 -5
  66. data/spec/factory_girl/registry_spec.rb +1 -1
  67. data/spec/factory_girl/sequence_spec.rb +3 -4
  68. data/spec/factory_girl/strategy/attributes_for_spec.rb +2 -2
  69. data/spec/factory_girl/strategy/build_spec.rb +1 -1
  70. data/spec/factory_girl/strategy/create_spec.rb +1 -1
  71. data/spec/factory_girl/strategy/stub_spec.rb +2 -2
  72. data/spec/spec_helper.rb +3 -0
  73. data/spec/support/macros/define_constant.rb +2 -2
  74. data/spec/support/shared_examples/strategy.rb +12 -22
  75. metadata +32 -41
  76. data/gemfiles/2.3.gemfile.lock +0 -72
  77. data/lib/factory_girl/deprecated.rb +0 -18
  78. data/spec/acceptance/default_strategy_spec.rb +0 -24
  79. data/spec/acceptance/nested_attributes_spec.rb +0 -32
  80. data/spec/factory_girl/deprecated_spec.rb +0 -45
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe "transient attributes" do
4
4
  before do
5
- define_model("User", :name => :string, :email => :string)
5
+ define_model("User", name: :string, email: :string)
6
6
 
7
7
  FactoryGirl.define do
8
8
  sequence(:name) {|n| "John #{n}" }
@@ -25,7 +25,7 @@ describe "transient attributes" do
25
25
  end
26
26
 
27
27
  context "returning attributes for a factory" do
28
- subject { FactoryGirl.attributes_for(:user, :rockstar => true) }
28
+ subject { FactoryGirl.attributes_for(:user, rockstar: true) }
29
29
  it { should_not have_key(:four) }
30
30
  it { should_not have_key(:rockstar) }
31
31
  it { should_not have_key(:upcased) }
@@ -34,10 +34,10 @@ describe "transient attributes" do
34
34
  end
35
35
 
36
36
  context "with a transient variable assigned" do
37
- let(:rockstar) { FactoryGirl.create(:user, :rockstar => true, :four => "1234") }
38
- let(:rockstar_with_name) { FactoryGirl.create(:user, :name => "Jane Doe", :rockstar => true) }
39
- let(:upcased_rockstar) { FactoryGirl.create(:user, :rockstar => true, :upcased => true) }
40
- let(:groupie) { FactoryGirl.create(:user, :rockstar => false) }
37
+ let(:rockstar) { FactoryGirl.create(:user, rockstar: true, four: "1234") }
38
+ let(:rockstar_with_name) { FactoryGirl.create(:user, name: "Jane Doe", rockstar: true) }
39
+ let(:upcased_rockstar) { FactoryGirl.create(:user, rockstar: true, upcased: true) }
40
+ let(:groupie) { FactoryGirl.create(:user, rockstar: false) }
41
41
 
42
42
  it "generates the correct attributes on a rockstar" do
43
43
  rockstar.name.should == "John 1 - Rockstar"
@@ -69,28 +69,9 @@ describe "transient attributes" do
69
69
  end
70
70
  end
71
71
 
72
- describe "deprecated way of ignoring attributes" do
73
- before do
74
- define_model("User", :name => :string)
75
-
76
- FactoryGirl.define do
77
- factory :user do
78
- rockstar(false).ignore
79
-
80
- name { "John Doe#{" Rockstar" if rockstar}" }
81
- end
82
- end
83
- end
84
-
85
- it "assigns attributes correctly" do
86
- FactoryGirl.build(:user, :rockstar => true).name.should == "John Doe Rockstar"
87
- FactoryGirl.build(:user).name.should == "John Doe"
88
- end
89
- end
90
-
91
72
  describe "transient sequences" do
92
73
  before do
93
- define_model("User", :name => :string)
74
+ define_model("User", name: :string)
94
75
 
95
76
  FactoryGirl.define do
96
77
  factory :user do
@@ -108,36 +89,3 @@ describe "transient sequences" do
108
89
  FactoryGirl.build(:user).name.should == "John Doe 2"
109
90
  end
110
91
  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
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  describe Factory, "after defining an alias" do
23
23
  before do
24
- Factory.alias(/(.*)_suffix/, '\1')
24
+ FactoryGirl.aliases << [/(.*)_suffix/, '\1']
25
25
  end
26
26
 
27
27
  subject { FactoryGirl.aliases_for(:test_suffix) }
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe FactoryGirl::Attribute::Association do
4
4
  let(:name) { :author }
5
5
  let(:factory) { :user }
6
- let(:overrides) { { :first_name => "John" } }
6
+ let(:overrides) { { first_name: "John" } }
7
7
  let(:association) { stub("association") }
8
8
 
9
9
  subject { FactoryGirl::Attribute::Association.new(name, factory, overrides) }
10
- before { subject.stubs(:association => association) }
10
+ before { subject.stubs(association: association) }
11
11
 
12
12
  it { should be_association }
13
13
  its(:name) { should == name }
@@ -29,7 +29,7 @@ describe FactoryGirl::Attribute::Dynamic do
29
29
  let(:result) { "other attribute value" }
30
30
 
31
31
  before do
32
- subject.stubs(:attribute_defined_on_attribute => result)
32
+ subject.stubs(attribute_defined_on_attribute: result)
33
33
  end
34
34
 
35
35
  it "evaluates the attribute from the attribute" do
@@ -38,7 +38,7 @@ describe FactoryGirl::Attribute::Dynamic do
38
38
  end
39
39
 
40
40
  context "with a block returning a sequence" do
41
- let(:block) { lambda { Factory.sequence(:email) } }
41
+ let(:block) { lambda { FactoryGirl.register_sequence(FactoryGirl::Sequence.new(:email, 1) {|n| "foo#{n}" }) } }
42
42
 
43
43
  it "raises a sequence abuse error" do
44
44
  expect { subject.to_proc.call }.to raise_error(FactoryGirl::SequenceAbuseError)
@@ -4,17 +4,17 @@ describe FactoryGirl::DeclarationList, "#attribute_list" do
4
4
  let(:static_attribute_1) { stub("static attribute 1") }
5
5
  let(:static_attribute_2) { stub("static attribute 2") }
6
6
  let(:dynamic_attribute_1) { stub("dynamic attribute 1") }
7
- let(:static_declaration) { stub("static declaration", :to_attributes => [static_attribute_1, static_attribute_2]) }
8
- let(:dynamic_declaration) { stub("static declaration", :to_attributes => [dynamic_attribute_1]) }
7
+ let(:static_declaration) { stub("static declaration", to_attributes: [static_attribute_1, static_attribute_2]) }
8
+ let(:dynamic_declaration) { stub("static declaration", to_attributes: [dynamic_attribute_1]) }
9
9
 
10
10
  it "returns an AttributeList" do
11
11
  subject.attribute_list.should be_a(FactoryGirl::AttributeList)
12
12
  end
13
13
 
14
- let(:attribute_list) { stub("attribute list", :define_attribute => true) }
14
+ let(:attribute_list) { stub("attribute list", define_attribute: true) }
15
15
 
16
16
  it "defines each attribute on the attribute list" do
17
- FactoryGirl::AttributeList.stubs(:new => attribute_list)
17
+ FactoryGirl::AttributeList.stubs(new: attribute_list)
18
18
 
19
19
  subject.declare_attribute(static_declaration)
20
20
  subject.declare_attribute(dynamic_declaration)
@@ -32,9 +32,9 @@ describe FactoryGirl::DeclarationList, "#attribute_list" do
32
32
  end
33
33
 
34
34
  describe FactoryGirl::DeclarationList, "#declare_attribute" do
35
- let(:declaration_1) { stub("declaration", :name => "declaration 1") }
36
- let(:declaration_2) { stub("declaration", :name => "declaration 2") }
37
- let(:declaration_with_same_name) { stub("declaration", :name => "declaration 1") }
35
+ let(:declaration_1) { stub("declaration", name: "declaration 1") }
36
+ let(:declaration_2) { stub("declaration", name: "declaration 2") }
37
+ let(:declaration_with_same_name) { stub("declaration", name: "declaration 1") }
38
38
 
39
39
  context "when not overridable" do
40
40
  it "adds the declaration to the list" do
@@ -67,8 +67,8 @@ describe FactoryGirl::DefinitionProxy, "#method_missing" do
67
67
  end
68
68
 
69
69
  it "declares an association when :factory is passed" do
70
- proxy.author :factory => :user
71
- subject.should have_association_declaration(:author).with_options(:factory => :user)
70
+ proxy.author factory: :user
71
+ subject.should have_association_declaration(:author).with_options(factory: :user)
72
72
  end
73
73
 
74
74
  it "declares a static attribute" do
@@ -116,8 +116,8 @@ describe FactoryGirl::DefinitionProxy, "#association" do
116
116
  end
117
117
 
118
118
  it "declares an association with options" do
119
- proxy.association(:association_name, { :name => "Awesome" })
120
- subject.should have_association_declaration(:association_name).with_options(:name => "Awesome")
119
+ proxy.association(:association_name, { name: "Awesome" })
120
+ subject.should have_association_declaration(:association_name).with_options(name: "Awesome")
121
121
  end
122
122
  end
123
123
 
@@ -163,8 +163,8 @@ describe FactoryGirl::DefinitionProxy, "#factory" do
163
163
  end
164
164
 
165
165
  it "with options" do
166
- proxy.factory(:child, { :awesome => true })
167
- proxy.child_factories.should include([:child, { :awesome => true }, nil])
166
+ proxy.factory(:child, { awesome: true })
167
+ proxy.child_factories.should include([:child, { awesome: true }, nil])
168
168
  end
169
169
 
170
170
  it "with a block" do
@@ -17,8 +17,8 @@ describe FactoryGirl::Definition, "with a name" do
17
17
  end
18
18
 
19
19
  describe FactoryGirl::Definition, "#overridable" do
20
- let(:list) { stub("declaration list", :overridable => true) }
21
- before { FactoryGirl::DeclarationList.stubs(:new => list) }
20
+ let(:list) { stub("declaration list", overridable: true) }
21
+ before { FactoryGirl::DeclarationList.stubs(new: list) }
22
22
 
23
23
  it "sets the declaration list as overridable" do
24
24
  subject.overridable.should == subject
@@ -70,7 +70,7 @@ describe FactoryGirl::Definition, "#processing_order" do
70
70
 
71
71
  before do
72
72
  subject.define_trait(female_trait)
73
- FactoryGirl.stubs(:trait_by_name => admin_trait)
73
+ FactoryGirl.stubs(trait_by_name: admin_trait)
74
74
  end
75
75
 
76
76
  context "without base traits" do
@@ -1,14 +1,14 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe FactoryGirl::EvaluatorClassDefiner do
4
- let(:simple_attribute) { stub("simple attribute", :name => :simple, :to_proc => lambda { 1 }) }
5
- let(:relative_attribute) { stub("relative attribute", :name => :relative, :to_proc => lambda { simple + 1 }) }
6
- let(:attribute_that_raises_a_second_time) { stub("attribute that would raise without a cache", :name => :raises_without_proper_cache, :to_proc => lambda { raise "failed" if @run; @run = true; nil }) }
4
+ let(:simple_attribute) { stub("simple attribute", name: :simple, to_proc: lambda { 1 }) }
5
+ let(:relative_attribute) { stub("relative attribute", name: :relative, to_proc: lambda { simple + 1 }) }
6
+ let(:attribute_that_raises_a_second_time) { stub("attribute that would raise without a cache", name: :raises_without_proper_cache, to_proc: lambda { raise "failed" if @run; @run = true; nil }) }
7
7
  let(:callbacks) { [stub("callback 1"), stub("callback 2")] }
8
8
 
9
9
  let(:attributes) { [simple_attribute, relative_attribute, attribute_that_raises_a_second_time] }
10
10
  let(:class_definer) { FactoryGirl::EvaluatorClassDefiner.new(attributes, callbacks, FactoryGirl::Evaluator) }
11
- let(:evaluator) { class_definer.evaluator_class.new(stub("build strategy", :add_observer => true)) }
11
+ let(:evaluator) { class_definer.evaluator_class.new(stub("build strategy", add_observer: true)) }
12
12
 
13
13
  it "returns an evaluator when accessing the evaluator class" do
14
14
  evaluator.should be_a(FactoryGirl::Evaluator)
@@ -38,7 +38,7 @@ describe FactoryGirl::EvaluatorClassDefiner do
38
38
 
39
39
  context "with a custom evaluator as a parent class" do
40
40
  let(:child_callbacks) { [stub("child callback 1"), stub("child callback 2")] }
41
- let(:child_attributes) { [stub("child attribute", :name => :simple, :to_proc => lambda { 1 })] }
41
+ let(:child_attributes) { [stub("child attribute", name: :simple, to_proc: lambda { 1 })] }
42
42
  let(:child_definer) { FactoryGirl::EvaluatorClassDefiner.new(child_attributes, child_callbacks, class_definer.evaluator_class) }
43
43
 
44
44
  subject { child_definer.evaluator_class }
@@ -12,21 +12,13 @@ describe FactoryGirl::Factory do
12
12
  @factory.name.should == @name
13
13
  end
14
14
 
15
- it "responds to factory_name" do
16
- @factory.factory_name.should == @name
17
- end
18
-
19
15
  it "has a build class" do
20
16
  @factory.build_class.should == @class
21
17
  end
22
18
 
23
- it "has a default strategy" do
24
- @factory.default_strategy.should == :create
25
- end
26
-
27
19
  it "passes a custom creation block" do
28
- strategy = stub("strategy", :result => nil, :add_observer => true)
29
- FactoryGirl::Strategy::Build.stubs(:new => strategy)
20
+ strategy = stub("strategy", result: nil, add_observer: true)
21
+ FactoryGirl::Strategy::Build.stubs(new: strategy)
30
22
  block = lambda {}
31
23
  factory = FactoryGirl::Factory.new(:object)
32
24
  factory.to_create(&block)
@@ -56,7 +48,7 @@ describe FactoryGirl::Factory do
56
48
  factory.declare_attribute(association_on_parent)
57
49
  FactoryGirl.register_factory(factory)
58
50
 
59
- child_factory = FactoryGirl::Factory.new(:child_post, :parent => :post)
51
+ child_factory = FactoryGirl::Factory.new(:child_post, parent: :post)
60
52
  child_factory.declare_attribute(association_on_child)
61
53
 
62
54
  child_factory.associations.map(&:name).should == [:association_on_parent, :association_on_child]
@@ -94,9 +86,9 @@ describe FactoryGirl::Factory do
94
86
  describe "overriding an attribute with an alias" do
95
87
  before do
96
88
  @factory.declare_attribute(FactoryGirl::Declaration::Static.new(:test, 'original'))
97
- Factory.alias(/(.*)_alias/, '\1')
89
+ FactoryGirl.aliases << [/(.*)_alias/, '\1']
98
90
  @result = @factory.run(FactoryGirl::Strategy::AttributesFor,
99
- :test_alias => 'new')
91
+ test_alias: 'new')
100
92
  end
101
93
 
102
94
  it "uses the passed in value for the alias" do
@@ -113,20 +105,20 @@ describe FactoryGirl::Factory do
113
105
  end
114
106
 
115
107
  it "creates a new factory using the class of the parent" do
116
- child = FactoryGirl::Factory.new(:child, :parent => @factory.name)
108
+ child = FactoryGirl::Factory.new(:child, parent: @factory.name)
117
109
  child.compile
118
110
  child.build_class.should == @factory.build_class
119
111
  end
120
112
 
121
113
  it "creates a new factory while overriding the parent class" do
122
- child = FactoryGirl::Factory.new(:child, :class => String, :parent => @factory.name)
114
+ child = FactoryGirl::Factory.new(:child, class: String, parent: @factory.name)
123
115
  child.compile
124
116
  child.build_class.should == String
125
117
  end
126
118
  end
127
119
 
128
120
  describe FactoryGirl::Factory, "when defined with a custom class" do
129
- subject { FactoryGirl::Factory.new(:author, :class => Float) }
121
+ subject { FactoryGirl::Factory.new(:author, class: Float) }
130
122
  its(:build_class) { should == Float }
131
123
  end
132
124
 
@@ -142,7 +134,7 @@ describe FactoryGirl::Factory, "when given a class that overrides #to_s" do
142
134
  end
143
135
  end
144
136
 
145
- subject { FactoryGirl::Factory.new(:overriding_class, :class => Overriding::Class) }
137
+ subject { FactoryGirl::Factory.new(:overriding_class, class: Overriding::Class) }
146
138
 
147
139
  it "sets build_class correctly" do
148
140
  subject.build_class.should == overriding_class
@@ -160,7 +152,7 @@ describe FactoryGirl::Factory, "when defined with a class instead of a name" do
160
152
  end
161
153
 
162
154
  describe FactoryGirl::Factory, "when defined with a custom class name" do
163
- subject { FactoryGirl::Factory.new(:author, :class => :argument_error) }
155
+ subject { FactoryGirl::Factory.new(:author, class: :argument_error) }
164
156
  its(:build_class) { should == ArgumentError }
165
157
  end
166
158
 
@@ -191,7 +183,7 @@ describe FactoryGirl::Factory, "for namespaced class" do
191
183
  end
192
184
 
193
185
  context "with a namespaced class with Namespace::Class syntax" do
194
- subject { FactoryGirl::Factory.new(name, :class => "Admin::Settings") }
186
+ subject { FactoryGirl::Factory.new(name, class: "Admin::Settings") }
195
187
 
196
188
  it "sets build_class correctly" do
197
189
  subject.build_class.should == settings_class
@@ -199,7 +191,7 @@ describe FactoryGirl::Factory, "for namespaced class" do
199
191
  end
200
192
 
201
193
  context "with a namespaced class with namespace/class syntax" do
202
- subject { FactoryGirl::Factory.new(name, :class => "admin/settings") }
194
+ subject { FactoryGirl::Factory.new(name, class: "admin/settings") }
203
195
 
204
196
  it "sets build_class correctly" do
205
197
  subject.build_class.should == settings_class
@@ -207,48 +199,6 @@ describe FactoryGirl::Factory, "for namespaced class" do
207
199
  end
208
200
  end
209
201
 
210
- describe FactoryGirl::Factory do
211
- let(:factory_with_non_existent_strategy) do
212
- FactoryGirl::Factory.new(:object, :default_strategy => :nonexistent) { }
213
- end
214
-
215
- let(:factory_with_stub_strategy) do
216
- FactoryGirl::Factory.new(:object, :default_strategy => :stub)
217
- end
218
-
219
- before do
220
- define_class("User")
221
- define_class("Admin", User)
222
- FactoryGirl.register_factory(factory_with_stub_strategy)
223
- end
224
-
225
- it "raises when trying to use a non-existent strategy" do
226
- expect { factory_with_non_existent_strategy }.to raise_error
227
- end
228
-
229
- it "creates a new factory with a specified default strategy" do
230
- factory_with_stub_strategy.default_strategy.should == :stub
231
- end
232
-
233
- describe "defining a child factory without setting default strategy" do
234
- subject { FactoryGirl::Factory.new(:other_object, :parent => factory_with_stub_strategy.name) }
235
- before { subject.compile }
236
-
237
- it "inherits default strategy from its parent" do
238
- subject.default_strategy.should == :stub
239
- end
240
- end
241
-
242
- describe "defining a child factory with a default strategy" do
243
- subject { FactoryGirl::Factory.new(:other_object, :default_strategy => :build, :parent => factory_with_stub_strategy.name) }
244
- before { subject.compile }
245
-
246
- it "overrides the default strategy from parent" do
247
- subject.default_strategy.should == :build
248
- end
249
- end
250
- end
251
-
252
202
  describe FactoryGirl::Factory, "human names" do
253
203
  context "factory name without underscores" do
254
204
  subject { FactoryGirl::Factory.new(:user) }
@@ -269,7 +219,7 @@ describe FactoryGirl::Factory, "human names" do
269
219
  end
270
220
 
271
221
  context "factory name with aliases" do
272
- subject { FactoryGirl::Factory.new(:happy_user, :aliases => [:gleeful_user, :person]) }
222
+ subject { FactoryGirl::Factory.new(:happy_user, aliases: [:gleeful_user, :person]) }
273
223
  its(:names) { should == [:happy_user, :gleeful_user, :person] }
274
224
  its(:human_names) { should == ["happy user", "gleeful user", "person"] }
275
225
  end
@@ -279,15 +229,15 @@ describe FactoryGirl::Factory, "running a factory" do
279
229
  subject { FactoryGirl::Factory.new(:user) }
280
230
  let(:attribute) { FactoryGirl::Attribute::Static.new(:name, "value", false) }
281
231
  let(:declaration) { FactoryGirl::Declaration::Static.new(:name, "value", false) }
282
- let(:strategy) { stub("strategy", :result => "result", :add_observer => true) }
232
+ let(:strategy) { stub("strategy", result: "result", add_observer: true) }
283
233
  let(:attributes) { [attribute] }
284
- let(:attribute_list) { stub('attribute-list', :declarations => [declaration], :to_a => attributes) }
234
+ let(:attribute_list) { stub('attribute-list', declarations: [declaration], to_a: attributes) }
285
235
 
286
236
  before do
287
- define_model("User", :name => :string)
288
- FactoryGirl::Declaration::Static.stubs(:new => declaration)
289
- declaration.stubs(:to_attributes => attributes)
290
- FactoryGirl::Strategy::Build.stubs(:new => strategy)
237
+ define_model("User", name: :string)
238
+ FactoryGirl::Declaration::Static.stubs(new: declaration)
239
+ declaration.stubs(to_attributes: attributes)
240
+ FactoryGirl::Strategy::Build.stubs(new: strategy)
291
241
  subject.declare_attribute(declaration)
292
242
  end
293
243
 
@@ -6,9 +6,8 @@ describe FactoryGirl::NullFactory do
6
6
  it { should delegate(:attributes).to(:definition) }
7
7
  it { should delegate(:constructor).to(:definition) }
8
8
 
9
- its(:compile) { should be_nil }
10
- its(:class_name) { should be_nil }
11
- its(:default_strategy) { should == :create }
12
- its(:attributes) { should be_an_instance_of(FactoryGirl::AttributeList) }
13
- its(:evaluator_class) { should == FactoryGirl::Evaluator }
9
+ its(:compile) { should be_nil }
10
+ its(:class_name) { should be_nil }
11
+ its(:attributes) { should be_an_instance_of(FactoryGirl::AttributeList) }
12
+ its(:evaluator_class) { should == FactoryGirl::Evaluator }
14
13
  end