diff --git a/lib/factory_girl/factory.rb b/lib/factory_girl/factory.rb index 68292a84b..180fc34f4 100644 --- a/lib/factory_girl/factory.rb +++ b/lib/factory_girl/factory.rb @@ -121,10 +121,6 @@ def association (name, options = {}) add_attribute(name) {|a| a.association(association_factory) } end - def build (overrides = {}) #:nodoc: - run_strategy(Strategy::Build, overrides) - end - def create (overrides = {}) #:nodoc: run_strategy(Strategy::Create, overrides) end diff --git a/test/factory_test.rb b/test/factory_test.rb index 996e5117c..7dc47b295 100644 --- a/test/factory_test.rb +++ b/test/factory_test.rb @@ -14,7 +14,8 @@ def self.should_instantiate_class should "override attributes using the passed hash" do @value = 'Davis' - @instance = @factory.build(:first_name => @value) + @instance = @factory.run_strategy(Factory::Strategy::Build, + :first_name => @value) assert_equal @value, @instance.first_name end end @@ -150,7 +151,7 @@ def self.should_instantiate_class should "create a block that builds the association" do Factory.expects(:create).with(@name, {}) - @factory.build + @factory.run_strategy(Factory::Strategy::Build, {}) end end @@ -170,7 +171,7 @@ def self.should_instantiate_class should "create a block that builds the association" do Factory.expects(:create).with(@factory_name, {}) - @factory.build + @factory.run_strategy(Factory::Strategy::Build, {}) end end @@ -266,48 +267,6 @@ def self.should_instantiate_class assert_equal @class, @factory.build_class end end - - context "with some attributes added" do - setup do - @first_name = 'Billy' - @last_name = 'Idol' - @email = 'test@something.com' - - @factory.add_attribute(:first_name, @first_name) - @factory.add_attribute(:last_name, @last_name) - @factory.add_attribute(:email, @email) - end - - context "when building an instance" do - setup do - @instance = @factory.build - end - - should_instantiate_class - - should "not save the instance" do - assert @instance.new_record? - end - end - - context "when creating an instance" do - setup do - @instance = @factory.create - end - - should_instantiate_class - - should "save the instance" do - assert !@instance.new_record? - end - end - - should "raise an error for invalid instances" do - assert_raise(ActiveRecord::RecordInvalid) do - @factory.create(:first_name => nil) - end - end - end end context "a factory with a name ending in s" do