Francois Beausoleil
2007-Jan-29 05:12 UTC
[rspec-users] mock.with(Hash) expects an Array ?
Hi all,
I looked at the open issues on the bug tracker, but couldn''t find
anything related to this. I also searched the archives. And I can''t
believe someone didn''t hit on this before.
Here''s my spec:
context "A project owner" do
controller_name :roles
setup do
controller.stub!(:current_user).and_return(@user = mock("user"))
controller.stub!(:current_project).and_return(@project =
mock("project"))
@user.stub!(:role_on).and_return(Role.owner)
end
specify "can change the role of a user" do
@project.should_receive(:roles).and_return(roles_proxy mock("roles
proxy"))
roles_proxy.should_receive(:find).with("17").and_return(role =
mock("role"))
role.should_receive(:update_attributes!).with(:name =>
Role.developer).and_return(true)
role.stub!(:name).and_return(Role.developer)
post :update, :project_id => 41, :id => 17, :role => {:name =>
Role.developer}
response.body.should == Role.developer
end
end
And the failure:
''A project owner can change the role of a user'' FAILED
Mock ''role'' expected :update_attributes! with ([:name,
"developer"])
but received it with ({"name"=>"developer"})
(eval):3:in `update_attributes!''
/home/francois/src/smrty2/config/../app/controllers/roles_controller.rb:11:in
`update''
./spec/controllers/roles_spec.rb:35:
Looks like the call to #with changed the Hash to an Array.
Can anyone else confirm this ? This is on 0.7.5.1.
Thanks !
--
Fran?ois Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
