factory_girl 4.5.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +25 -5
  3. data/Appraisals +11 -7
  4. data/CONTRIBUTING.md +44 -6
  5. data/GETTING_STARTED.md +175 -59
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +86 -63
  8. data/LICENSE +1 -1
  9. data/NEWS +12 -1
  10. data/README.md +21 -10
  11. data/Rakefile +1 -3
  12. data/factory_girl.gemspec +6 -14
  13. data/gemfiles/3.2.gemfile +4 -1
  14. data/gemfiles/3.2.gemfile.lock +84 -52
  15. data/gemfiles/4.0.gemfile +4 -1
  16. data/gemfiles/4.0.gemfile.lock +75 -49
  17. data/gemfiles/4.1.gemfile +4 -1
  18. data/gemfiles/4.1.gemfile.lock +78 -48
  19. data/gemfiles/4.2.gemfile +10 -0
  20. data/gemfiles/4.2.gemfile.lock +123 -0
  21. data/gemfiles/5.0.gemfile +10 -0
  22. data/gemfiles/5.0.gemfile.lock +126 -0
  23. data/lib/factory_girl.rb +13 -4
  24. data/lib/factory_girl/attribute/dynamic.rb +4 -1
  25. data/lib/factory_girl/attribute_assigner.rb +2 -2
  26. data/lib/factory_girl/configuration.rb +4 -0
  27. data/lib/factory_girl/decorator.rb +2 -2
  28. data/lib/factory_girl/decorator/class_key_hash.rb +2 -1
  29. data/lib/factory_girl/definition_proxy.rb +2 -2
  30. data/lib/factory_girl/evaluator.rb +4 -0
  31. data/lib/factory_girl/factory_runner.rb +7 -1
  32. data/lib/factory_girl/find_definitions.rb +1 -1
  33. data/lib/factory_girl/linter.rb +65 -14
  34. data/lib/factory_girl/strategy/stub.rb +25 -1
  35. data/lib/factory_girl/strategy_syntax_method_registrar.rb +4 -0
  36. data/lib/factory_girl/version.rb +1 -1
  37. metadata +26 -185
  38. data/features/find_definitions.feature +0 -75
  39. data/features/step_definitions/database_steps.rb +0 -9
  40. data/features/step_definitions/factory_girl_steps.rb +0 -36
  41. data/features/support/env.rb +0 -10
  42. data/features/support/factories.rb +0 -16
  43. data/gemfiles/3.1.gemfile +0 -7
  44. data/gemfiles/3.1.gemfile.lock +0 -91
  45. data/spec/acceptance/activesupport_instrumentation_spec.rb +0 -62
  46. data/spec/acceptance/aliases_spec.rb +0 -19
  47. data/spec/acceptance/attribute_aliases_spec.rb +0 -45
  48. data/spec/acceptance/attribute_existing_on_object_spec.rb +0 -68
  49. data/spec/acceptance/attributes_for_spec.rb +0 -97
  50. data/spec/acceptance/attributes_from_instance_spec.rb +0 -53
  51. data/spec/acceptance/attributes_ordered_spec.rb +0 -51
  52. data/spec/acceptance/build_list_spec.rb +0 -56
  53. data/spec/acceptance/build_spec.rb +0 -86
  54. data/spec/acceptance/build_stubbed_spec.rb +0 -161
  55. data/spec/acceptance/callbacks_spec.rb +0 -253
  56. data/spec/acceptance/create_list_spec.rb +0 -97
  57. data/spec/acceptance/create_pair_spec.rb +0 -32
  58. data/spec/acceptance/create_spec.rb +0 -116
  59. data/spec/acceptance/define_child_before_parent_spec.rb +0 -21
  60. data/spec/acceptance/defining_methods_inside_a_factory_spec.rb +0 -17
  61. data/spec/acceptance/definition_camel_string_spec.rb +0 -15
  62. data/spec/acceptance/definition_spec.rb +0 -21
  63. data/spec/acceptance/definition_without_block_spec.rb +0 -15
  64. data/spec/acceptance/global_initialize_with_spec.rb +0 -82
  65. data/spec/acceptance/global_to_create_spec.rb +0 -122
  66. data/spec/acceptance/initialize_with_spec.rb +0 -217
  67. data/spec/acceptance/keyed_by_class_spec.rb +0 -22
  68. data/spec/acceptance/lint_spec.rb +0 -65
  69. data/spec/acceptance/modify_factories_spec.rb +0 -184
  70. data/spec/acceptance/modify_inherited_spec.rb +0 -52
  71. data/spec/acceptance/nested_attributes_spec.rb +0 -32
  72. data/spec/acceptance/overrides_spec.rb +0 -61
  73. data/spec/acceptance/parent_spec.rb +0 -90
  74. data/spec/acceptance/private_attributes_spec.rb +0 -20
  75. data/spec/acceptance/register_strategies_spec.rb +0 -136
  76. data/spec/acceptance/sequence_context_spec.rb +0 -52
  77. data/spec/acceptance/sequence_spec.rb +0 -61
  78. data/spec/acceptance/skip_create_spec.rb +0 -19
  79. data/spec/acceptance/stub_spec.rb +0 -62
  80. data/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb +0 -51
  81. data/spec/acceptance/traits_spec.rb +0 -727
  82. data/spec/acceptance/transient_attributes_spec.rb +0 -151
  83. data/spec/factory_girl/aliases_spec.rb +0 -31
  84. data/spec/factory_girl/attribute/association_spec.rb +0 -28
  85. data/spec/factory_girl/attribute/dynamic_spec.rb +0 -52
  86. data/spec/factory_girl/attribute/sequence_spec.rb +0 -16
  87. data/spec/factory_girl/attribute/static_spec.rb +0 -19
  88. data/spec/factory_girl/attribute_list_spec.rb +0 -143
  89. data/spec/factory_girl/attribute_spec.rb +0 -16
  90. data/spec/factory_girl/callback_spec.rb +0 -41
  91. data/spec/factory_girl/declaration/implicit_spec.rb +0 -25
  92. data/spec/factory_girl/declaration_list_spec.rb +0 -67
  93. data/spec/factory_girl/definition_proxy_spec.rb +0 -215
  94. data/spec/factory_girl/definition_spec.rb +0 -64
  95. data/spec/factory_girl/disallows_duplicates_registry_spec.rb +0 -19
  96. data/spec/factory_girl/evaluator_class_definer_spec.rb +0 -77
  97. data/spec/factory_girl/factory_spec.rb +0 -259
  98. data/spec/factory_girl/find_definitions_spec.rb +0 -110
  99. data/spec/factory_girl/null_factory_spec.rb +0 -13
  100. data/spec/factory_girl/null_object_spec.rb +0 -22
  101. data/spec/factory_girl/registry_spec.rb +0 -68
  102. data/spec/factory_girl/sequence_spec.rb +0 -95
  103. data/spec/factory_girl/strategy/attributes_for_spec.rb +0 -18
  104. data/spec/factory_girl/strategy/build_spec.rb +0 -7
  105. data/spec/factory_girl/strategy/create_spec.rb +0 -25
  106. data/spec/factory_girl/strategy/stub_spec.rb +0 -38
  107. data/spec/factory_girl/strategy_calculator_spec.rb +0 -29
  108. data/spec/factory_girl_spec.rb +0 -22
  109. data/spec/spec_helper.rb +0 -26
  110. data/spec/support/macros/define_constant.rb +0 -86
  111. data/spec/support/matchers/callback.rb +0 -9
  112. data/spec/support/matchers/declaration.rb +0 -83
  113. data/spec/support/matchers/delegate.rb +0 -44
  114. data/spec/support/matchers/trait.rb +0 -11
  115. data/spec/support/shared_examples/strategy.rb +0 -90
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FactoryGirl::Attribute do
4
- let(:name) { "user" }
5
- subject { FactoryGirl::Attribute.new(name, false) }
6
-
7
- its(:name) { should eq name.to_sym }
8
- it { should_not be_association }
9
-
10
- it "raises an error when defining an attribute writer" do
11
- error_message = %{factory_girl uses 'test value' syntax rather than 'test = value'}
12
- expect {
13
- FactoryGirl::Attribute.new('test=', false)
14
- }.to raise_error(FactoryGirl::AttributeDefinitionError, error_message)
15
- end
16
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FactoryGirl::Callback do
4
- it "has a name" do
5
- expect(FactoryGirl::Callback.new(:after_create, -> {}).name).to eq :after_create
6
- end
7
-
8
- it "converts strings to symbols" do
9
- expect(FactoryGirl::Callback.new("after_create", -> {}).name).to eq :after_create
10
- end
11
-
12
- it "runs its block with no parameters" do
13
- ran_with = nil
14
- FactoryGirl::Callback.new(:after_create, -> { ran_with = [] }).run(:one, :two)
15
- expect(ran_with).to eq []
16
- end
17
-
18
- it "runs its block with one parameter" do
19
- ran_with = nil
20
- FactoryGirl::Callback.new(:after_create, ->(one) { ran_with = [one] }).run(:one, :two)
21
- expect(ran_with).to eq [:one]
22
- end
23
-
24
- it "runs its block with two parameters" do
25
- ran_with = nil
26
- FactoryGirl::Callback.new(:after_create, ->(one, two) { ran_with = [one, two] }).run(:one, :two)
27
- expect(ran_with).to eq [:one, :two]
28
- end
29
-
30
- it "allows valid callback names to be assigned" do
31
- FactoryGirl.callback_names.each do |callback_name|
32
- expect { FactoryGirl::Callback.new(callback_name, -> {}) }.
33
- to_not raise_error
34
- end
35
- end
36
-
37
- it "raises if an invalid callback name is assigned" do
38
- expect { FactoryGirl::Callback.new(:magic_fairies, -> {}) }.
39
- to raise_error(FactoryGirl::InvalidCallbackNameError, /magic_fairies is not a valid callback name/)
40
- end
41
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FactoryGirl::Declaration::Implicit do
4
- let(:name) { :author }
5
- let(:declaration) { FactoryGirl::Declaration::Implicit.new(name) }
6
- subject { declaration.to_attributes.first }
7
-
8
- context "with a known factory" do
9
- before do
10
- FactoryGirl.factories.stubs(:registered? => true)
11
- end
12
-
13
- it { should be_association }
14
- its(:factory) { should eq name }
15
- end
16
-
17
- context "with a known sequence" do
18
- before do
19
- FactoryGirl.sequences.stubs(:registered? => true)
20
- end
21
-
22
- it { should_not be_association }
23
- it { should be_a(FactoryGirl::Attribute::Sequence) }
24
- end
25
- end
@@ -1,67 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe FactoryGirl::DeclarationList, "#attributes" do
4
- let(:static_attribute_1) { stub("static attribute 1") }
5
- let(:static_attribute_2) { stub("static attribute 2") }
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]) }
9
-
10
- it "returns an AttributeList" do
11
- expect(subject.attributes).to be_a(FactoryGirl::AttributeList)
12
- end
13
-
14
- let(:attribute_list) { stub("attribute list", define_attribute: true) }
15
-
16
- it "defines each attribute on the attribute list" do
17
- FactoryGirl::AttributeList.stubs(new: attribute_list)
18
-
19
- subject.declare_attribute(static_declaration)
20
- subject.declare_attribute(dynamic_declaration)
21
-
22
- subject.attributes
23
-
24
- expect(attribute_list).to have_received(:define_attribute).with(static_attribute_1)
25
- expect(attribute_list).to have_received(:define_attribute).with(static_attribute_2)
26
- expect(attribute_list).to have_received(:define_attribute).with(dynamic_attribute_1)
27
- end
28
- end
29
-
30
- describe FactoryGirl::DeclarationList, "#declare_attribute" do
31
- let(:declaration_1) { stub("declaration", name: "declaration 1") }
32
- let(:declaration_2) { stub("declaration", name: "declaration 2") }
33
- let(:declaration_with_same_name) { stub("declaration", name: "declaration 1") }
34
-
35
- context "when not overridable" do
36
- it "adds the declaration to the list" do
37
- subject.declare_attribute(declaration_1)
38
- expect(subject.to_a).to eq [declaration_1]
39
-
40
- subject.declare_attribute(declaration_2)
41
- expect(subject.to_a).to eq [declaration_1, declaration_2]
42
- end
43
- end
44
-
45
- context "when overridable" do
46
- before { subject.overridable }
47
-
48
- it "adds the declaration to the list" do
49
- subject.declare_attribute(declaration_1)
50
- expect(subject.to_a).to eq [declaration_1]
51
-
52
- subject.declare_attribute(declaration_2)
53
- expect(subject.to_a).to eq [declaration_1, declaration_2]
54
- end
55
-
56
- it "deletes declarations with the same name" do
57
- subject.declare_attribute(declaration_1)
58
- expect(subject.to_a).to eq [declaration_1]
59
-
60
- subject.declare_attribute(declaration_2)
61
- expect(subject.to_a).to eq [declaration_1, declaration_2]
62
-
63
- subject.declare_attribute(declaration_with_same_name)
64
- expect(subject.to_a).to eq [declaration_2, declaration_with_same_name]
65
- end
66
- end
67
- end
@@ -1,215 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FactoryGirl::DefinitionProxy, "#add_attribute" do
4
- subject { FactoryGirl::Definition.new }
5
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
6
-
7
- it "raises if both a block and value are given" do
8
- expect {
9
- proxy.add_attribute(:something, "great") { "will raise!" }
10
- }.to raise_error(FactoryGirl::AttributeDefinitionError, "Both value and block given")
11
- end
12
-
13
- it "declares a static attribute on the factory" do
14
- proxy.add_attribute(:attribute_name, "attribute value")
15
- expect(subject).to have_static_declaration(:attribute_name).with_value("attribute value")
16
- end
17
-
18
- it "declares a dynamic attribute on the factory" do
19
- attribute_value = -> { "dynamic attribute" }
20
- proxy.add_attribute(:attribute_name, &attribute_value)
21
- expect(subject).to have_dynamic_declaration(:attribute_name).with_value(attribute_value)
22
- end
23
- end
24
-
25
- describe FactoryGirl::DefinitionProxy, "#add_attribute when the proxy ignores attributes" do
26
- subject { FactoryGirl::Definition.new }
27
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject, true) }
28
-
29
- it "raises if both a block and value are given" do
30
- expect {
31
- proxy.add_attribute(:something, "great") { "will raise!" }
32
- }.to raise_error(FactoryGirl::AttributeDefinitionError, "Both value and block given")
33
- end
34
-
35
- it "declares a static attribute on the factory" do
36
- proxy.add_attribute(:attribute_name, "attribute value")
37
- expect(subject).to have_static_declaration(:attribute_name).ignored.with_value("attribute value")
38
- end
39
-
40
- it "declares a dynamic attribute on the factory" do
41
- attribute_value = -> { "dynamic attribute" }
42
- proxy.add_attribute(:attribute_name, &attribute_value)
43
- expect(subject).to have_dynamic_declaration(:attribute_name).ignored.with_value(attribute_value)
44
- end
45
- end
46
-
47
- describe FactoryGirl::DefinitionProxy, "#transient" do
48
- subject { FactoryGirl::Definition.new }
49
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
50
-
51
- it "makes all attributes added ignored" do
52
- proxy.transient do
53
- add_attribute(:attribute_name, "attribute value")
54
- end
55
-
56
- expect(subject).to have_static_declaration(:attribute_name).ignored.with_value("attribute value")
57
- end
58
- end
59
-
60
- describe FactoryGirl::DefinitionProxy, "#method_missing" do
61
- subject { FactoryGirl::Definition.new }
62
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
63
-
64
- it "declares an implicit declaration without args or a block" do
65
- proxy.bogus
66
- expect(subject).to have_implicit_declaration(:bogus).with_factory(subject)
67
- end
68
-
69
- it "declares an association when :factory is passed" do
70
- proxy.author factory: :user
71
- expect(subject).to have_association_declaration(:author).with_options(factory: :user)
72
- end
73
-
74
- it "declares a static attribute" do
75
- proxy.attribute_name "attribute value"
76
- expect(subject).to have_static_declaration(:attribute_name).with_value("attribute value")
77
- end
78
-
79
- it "declares a dynamic attribute" do
80
- attribute_value = -> { "dynamic attribute" }
81
- proxy.attribute_name(&attribute_value)
82
- expect(subject).to have_dynamic_declaration(:attribute_name).with_value(attribute_value)
83
- end
84
- end
85
-
86
- describe FactoryGirl::DefinitionProxy, "#sequence" do
87
- subject { FactoryGirl::Definition.new }
88
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
89
-
90
- before { FactoryGirl::Sequence.stubs(:new) }
91
-
92
- it "creates a new sequence starting at 1" do
93
- proxy.sequence(:great)
94
- expect(FactoryGirl::Sequence).to have_received(:new).with(:great)
95
- end
96
-
97
- it "creates a new sequence with an overridden starting vaue" do
98
- proxy.sequence(:great, "C")
99
- expect(FactoryGirl::Sequence).to have_received(:new).with(:great, "C")
100
- end
101
-
102
- it "creates a new sequence with a block" do
103
- sequence_block = Proc.new { |n| "user+#{n}@example.com" }
104
- proxy.sequence(:great, 1, &sequence_block)
105
- expect(FactoryGirl::Sequence).to have_received(:new).with(:great, 1, &sequence_block)
106
- end
107
- end
108
-
109
- describe FactoryGirl::DefinitionProxy, "#association" do
110
- subject { FactoryGirl::Definition.new }
111
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
112
-
113
- it "declares an association" do
114
- proxy.association(:association_name)
115
- expect(subject).to have_association_declaration(:association_name)
116
- end
117
-
118
- it "declares an association with options" do
119
- proxy.association(:association_name, { name: "Awesome" })
120
- expect(subject).to have_association_declaration(:association_name).with_options(name: "Awesome")
121
- end
122
- end
123
-
124
- describe FactoryGirl::DefinitionProxy, "adding callbacks" do
125
- subject { FactoryGirl::Definition.new }
126
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
127
- let(:callback) { -> { "my awesome callback!" } }
128
-
129
- context "#after(:build)" do
130
- before { proxy.after(:build, &callback) }
131
- it { should have_callback(:after_build).with_block(callback) }
132
- end
133
-
134
- context "#after(:create)" do
135
- before { proxy.after(:create, &callback) }
136
- it { should have_callback(:after_create).with_block(callback) }
137
- end
138
-
139
- context "#after(:stub)" do
140
- before { proxy.after(:stub, &callback) }
141
- it { should have_callback(:after_stub).with_block(callback) }
142
- end
143
-
144
- context "#after(:stub, :create)" do
145
- before { proxy.after(:stub, :create, &callback) }
146
- it { should have_callback(:after_stub).with_block(callback) }
147
- it { should have_callback(:after_create).with_block(callback) }
148
- end
149
-
150
- context "#before(:stub, :create)" do
151
- before { proxy.before(:stub, :create, &callback) }
152
- it { should have_callback(:before_stub).with_block(callback) }
153
- it { should have_callback(:before_create).with_block(callback) }
154
- end
155
-
156
- context "#callback(:after_stub, :before_create)" do
157
- before { proxy.callback(:after_stub, :before_create, &callback) }
158
- it { should have_callback(:after_stub).with_block(callback) }
159
- it { should have_callback(:before_create).with_block(callback) }
160
- end
161
- end
162
-
163
- describe FactoryGirl::DefinitionProxy, "#to_create" do
164
- subject { FactoryGirl::Definition.new }
165
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
166
-
167
- it "accepts a block to run in place of #save!" do
168
- to_create_block = ->(record) { record.persist }
169
- proxy.to_create(&to_create_block)
170
- expect(subject.to_create).to eq to_create_block
171
- end
172
- end
173
-
174
- describe FactoryGirl::DefinitionProxy, "#factory" do
175
- subject { FactoryGirl::Definition.new }
176
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
177
-
178
- it "without options" do
179
- proxy.factory(:child)
180
- expect(proxy.child_factories).to include([:child, {}, nil])
181
- end
182
-
183
- it "with options" do
184
- proxy.factory(:child, { awesome: true })
185
- expect(proxy.child_factories).to include([:child, { awesome: true }, nil])
186
- end
187
-
188
- it "with a block" do
189
- child_block = -> { }
190
- proxy.factory(:child, {}, &child_block)
191
- expect(proxy.child_factories).to include([:child, {}, child_block])
192
- end
193
- end
194
-
195
- describe FactoryGirl::DefinitionProxy, "#trait" do
196
- subject { FactoryGirl::Definition.new }
197
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
198
-
199
- it "declares a trait" do
200
- male_trait = Proc.new { gender("Male") }
201
- proxy.trait(:male, &male_trait)
202
- expect(subject).to have_trait(:male).with_block(male_trait)
203
- end
204
- end
205
-
206
- describe FactoryGirl::DefinitionProxy, "#initialize_with" do
207
- subject { FactoryGirl::Definition.new }
208
- let(:proxy) { FactoryGirl::DefinitionProxy.new(subject) }
209
-
210
- it "defines the constructor on the definition" do
211
- constructor = Proc.new { Array.new }
212
- proxy.initialize_with(&constructor)
213
- expect(subject.constructor).to eq constructor
214
- end
215
- end
@@ -1,64 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe FactoryGirl::Definition do
4
- it { should delegate(:declare_attribute).to(:declarations) }
5
- end
6
-
7
- describe FactoryGirl::Definition, "with a name" do
8
- let(:name) { :"great name" }
9
- subject { FactoryGirl::Definition.new(name) }
10
-
11
- it "creates a new attribute list with the name passed" do
12
- FactoryGirl::DeclarationList.stubs(:new)
13
- subject
14
- expect(FactoryGirl::DeclarationList).to have_received(:new).with(name)
15
- end
16
- end
17
-
18
- describe FactoryGirl::Definition, "#overridable" do
19
- let(:list) { stub("declaration list", overridable: true) }
20
- before { FactoryGirl::DeclarationList.stubs(new: list) }
21
-
22
- it "sets the declaration list as overridable" do
23
- expect(subject.overridable).to eq subject
24
- expect(list).to have_received(:overridable).once
25
- end
26
- end
27
-
28
- describe FactoryGirl::Definition, "defining traits" do
29
- let(:trait_1) { stub("trait") }
30
- let(:trait_2) { stub("trait") }
31
-
32
- it "maintains a list of traits" do
33
- subject.define_trait(trait_1)
34
- subject.define_trait(trait_2)
35
- expect(subject.defined_traits).to include(trait_1, trait_2)
36
- end
37
-
38
- it "adds only unique traits" do
39
- subject.define_trait(trait_1)
40
- subject.define_trait(trait_1)
41
- expect(subject.defined_traits.size).to eq 1
42
- end
43
- end
44
-
45
- describe FactoryGirl::Definition, "adding callbacks" do
46
- let(:callback_1) { "callback1" }
47
- let(:callback_2) { "callback2" }
48
-
49
- it "maintains a list of callbacks" do
50
- subject.add_callback(callback_1)
51
- subject.add_callback(callback_2)
52
- expect(subject.callbacks).to eq [callback_1, callback_2]
53
- end
54
- end
55
-
56
- describe FactoryGirl::Definition, "#to_create" do
57
- its(:to_create) { should be_nil }
58
-
59
- it "returns the assigned value when given a block" do
60
- block = proc { nil }
61
- subject.to_create(&block)
62
- expect(subject.to_create).to eq block
63
- end
64
- end
@@ -1,19 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe FactoryGirl::Decorator::DisallowsDuplicatesRegistry do
4
- let(:registry) { stub("registry", name: 'Great thing', register: true) }
5
-
6
- subject { described_class.new(registry) }
7
-
8
- it "delegates #register to the registry when not registered" do
9
- registry.stubs(registered?: false)
10
- subject.register(:awesome, {})
11
- expect(registry).to have_received(:register).with(:awesome, {})
12
- end
13
-
14
- it "raises when attempting to #register a previously registered strategy" do
15
- registry.stubs(registered?: true)
16
- expect { subject.register(:same_name, {}) }.
17
- to raise_error(FactoryGirl::DuplicateDefinitionError, "Great thing already registered: same_name")
18
- end
19
- end