我有一个 users_controller_spec.rb :
describe "POST create" do
describe "with valid params" do
let(:user) { create(:user) }
it "assigns a newly created user as @user" do
post :create, user: user
assigns(:user).should be_a(User)
assigns(:user).should be_persisted
end
end
...
end
Debuggin 我发现控制器收到了下一个参数
(rdb:1) pp params
{"user"=>"1", "controller"=>"users", "action"=>"create"}
为什么“用户”=>“1”?为什么没有正确传递用户对象?