1

理由はよくわかりませんが、Sinatra の rspec テストが適切に失敗するはずです。これが私のRspecの一部です:

context "invalid params" do
        before do
            @params = {}
        end
        it "does not call the Count model" do
            Count.should_not_receive(:increment)
            post '/counts' , @params
        end
end

失敗じゃないけど。ただし、 should_not_receive 行を次のように切り替えると:

Count.should_receive(:increment).exactly(2).times

次のエラーで応答します。

Failure/Error: Count.should_receive(:increment).exactly(2).times
   (<Count (class)>).increment(any args)
       expected: 2 times
       received: 1 time

では、一度呼び出された場合、最初のテストが失敗しないのはなぜですか?

4

1 に答える 1