我正在尝试使用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