35
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rspec3で引数を持つメソッドチェーンをstub化する

Last updated at Posted at 2014-09-22

rspec3ではstub_chainが廃止された。

これ

AnimalPage.where('title like ?', "%#{word}%").page(1).per(per_page).title_asc

たとえばこんな感じ

allow(AnimalPage).to receive_message_chain(:where, :page, :per, :title_asc)
  .with(anything).with(1).with(per_page).with(no_args)
  .and_return([])

allowexpectでもいける。
引数なしのパターン、with()にすると怒られた。

35
26
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
35
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?