On Fri, May 24, 2013 at 8:07 AM, Aashish Kiran <li...@ruby-forum.com> wrote:
> 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.

--
Andy Lindeman
http://www.andylindeman.com/

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BvJLftvPjPNg99BTGfqJdY8DPJMf8mjY_WqcryJvdvLM8YOwg%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to