Trevoke (trevoke) wrote,

Devise + rspec error: undefined method ‘name’

If you’re using Devise and rspec on Rails 3, and you want to override a controller, and you end up with an error that makes no sense whatsoever:

“Undefined method ‘name’ for nil:NilClass”, well then, you probably want to add the following line to your tests:

@request.env["devise.mapping"] = Devise.mappings[:admin]

Yeah… That took me way longer than expected.

On a COMPLETELY UNRELATED SIDE NOTE, pry is pretty cool when you end up having to step through code…

Mirrored from Seven steps.

Tags: devise, programming, rails, rails 3, rspec, ruby
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded