spec/lib/pickle_session_spec.rb in pickle-0.2.3 vs spec/lib/pickle_session_spec.rb in pickle-0.2.4

- old
+ new

@@ -205,31 +205,43 @@ it_should_behave_like "after storing a single user" end end end - describe "#create_models_from_table(plural_factory, table)" do + describe "create and find using plural_factory and table" do context "when given a table without a matching pickle ref column" do before do @table = mock(:hashes => [{'name' => 'Fred'}, {'name' => 'Betty'}]) end - it "should call create_model for each of the table hashes with plain factory name" do + 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) 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) + end end context "when given a table with a matching pickle ref column" do before do @table = mock(:hashes => [{'user' => "fred", 'name' => 'Fred'}, {'user' => "betty", 'name' => 'Betty'}]) end - it "should call create_model for each of the table hashes with labelled pickle ref" do + 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) + 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) end end end describe "#find_model!" do \ No newline at end of file