[英]Rspec: how to test Service Object method “call” which is called in Controller action create?
[英]RSpec: Test a create action method in controller
我已經為控制器中的創建操作方法編寫了 RSpec 測試。 現在我變成了以下錯誤:錯誤屏幕
我的測試:
describe '#create' do
before(:each) {
@address = {
attributes: {
'street': "bla",
'street-number': 2,
'zip': "12345",
'city': "blabla",
'country': ''
},
type: "addresses"
}
}
it 'test the create route' do
post 'create', { params: @address }
end
end
我的控制器方法:
public def create
action(Address::Create)
.otherwise('address_create_error', 401)
.then_render(Address::Representer::Out::Default)
end
還有我的工廠:
FactoryGirl.define do
factory :address do
street 'Musterstraße'
street_number '1'
zip '12345'
city 'Musterstadt'
country ''
end
end
我不知道為什么會出現這個錯誤。 有人可以幫我嗎?
嘗試使用“=>”語法
@address = {
'attributes' => {
'street' => "bla",
'street-number' => 2,
'zip' => "12345",
'city' => "blabla",
'country': ''
},
'type' => "addresses"
}
我今天已經解決了這個問題。 為了解決這個問題,我不得不調整兩件事。
還是要謝謝你的幫助。 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.