8
9

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.

RSpec で一度定義したスタブを解除する

Posted at

RSpec で一度定義したスタブをある条件下で解除したい場合は unstub を使う。

Ruby
foo.stub(:bar).with(any_args).and_return(true)

のように定義していた場合、

Ruby
foo.unstub(:bar)

で解除する。

参考:
https://www.relishapp.com/rspec/rspec-mocks/docs/method-stubs/stub-on-any-instance-of-a-class

8
9
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
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?