[rspec-users] Odd parameter munging with with()
James Hughes
hughes.james at gmail.com
Wed Feb 14 19:00:37 EST 2007
Hi,
I have this setup block:
setup do
session[:login] = 'jhughes'
@user = mock("user")
User.stub!(:find).and_return(@user)
@params = {:cn => "Bilbo Baggins",
:telephoneNumber => "416-277-4418",
:mail => "bilbo at baggins.com"}
end
And then this spec:
specify "should update and save the attributes for user" do
@user.should_receive(:update_attributes).with(@params).and_return(true)
post :update, :id => "jhughes", :user => @params
end
This fails like this:
Mock 'user' expected :update_attributes with ([:telephoneNumber,
"416-277-4418"], [:mail, "bilbo at baggins.com"], [:cn, "Bilbo Baggins"])
but received it with ({"cn"=>"Bilbo Baggins",
"telephoneNumber"=>"416-277-4418", "mail"=>"bilbo at baggins.com"})
Puzzling, especially since inspecting the @params variable just before
the should_receive shows the expected hash.
What am I doing wrong?
James
More information about the rspec-users
mailing list