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