Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 673
bobomoreno Avatar asked Jun 11 '14 20:06

bobomoreno


1 Answers

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

Notable Changes in RSpec 3

like image 95
dre-hh Avatar answered Oct 02 '22 10:10

dre-hh