2

我试图用来stub_chain模拟控制器操作中的一系列调用。但是它抱怨找不到方法错误。经过大量搜索,我并没有真正找到与此特定错误相关的任何信息,所以我认为我遗漏了一些相当明显的东西。有任何想法吗?

谢谢。

这是错误:

Admin::AccountsController GET #index with accounts 
 Failure/Error: before(:each) { Account.stub_chain(:scoped, :page, :order).returns([account]) }
 NoMethodError:
   undefined method `stub_chain' for #<Class:0x007f96c6448158>
 # ./spec/controllers/admin/accounts_controller_spec.rb:11:in `block (4 levels) in <top (required)>'

规范来源:

#spec/controllers/admin/accounts_controller.rb
describe 'GET #index' do

  context 'with accounts' do

    let(:account) { FactoryGirl.build_stubbed(:account) }
    before(:each) { Account.stub_chain(:scoped, :page, :order).returns([account]) }

    subject { get :index }

    it { should render_template(:index) }
    it { should assign_to(:accounts) }
    it { should respond_with(:success) }
    it { should_not set_the_flash }
  end
end
4

0 回答 0