Redirect_to() says "undefined local variable or method `request'"

I’ve been doing my plugin and testing it with rspec. Let me show the
spec code first:

So, this spec lies in vendor/plugins/myplugin/spec/lib
The reason I set @controller, @request and @response in before(:all)
is because rspec complains they are not set (probably because I run
this test from plugin dir). Anyway, the error pops up on str 21, when
it tries to execute redirect_to(): undefined local variable or method
`request’. I’ve checked redirect_to source and I have no idea how to
pass it the ‘request’ variable.

Probably, the whole thing happens because I forgot to require/include
something (that’s why I have to set @controllers and others manually).
I wish it could just work as when it’s run from RAILS_ROOT/spec.

Any help or ideas, please?

Being more specific, the error message is:
undefined local variable or method `request’ for

It both appears if I run ‘spec spec/lib’ from plugin folder or rake
task ‘rake spec:plugins:myplugin’

Okay, solution found: never put specs that test controllers anywhere
but in ‘spec/controllers’ dir. Unless you know how to include
everything it needs to work.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs