factory_girl 2.1.0 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Changelog +9 -0
- data/GETTING_STARTED.md +47 -16
- data/Gemfile.lock +10 -9
- data/gemfiles/2.1.gemfile.lock +2 -1
- data/gemfiles/2.3.gemfile.lock +2 -1
- data/gemfiles/3.0.gemfile.lock +2 -1
- data/gemfiles/3.1.gemfile.lock +2 -1
- data/lib/factory_girl.rb +6 -3
- data/lib/factory_girl/attribute/static.rb +8 -0
- data/lib/factory_girl/attribute_list.rb +20 -12
- data/lib/factory_girl/callback.rb +30 -0
- data/lib/factory_girl/declaration.rb +19 -0
- data/lib/factory_girl/declaration/association.rb +17 -0
- data/lib/factory_girl/declaration/dynamic.rb +16 -0
- data/lib/factory_girl/declaration/implicit.rb +23 -0
- data/lib/factory_girl/declaration/static.rb +16 -0
- data/lib/factory_girl/definition_proxy.rb +6 -6
- data/lib/factory_girl/factory.rb +63 -79
- data/lib/factory_girl/proxy.rb +7 -11
- data/lib/factory_girl/proxy/attributes_for.rb +1 -0
- data/lib/factory_girl/proxy/build.rb +1 -0
- data/lib/factory_girl/proxy/stub.rb +1 -0
- data/lib/factory_girl/syntax/default.rb +4 -2
- data/lib/factory_girl/syntax/vintage.rb +1 -1
- data/lib/factory_girl/trait.rb +12 -4
- data/lib/factory_girl/version.rb +1 -1
- data/spec/acceptance/callbacks_spec.rb +7 -1
- data/spec/acceptance/modify_inherited_spec.rb +52 -0
- data/spec/acceptance/syntax/vintage_spec.rb +19 -7
- data/spec/factory_girl/attribute_list_spec.rb +18 -45
- data/spec/factory_girl/callback_spec.rb +41 -0
- data/spec/factory_girl/{attribute → declaration}/implicit_spec.rb +16 -11
- data/spec/factory_girl/definition_proxy_spec.rb +16 -12
- data/spec/factory_girl/factory_spec.rb +43 -34
- data/spec/factory_girl/proxy/create_spec.rb +7 -9
- data/spec/factory_girl/proxy_spec.rb +26 -39
- data/spec/support/shared_examples/proxy.rb +1 -1
- metadata +137 -114
- data/lib/factory_girl/attribute/callback.rb +0 -14
- data/lib/factory_girl/attribute/implicit.rb +0 -39
- data/lib/factory_girl/attribute/trait.rb +0 -22
- data/spec/factory_girl/attribute/callback_spec.rb +0 -22
@@ -1,39 +0,0 @@
|
|
1
|
-
module FactoryGirl
|
2
|
-
class Attribute
|
3
|
-
|
4
|
-
class Implicit < Attribute
|
5
|
-
def initialize(name, factory = nil)
|
6
|
-
super(name)
|
7
|
-
@factory = factory
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_to(proxy)
|
11
|
-
implementation.add_to(proxy)
|
12
|
-
end
|
13
|
-
|
14
|
-
def association?
|
15
|
-
implementation.association?
|
16
|
-
end
|
17
|
-
|
18
|
-
def factory
|
19
|
-
name
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def implementation
|
25
|
-
@implementation ||= resolve_name
|
26
|
-
end
|
27
|
-
|
28
|
-
def resolve_name
|
29
|
-
if FactoryGirl.factories.registered?(name)
|
30
|
-
Attribute::Association.new(name, name, {})
|
31
|
-
elsif FactoryGirl.sequences.registered?(name)
|
32
|
-
Attribute::Sequence.new(name, name)
|
33
|
-
else
|
34
|
-
Attribute::Trait.new(name, @factory)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module FactoryGirl
|
2
|
-
class Attribute #:nodoc:
|
3
|
-
|
4
|
-
class Trait < Attribute #:nodoc:
|
5
|
-
def initialize(name, factory)
|
6
|
-
super(name)
|
7
|
-
@factory = factory
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_to(proxy)
|
11
|
-
trait.attributes.each { |attr| attr.add_to(proxy) }
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def trait
|
17
|
-
(@factory || FactoryGirl).trait_by_name(name)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe FactoryGirl::Attribute::Callback do
|
4
|
-
let(:name) { :after_create }
|
5
|
-
let(:block) { proc { "block" } }
|
6
|
-
let(:proxy) { stub("proxy") }
|
7
|
-
|
8
|
-
subject { FactoryGirl::Attribute::Callback.new(name, block) }
|
9
|
-
|
10
|
-
its(:name) { should == name }
|
11
|
-
|
12
|
-
it "set its callback on a proxy" do
|
13
|
-
proxy.stubs(:add_callback)
|
14
|
-
subject.add_to(proxy)
|
15
|
-
proxy.should have_received(:add_callback).with(name, block)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe FactoryGirl::Attribute::Callback, "with a string name" do
|
20
|
-
subject { FactoryGirl::Attribute::Callback.new("name", nil) }
|
21
|
-
its(:name) { should == :name }
|
22
|
-
end
|