Search code examples
ruby-on-railsrspecrspec-rails

Rspec 3 upgrade issues with view.stub (Rails)


I'm upgrading my tests to Rspec3 (what a bother), removing all my 'shoulds', but I can't work out how to upgrade 'view.stub' in my view tests.

I am using devise

example:

view.stub(:current_user) { nil }

render

expect(rendered).to .... etc

This gives me a deprecation warning:

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 ....

I can't work out how to upgrade to the new 'improved' syntax. Thanks


Solution

  • allow(view).to receive_messages(current_user: nil)
    

    Notable Changes in RSpec 3