LoginSignup
8
8

More than 5 years have passed since last update.

Rspecでメソッドチェーンをstubで使う方法

Posted at

その名も、stub_chain

subject.stub_chain("one.two.three").and_return(:four)

(参考)
https://www.relishapp.com/rspec/rspec-mocks/v/2-0/docs/stubs/stub-a-chain-of-methods

mockと組み合わせるとこんな感じ

mmock = mock       
subject.stub_chain("one.two.three").and_return(mmock.as_null_object).should_receive(:hogehoge)
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8