Controller Specs - undefined local variable or method 'app'

On one of my projects using rspec 2.5 & rails 3.0.4, I recently moved
postgres to mongo and am using mongoid as the persistence library.

I ported all the models over to the mongoid way of doing things and now
all my models passing the tests.

None of the controller test work any more. They all fail with the
error message about undefined local variable or method.

Failure/Error: post :create, :account => {}

   undefined local variable or method `app' for

# ./spec/controllers/accounts_controller_spec.rb:84:in `block (4
levels) in <top (required)>’

Has anyone else run across this? Any ideas about how to fix it?


Not 100% sure, but that failure looks suspiciously like something you
get when using rack-test; which expects an ‘app’ method to be defined
that returns an instance of your rack-compatible application.

Your hunch looks correct - I ran it through the debugger last night and
found the spot where it was failing in rack-test although I don’t know
it was failing.

I removed this line from my spec_helper.rb:

config.include Rack::Test::Methods

and it magically started working again.

Thanks for taking the time to look at it.


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