我写的RSpec集成测试,将我的面条代码使用accepts_nested_attributes_for
。我有这样一个片段:如何在RSpec集成测试中POST POST嵌套属性?
# file: spec/requests/wizard_spec.rb
describe 'POST /wizard with address' do
before(:each) do
@premise_attributes = {
"address"=>"600 Mellow Ave, Mellow Park, CA 94025, USA",
}
end
it 'should succeed' do
post :create, "wizard" => { "premise_attributes" => @premise_attributes }
response.status.should be(200)
end
end
当然这失败:
Failure/Error: post :create, "wizard" => { "premise_attributes" => @premise_attributes }
ArgumentError:
bad argument(expected URI object or URI string)
是否有转换嵌套的属性散列成后能够格式的方法?
(相关,但同样重要的:?是post
方法记录或定义,我想看看什么是真正接受作为参数)