mnyon-grandkru / knowledgebase

An issue tracker of error messages discovered while developing as well as their solution.
https://github.com/mnyon-grandkru/knowledgebase/issues
MIT License
2 stars 0 forks source link

Using `any_instance` from rspec-mocks' rspec-mocks deprecation warning #5

Closed trystant closed 6 years ago

trystant commented 6 years ago

Here's the full message from a spec run:

Deprecation Warnings:

Using `any_instance` 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 /home/ubuntu/workspace/spec/spec_helper.rb:28:in `login_as'.

If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

and the code in question:

   NewAdmin::Admin.any_instance.stub(:current_account).and_return(acct)
    NewAdmin::Admin.any_instance.stub(:logged_in?).and_return(true)
    NewAdmin::App.any_instance.stub(:current_account).and_return(acct)
    NewAdmin::App.any_instance.stub(:logged_in?).and_return(true)
trystant commented 6 years ago

The solution was to update the rspec syntax from any_instance to allow_any_instance_of