Skip to content

Commit

Permalink
Add specs for find/create models_from_table returning the models
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Mar 17, 2010
1 parent 40a2267 commit f839d3c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions spec/lib/pickle_session_spec.rb
Expand Up @@ -213,16 +213,16 @@ def do_create_model
@table = mock(:hashes => [{'name' => 'Fred'}, {'name' => 'Betty'}])
end

it "#create_models_from_table(<plural factory>, <table>) should call create_model for each of the table hashes with plain factory name" do
should_receive(:create_model).with("user", 'name' => "Fred").once.ordered
should_receive(:create_model).with("user", 'name' => "Betty").once.ordered
create_models_from_table("users", @table)
it "#create_models_from_table(<plural factory>, <table>) should call create_model for each of the table hashes with plain factory name and return the models" do
should_receive(:create_model).with("user", 'name' => "Fred").once.ordered.and_return(:fred)
should_receive(:create_model).with("user", 'name' => "Betty").once.ordered.and_return(:betty)
create_models_from_table("users", @table).should == [:fred, :betty]
end

it "#find_models_from_table(<plural factory>, <table>) should call find_model for each of the table hashes with plain factory name" do
should_receive(:find_model).with("user", 'name' => "Fred").once.ordered
should_receive(:find_model).with("user", 'name' => "Betty").once.ordered
find_models_from_table("users", @table)
it "#find_models_from_table(<plural factory>, <table>) should call find_model for each of the table hashes with plain factory name and return the models" do
should_receive(:find_model).with("user", 'name' => "Fred").once.ordered.and_return(:fred)
should_receive(:find_model).with("user", 'name' => "Betty").once.ordered.and_return(:betty)
find_models_from_table("users", @table).should == [:fred, :betty]
end
end

Expand All @@ -232,15 +232,15 @@ def do_create_model
end

it "#create_models_from_table(<plural factory>, <table>) should call create_model for each of the table hashes with labelled pickle ref" do
should_receive(:create_model).with("user \"fred\"", 'name' => "Fred").once.ordered
should_receive(:create_model).with("user \"betty\"", 'name' => "Betty").once.ordered
create_models_from_table("users", @table)
should_receive(:create_model).with("user \"fred\"", 'name' => "Fred").once.ordered.and_return(:fred)
should_receive(:create_model).with("user \"betty\"", 'name' => "Betty").once.ordered.and_return(:betty)
create_models_from_table("users", @table).should == [:fred, :betty]
end

it "#find_models_from_table(<plural factory>, <table>) should call find_model for each of the table hashes with labelled pickle ref" do
should_receive(:find_model).with("user \"fred\"", 'name' => "Fred").once.ordered
should_receive(:find_model).with("user \"betty\"", 'name' => "Betty").once.ordered
find_models_from_table("users", @table)
should_receive(:find_model).with("user \"fred\"", 'name' => "Fred").once.ordered.and_return(:fred)
should_receive(:find_model).with("user \"betty\"", 'name' => "Betty").once.ordered.and_return(:betty)
find_models_from_table("users", @table).should == [:fred, :betty]
end
end
end
Expand Down

0 comments on commit f839d3c

Please sign in to comment.