I'm struggling mightily!

I have a controller called Govtpositions, and I'm just trying to test
the standard Rails 'create' method. So it seems as if three examples
would be appropriate... one to test the instantiation of the new model
from the params hash, another to test that it was saved, and then the
final redirection.

So just to test the model instantiation, I have:

describe GovtpositionsController, "POST govtpositions to create govt
new government position" do
  before do
    Govtposition.stub!(:new).and_return(@govtposition)
  end

  it "should create a new govt position model" do
    @govtposition = mock_model(Govtposition)
    @params = {"name"=>"chief"}
    Govtposition.should_receive(:new).with(@params).and_return
(@govtposition)
  end
end

But this example fails due to "Mock 'Govtposition_1001' received
unexpected message :save with (no args)"

Surely I should be able to test the save in a separate example, no? I
was expecting to declare just one expectation per example, with a
total of three for the create method. But the test failure seems to
suggest otherwise.

Any clarification you can offer would be much appreciated.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to