ruby on rails - RSpec controller test: How do I check @organization.destroy is being called? -
i thought might like:
let(:organization) { mock_model(organization).as_null_object } before(:each) organization.stub(:find).and_return(organization) end "calls destroy action on @organization" assigns[:organization].should_receive("destroy") post :destroy, :id => organization.id end
..but "can't modify frozen object" error.
here's how write spec:
describe 'oragnization#destroy' let(:organization) { mock_model(organization, :id => 1, :destroy => true) } subject { post :destroy, :id => organization.id } { should be_successful } end
Comments
Post a Comment