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.
- data/.travis.yml +0 -3
- data/Appraisals +0 -4
- data/Changelog +0 -4
- data/Gemfile.lock +7 -4
- data/Rakefile +0 -12
- data/factory_girl.gemspec +3 -3
- data/features/support/env.rb +3 -0
- data/gemfiles/3.0.gemfile.lock +8 -4
- data/gemfiles/3.1.gemfile.lock +7 -4
- data/gemfiles/3.2.gemfile.lock +7 -4
- data/lib/factory_girl.rb +0 -1
- data/lib/factory_girl/attribute_assigner.rb +2 -2
- data/lib/factory_girl/declaration.rb +0 -5
- data/lib/factory_girl/definition.rb +1 -1
- data/lib/factory_girl/definition_proxy.rb +1 -1
- data/lib/factory_girl/errors.rb +1 -1
- data/lib/factory_girl/evaluator.rb +2 -5
- data/lib/factory_girl/factory.rb +4 -20
- data/lib/factory_girl/null_factory.rb +1 -2
- data/lib/factory_girl/null_object.rb +3 -15
- data/lib/factory_girl/sequence.rb +0 -4
- data/lib/factory_girl/step_definitions.rb +1 -1
- data/lib/factory_girl/syntax/blueprint.rb +2 -2
- data/lib/factory_girl/syntax/default.rb +1 -1
- data/lib/factory_girl/syntax/generate.rb +1 -1
- data/lib/factory_girl/syntax/make.rb +1 -1
- data/lib/factory_girl/syntax/vintage.rb +13 -32
- data/lib/factory_girl/trait.rb +1 -1
- data/lib/factory_girl/version.rb +1 -1
- data/spec/acceptance/aliases_spec.rb +3 -3
- data/spec/acceptance/attribute_aliases_spec.rb +5 -5
- data/spec/acceptance/attribute_existing_on_object_spec.rb +5 -5
- data/spec/acceptance/attributes_for_spec.rb +8 -8
- data/spec/acceptance/attributes_from_instance_spec.rb +5 -5
- data/spec/acceptance/attributes_ordered_spec.rb +5 -5
- data/spec/acceptance/build_list_spec.rb +2 -2
- data/spec/acceptance/build_spec.rb +6 -6
- data/spec/acceptance/build_stubbed_spec.rb +7 -7
- data/spec/acceptance/callbacks_spec.rb +3 -3
- data/spec/acceptance/create_list_spec.rb +6 -6
- data/spec/acceptance/create_spec.rb +13 -42
- data/spec/acceptance/define_child_before_parent_spec.rb +2 -2
- data/spec/acceptance/definition_spec.rb +2 -2
- data/spec/acceptance/initialize_with_spec.rb +7 -7
- data/spec/acceptance/modify_factories_spec.rb +5 -5
- data/spec/acceptance/modify_inherited_spec.rb +8 -8
- data/spec/acceptance/overrides_spec.rb +4 -4
- data/spec/acceptance/parent_spec.rb +3 -3
- data/spec/acceptance/stub_spec.rb +12 -41
- data/spec/acceptance/syntax/blueprint_spec.rb +6 -3
- data/spec/acceptance/syntax/generate_spec.rb +4 -4
- data/spec/acceptance/syntax/make_spec.rb +3 -3
- data/spec/acceptance/syntax/sham_spec.rb +5 -5
- data/spec/acceptance/syntax/vintage_spec.rb +28 -46
- data/spec/acceptance/traits_spec.rb +33 -33
- data/spec/acceptance/transient_attributes_spec.rb +7 -59
- data/spec/factory_girl/aliases_spec.rb +1 -1
- data/spec/factory_girl/attribute/association_spec.rb +2 -2
- data/spec/factory_girl/attribute/dynamic_spec.rb +2 -2
- data/spec/factory_girl/declaration_list_spec.rb +7 -7
- data/spec/factory_girl/definition_proxy_spec.rb +6 -6
- data/spec/factory_girl/definition_spec.rb +3 -3
- data/spec/factory_girl/evaluator_class_definer_spec.rb +5 -5
- data/spec/factory_girl/factory_spec.rb +19 -69
- data/spec/factory_girl/null_factory_spec.rb +4 -5
- data/spec/factory_girl/registry_spec.rb +1 -1
- data/spec/factory_girl/sequence_spec.rb +3 -4
- data/spec/factory_girl/strategy/attributes_for_spec.rb +2 -2
- data/spec/factory_girl/strategy/build_spec.rb +1 -1
- data/spec/factory_girl/strategy/create_spec.rb +1 -1
- data/spec/factory_girl/strategy/stub_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- data/spec/support/macros/define_constant.rb +2 -2
- data/spec/support/shared_examples/strategy.rb +12 -22
- metadata +32 -41
- data/gemfiles/2.3.gemfile.lock +0 -72
- data/lib/factory_girl/deprecated.rb +0 -18
- data/spec/acceptance/default_strategy_spec.rb +0 -24
- data/spec/acceptance/nested_attributes_spec.rb +0 -32
- data/spec/factory_girl/deprecated_spec.rb +0 -45
@@ -1,18 +0,0 @@
|
|
1
|
-
module Factory
|
2
|
-
def self.method_missing(name, *args, &block)
|
3
|
-
if FactoryGirl.respond_to?(name)
|
4
|
-
$stderr.puts "DEPRECATION WARNING: Change Factory.#{name} to FactoryGirl.#{name}"
|
5
|
-
FactoryGirl.send(name, *args, &block)
|
6
|
-
else
|
7
|
-
super(name, *args, &block)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.const_missing(name)
|
12
|
-
if FactoryGirl.const_defined?(name)
|
13
|
-
FactoryGirl.const_get(name)
|
14
|
-
else
|
15
|
-
super(name)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "default strategy" do
|
4
|
-
it "uses create when not specified" do
|
5
|
-
define_model('User')
|
6
|
-
|
7
|
-
FactoryGirl.define do
|
8
|
-
factory :user
|
9
|
-
end
|
10
|
-
|
11
|
-
Factory(:user).should_not be_new_record
|
12
|
-
end
|
13
|
-
|
14
|
-
it "can be overridden" do
|
15
|
-
define_model('User')
|
16
|
-
|
17
|
-
FactoryGirl.define do
|
18
|
-
factory :user, :default_strategy => :build
|
19
|
-
end
|
20
|
-
|
21
|
-
Factory(:user).should be_new_record
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "accessing an undefined method on Factory that is defined on FactoryGirl" do
|
4
|
-
let(:method_name) { :aliases }
|
5
|
-
let(:return_value) { 'value' }
|
6
|
-
let(:args) { [1, 2, 3] }
|
7
|
-
|
8
|
-
before do
|
9
|
-
FactoryGirl.stubs(method_name => return_value)
|
10
|
-
end
|
11
|
-
|
12
|
-
subject { Factory.send(method_name, *args) }
|
13
|
-
|
14
|
-
it "prints a deprecation warning" do
|
15
|
-
$stderr.stubs(:puts)
|
16
|
-
subject
|
17
|
-
$stderr.should have_received(:puts).with(anything)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "invokes that method on FactoryGirl" do
|
21
|
-
subject
|
22
|
-
FactoryGirl.should have_received(method_name).with(*args)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns the value from the method on FactoryGirl" do
|
26
|
-
subject.should == return_value
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "accessing an undefined method on Factory that is not defined on FactoryGirl" do
|
31
|
-
it "raises a NoMethodError" do
|
32
|
-
expect { Factory.send(:magic_beans) }.to raise_error(NoMethodError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "accessing an undefined constant on Factory that is defined on FactoryGirl" do
|
37
|
-
subject { Factory::VERSION }
|
38
|
-
it { should == FactoryGirl::VERSION }
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "accessing an undefined constant on Factory that is undefined on FactoryGirl" do
|
42
|
-
it "raises a NameError for Factory" do
|
43
|
-
expect { Factory::BOGUS }.to raise_error(NameError, /Factory::BOGUS/)
|
44
|
-
end
|
45
|
-
end
|