LoginSignup
43
39

More than 5 years have passed since last update.

stubを使ったらDeprecation Warningが出た

Last updated at Posted at 2014-06-26
Using `stub` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead. Called from

こんなメッセージが出て、stub使うと怒られる。

controller.stub(:current_user).and_return(user)

こんなstubがあったら

allow(controller).to receive(:current_user).and_return(user)

こんな感じで変更すればOK

追記

raiseしたい場合は

allow(User).to receive(:find).and_raise(ActiveRecord::RecordNotFound)
43
39
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
43
39