我认为它可能就像:
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
..但是我得到了“无法修改冻结对象”的错误。
答案 0 :(得分:0)
以下是我将如何编写该规范:
describe 'Oragnization#destroy' do
let(:organization) { mock_model(Organization, :id => 1, :destroy => true) }
subject { post :destroy, :id => organization.id }
it { should be_successful }
end