Skip to content

Commit

Permalink
Add the fabrication adapter to the default
Browse files Browse the repository at this point in the history
adapter list
  • Loading branch information
David Padilla authored and ianwhite committed Sep 19, 2011
1 parent 3288454 commit 3881add
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/pickle/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def configure(&block)
end

def adapters
@adapters ||= [:machinist, :factory_girl, :orm]
@adapters ||= [:machinist, :factory_girl, :fabrication, :orm]
end

def adapter_classes
Expand Down
13 changes: 8 additions & 5 deletions spec/pickle/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
end

it "#adapters should default to :machinist, :factory_girl, :orm" do
@config.adapters.should == [:machinist, :factory_girl, :orm]
@config.adapters.should == [:machinist, :factory_girl, :fabrication, :orm]
end

it "#adapter_classes should default to Adapter::Machinist, Adapter::FactoryGirl, Adapter::Orm" do
@config.adapter_classes.should == [Pickle::Adapter::Machinist, Pickle::Adapter::FactoryGirl, Pickle::Adapter::Orm]
@config.adapter_classes.should == [Pickle::Adapter::Machinist, Pickle::Adapter::FactoryGirl, Pickle::Adapter::Fabrication, Pickle::Adapter::Orm]
end

describe "setting adapters to [:machinist, SomeAdapter]" do
Expand All @@ -29,22 +29,25 @@ class SomeAdapter; end
it "should call adaptor.factories for each adaptor" do
Pickle::Adapter::Machinist.should_receive(:factories).and_return([])
Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([])
Pickle::Adapter::Fabrication.should_receive(:factories).and_return([])
Pickle::Adapter::Orm.should_receive(:factories).and_return([])
@config.factories
end

it "should aggregate factories into a hash using factory name as key" do
Pickle::Adapter::Machinist.should_receive(:factories).and_return([@machinist = mock('machinist', :name => 'machinist')])
Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([@factory_girl = mock('factory_girl', :name => 'factory_girl')])
Pickle::Adapter::Fabrication.should_receive(:factories).and_return([@fabrication = mock('fabrication', :name => 'fabrication')])
Pickle::Adapter::Orm.should_receive(:factories).and_return([@orm = mock('orm', :name => 'orm')])
@config.factories.should == {'machinist' => @machinist, 'factory_girl' => @factory_girl, 'orm' => @orm}
@config.factories.should == {'machinist' => @machinist, 'factory_girl' => @factory_girl, 'fabrication' => @fabrication, 'orm' => @orm}
end

it "should give preference to adaptors first in the list" do
Pickle::Adapter::Machinist.should_receive(:factories).and_return([@machinist_one = mock('one', :name => 'one')])
Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([@factory_girl_one = mock('one', :name => 'one'), @factory_girl_two = mock('two', :name => 'two')])
Pickle::Adapter::Orm.should_receive(:factories).and_return([@orm_two = mock('two', :name => 'two'), @orm_three = mock('three', :name => 'three')])
@config.factories.should == {'one' => @machinist_one, 'two' => @factory_girl_two, 'three' => @orm_three}
Pickle::Adapter::Fabrication.should_receive(:factories).and_return([@fabrication_one = mock('one', :name => 'one'), @fabrication_three = mock('three', :name => 'three')])
Pickle::Adapter::Orm.should_receive(:factories).and_return([@orm_two = mock('two', :name => 'two'), @orm_four = mock('four', :name => 'four')])
@config.factories.should == {'one' => @machinist_one, 'two' => @factory_girl_two, 'three' => @fabrication_three, 'four' => @orm_four}
end
end

Expand Down

0 comments on commit 3881add

Please sign in to comment.