[rspec-users] undefined local variable or method

Andy Lindeman alindeman at gmail.com
Tue Jun 11 00:21:09 UTC 2013


On Mon, Jun 10, 2013 at 6:45 PM, Guirec Corbel <guirec.corbel at gmail.com> wrote:
> Hi,
>
> I a controller spec like this :
> https://gist.github.com/GCorbel/5753042#file-painting_controller_spec_1-rb.
> (at the top). When I try to run this spec I have this message :
>
>      Failure/Error: before { painting.stub(:valid?).and_return(true) }
>      NameError:
>        undefined local variable or method ` painting' for
> #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x007fb7acbe5cb0>
>      # ./spec/controllers/painting_controller_spec.rb:10:in `block (4
> levels) in <top (required)>'
>
>
> But this spec :
> https://gist.github.com/GCorbel/5753042#file-painting_controller_spec_2-rb
> (at the bottom) works perfectly.
>
> In the context's before block, the painting seem not to be created. Did I do
> something wrong?
>
> Thanks!

Hi Guirec--

Can you make sure you are using rspec-rails 2.13.2 or greater?

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


More information about the rspec-users mailing list