私はコントローラーの仕様を持っていますが、次のような期待に失敗します。
Failure/Error: put :update, :id => login_user.id, :user => valid_attributes
#<User:0xbd030bc> received :update_attributes with unexpected arguments
expected: ({:name=>"changed name", :email=>"changed@mail.com", :password=>"secret", :password_confirmation=>"secret"})
got: ({"name"=>"Test user", "email"=>"user@test.com", "password"=>"secret", "password_confirmation"=>"secret"})
そして私にとっては、私が通りかかっているように見え"name" => "Test User"
、私は期待しています:name => "test user"
私のスペックは次のようになります:
describe 'with valid parameters' do
it 'updates the user' do
login_user = User.create!(valid_attributes)
controller.stub(:current_user).and_return(login_user)
User.any_instance.
should_receive(:update_attributes).
with(valid_attributes.merge(:email => "changed@mail.com",:name=>"changed name"))
put :update, :id => login_user.id, :user => valid_attributes
end
end
有効な属性には次のようなものがあります。
def valid_attributes
{
:name => "Test user",
:email=> "user@test.com",
:password => "secret",
:password_confirmation => "secret"
}
end
だから私のパラメータの何が問題になっていますか?
Rails3.0.5とrspec2.6.0を使用しています...