0
我有一個測試,我正在與此工作意外失敗。它是說==會在double上調用兩次。是否因爲它也是該方法的一個論據?爲什麼rspec雙打收到:==兩次
這就是我講的
require 'rspec'
describe 'rspec test doubles' do
let(:a_double) { double('a_double') }
it 'should only call == once' do
expect(a_double).to receive(:==).and_return(true)
a_double == a_double
end
end
的蒸餾的例子,這是我所得到的,當我運行這個測試
F
Failures:
1) rspec test doubles should only call == once
Failure/Error: expect(watir_driver).to receive(:==).and_return(true)
(Double "watir_driver").==(*(any args))
expected: 1 time with any arguments
received: 2 times with any arguments
# ./double_spec.rb:7:in `block (2 levels) in <top (required)>'
Finished in 0.019 seconds (files took 0.26902 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./double_spec.rb:6 # rspec test doubles should only call == once
你知道,當他們開始表現呀?它看起來像rspec 3.0沒有 – 2015-02-06 16:10:04
@DaneAndersen我不知道。我很驚訝它沒有在3.0中 - '=='的定義已經存在了將近3年了,並且查看3.0的代碼,它仍然執行'other == __mock_proxy'的事情。 – 2015-02-06 16:21:47