はじめに
Rspecでモックを使おうとしたところ時間がかかってしまった箇所があるので書いておきます
問題
テストの引数のチェックでanyting
を利用しました
Api.should_receive(:update_new_document).with(shortname, anything())
すると以下のエラーが発生します
Failures:
(Api).update_new_document("A-00001", #<RSpec::Mocks::ArgumentMatchers::AnyArgMatcher:0x007faba8fb9658>)
expected: 1 time
received: 0 times
# ./spec/jobs/update_all_worker_spec.rb:19:in `block (5 levels) in <top (required)>'
Finished in 2.68 seconds
1 example, 1 failure
解決方法
anything()
にして解決しました
Api.should_receive(:update_new_document).with(shortname, anything())
おわりに
久しぶりにRspecをかいてますが昔を思い出します。楽しい