Hi,
I am testing views. I dont understand why stubs are not working.
Can anyone help.
view code :
before(:all) do
@current_user = stub(“User”)
assigns[:message] = @current_user
end
output:
NoMethodError:
undefined method `stub’ for #<RSpec::Cor
On Fri, May 24, 2013 at 8:07 AM, Aashish K. [email protected]
wrote:
output:
NoMethodError:
undefined method `stub’ for #<RSpec::Cor
Mocks and stubs are not meant to be used in before(:all)
. Mocks and
stubs are reset after every example; therefore, using them in
before(:all)
does not make too much sense.
I suggest you switch to using before(:each)
(or just before
which
is the same thing). In general, use before(:each)
and avoid
before(:all)
unless you know exactly what you’re doing. Tests that
bleed state or use global state are a big smell.
–
Andy Lindeman
http://www.andylindeman.com/