我正在測試緩存過期,並且在創建新的ProjectInfo時,項目以及ProjectInfos的緩存應該過期。我有以下測試:無法找出此rspec錯誤
it "creating a new project info should invalidate the cache" do
2.times { FactoryGirl.create(:project_info) }
ProjectInfo.should_receive(:all).and_call_original
Project.should_receive(:all).and_call_original
Project.fetch_all
Project.should_not_receive(:all)
Project.fetch_all
ProjectInfo.should_not_receive(:all)
ProjectInfo.fetch_all
FactoryGirl.create(:project_info)
Project.should_receive(:all).and_call_original
Project.fetch_all <- problem line
ProjectInfo.should_receive(:all).and_call_original
ProjectInfo.fetch_all
end
我得到以下錯誤:
1) ProjectInfo Caching creating a new project should invalidate the cache
Failure/Error: Project.fetch_all
Project(id:integer, name:string).all({:include => :project_info})
expected: 0 times with any arguments
received: 1 time with arguments: ({:include=>:project_info})
問題的行,如果最後Project.fetch_all。爲什麼rspec期待它0次?