0
我嘗試使用RR編寫測試。我需要的是一個模型對象的存根。存根(...)收到帶有(無參數)的意外消息(...)
describe ApplicationController do
subject(:application_controller) { ApplicationController.new }
let(:messages) { ['a1', 'a2', 'a3' ] }
let(:model) { Object.new }
it 'should copy errors to flash' do
stub(model).error_messages { messages }
flash[:error] == nil
subject.copy_errors_to_flash(model)
flash[:error].should == messages
end
end
我得到的是
ApplicationController should copy errors to flash
Failure/Error: stub(model).error_messages { messages }
Stub #<Object:0x007ffaa803f930> received unexpected message :error_messages with (no args)
# ./spec/controllers/application_controller_spec.rb:10:in `block (2 levels) in <top (required)>'
我不知道我做錯了。我想,我按照文檔...