Ruby on rails RSpec控制器测试:如何检查@organization.destroy是否被调用?

Ruby on rails RSpec控制器测试:如何检查@organization.destroy是否被调用?,ruby-on-rails,ruby-on-rails-3,testing,rspec,rspec-rails,Ruby On Rails,Ruby On Rails 3,Testing,Rspec,Rspec Rails,我想可能是这样的: 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")

我想可能是这样的:

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

但是如果他取消了期望,剩下的测试是什么呢?是的-我不明白这是如何明确测试销毁操作被调用的。。。还是这只是一种常见的方法?