I'm using what is largely a scaffold generated RSpec spec, which is failing but shouldn't be. Here is the spec:
describe "PUT update" do
describe "with valid params" do
it "updates the requested invoice" do
invoice = Invoice.create!
Invoice.any_instance.should_receive(:update_attributes).with({"number" => "MyString" })
put :update, {:id => invoice.id, :invoice => { "number" => "MyString" }}
end
When the spec is run, one Invoice is created in the db, and is updated appropriately. However, I get this message and a fail:
RSpec::Mocks::MockExpectationError: (#<Mocha::ClassMethods::AnyInstance:0x653a9a8>).update_attributes({"number"=>"MyString"})
expected: 1 time with arguments: ({"number"=>"MyString"})
received: 0 times with arguments: ({"number"=>"MyString"})
Why is this failing?