RSpec controller test: How do I check @organization.destroy is being called?
I thought it might be like:
开发者_高级运维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
..but I get a "can't modify frozen object" error.
Here's how I would write that spec:
describe 'Oragnization#destroy' do
let(:organization) { mock_model(Organization, :id => 1, :destroy => true) }
subject { post :destroy, :id => organization.id }
it { should be_successful }
end
精彩评论