0

我想它可能是这样的:

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

..但我收到“无法修改冻结对象”错误。

4

1 回答 1

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
于 2011-07-02T21:18:55.207 回答