[英]RSpec controller test: How do I check @organization.destroy is being called?
我想它可能是這樣的:
let(:organization) { mock_model(Organization).as_null_object }
before(:each) do
Organization.stub(:find).and_return(organization)
end
it "calls the destroy action on @organization" do
assigns[:organization].should_receive("destroy")
post :destroy, :id => organization.id
end
..但我收到“無法修改凍結對象”錯誤。
這是我編寫該規范的方式:
describe 'Oragnization#destroy' do
let(:organization) { mock_model(Organization, :id => 1, :destroy => true) }
subject { post :destroy, :id => organization.id }
it { should be_successful }
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.