2
試圖斷言,在一個Mongoid ::文檔類的方法是通過我的控制器代碼中調用時,我面臨着一些問題:Rspec的2「should_receive」不Mongoid :: Document類工作
require 'spec_helper'
describe AController do
describe 'GET index' do
it 'returns the full list' do
get :index
Model.should_receive(:find).with(:all)
response.code.should eq ("200")
end
end
end
看看test.log我可以看到對數據庫執行的查詢。但是,測試失敗,rspec抱怨Model.find(:all)預期會發生一次,但收到0次。任何人都知道這裏發生了什麼?在我看來,Rspec無法存儲包含Mongoid :: Document的類。
謝謝!