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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.