开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜