title: Rails: Why does RSpec crash on my overridden Devise controller request spec?
body: <p><strong>Update:</strong> Oh good grief, it was all a red herring following a bad merge. Somewhere along the line, the following for elided from a cleanup of spec/spechelper.rb</p>
  
  <pre><code>Dir["#{Rails.root}/app/**/*.rb"].each {|f| load f}
  </code></pre>
  
  <p>Now that this is restored, everything is working again. I suspect it was only load the flat dir, and not nested dirs, making it <em>look</em> like a namespace issue.</p>
  
  <p>(I can't answer my own question as this is a new account, and I don't have the rep)</p>
  
  <hr>
  
  <p>Original question:</p>
  
  <p>Most of my RSpec/Capybara tests work fine, but I have <em>one</em> test that explodes on simply trying to visit a path, and I'm stuck on debugging.  I <em>suspect</em> it's a Namespace issue but I don't know how to address that; any help gratefully received. </p>
  
  <p>The entire test is:</p>
  
  <pre><code>require 'spec_helper'
  describe 'Registrations' do
    context 'when debugging the blocking issue' do
      it 'this minimal test should pass' do
        visit new_user_registration_path
      end
    end
  end
  </code></pre>
  
  <p>The error message is:</p>
  
  <blockquote>
    <p>$ bin/rspec spec/requests/users/registrations_spec.rb</p>
    
    <p>Failures:</p>
    
    <p>1) Users::Registrations when debugging the blocking issue this minimal test should pass
        Failure/Error: visit new_user_registration_path
        LoadError:
          Expected app/controllers/users/registrations_controller.rb to define Users::RegistrationsController
        # ./spec/requests/users/registrations_spec.rb:10:in `block (3 levels) in '</p>
  </blockquote>
  
  <p>So the error is <strong>Expected users/registrations_controller.rb to define Users::RegistrationsController</strong>, that's not much help!</p>
  
  <p>The controller is an overridden Devise controller, and it looks like:</p>
  
  <pre><code>class Users::RegistrationsController &lt; Devise::RegistrationsController
    def create
      super
      # My extra code here
    end
  end
  </code></pre>
  
  <p>My routes redirect devise a little:</p>
  
  <pre><code>devise_for :users, :controllers =&gt; { :registrations =&gt; 'users/registrations' } do
    get '/users/sign_out' =&gt; 'devise/sessions#destroy'
  end
  </code></pre>
  
  <p>I'm utterly stuck on trying to find a root cause for the 'Expected foo.rb to define Foo' error'; I can't get an insight into what's really causing my issue. </p>
  
  <p>What would you do next to debug this?</p>
  
  <hr>
  
  <p>David suggested a backtrace might help; as far as I can see, I don't have an error preventing loading, looks to me (but I'm a rails noob) like all ActiveSupport blocks. Here it is for interest:</p>
  
  <pre>
    1) Users::Registrations when debugging the blocking issue this minimal test should pass
       Failure/Error: visit new_user_registration_path
  
       LoadError:
         Expected app/controllers/users/registrations_controller.rb to define Users::RegistrationsController
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:490:in `load_missing_constant'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `block in const_missing'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:124:in `block in constantize'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `each'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `constantize'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:528:in `block in initialize'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `yield'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `default'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `[]'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:61:in `controller_reference'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:46:in `controller'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:25:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/routing/mapper.rb:41:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:110:in `optimized_each'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:531:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/sass-3.1.12/lib/sass/plugin/rack.rb:54:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/warden-1.1.0/lib/warden/manager.rb:35:in `block in call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/warden-1.1.0/lib/warden/manager.rb:34:in `catch'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/warden-1.1.0/lib/warden/manager.rb:34:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/etag.rb:23:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/conditionalget.rb:25:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/head.rb:14:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/flash.rb:243:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/cookies.rb:326:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activerecord-3.1.0/lib/active_record/query_cache.rb:62:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/sendfile.rb:101:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/railties-3.1.0/lib/rails/rack/logger.rb:13:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/runtime.rb:17:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/activesupport-3.1.0/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/lock.rb:15:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/actionpack-3.1.0/lib/action_dispatch/middleware/static.rb:53:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/railties-3.1.0/lib/rails/engine.rb:455:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/urlmap.rb:52:in `block in call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/urlmap.rb:46:in `each'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-1.3.5/lib/rack/urlmap.rb:46:in `call'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-test-0.6.1/lib/rack/mock_session.rb:30:in `request'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-test-0.6.1/lib/rack/test.rb:219:in `process_request'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rack-test-0.6.1/lib/rack/test.rb:57:in `get'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:62:in `process'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:21:in `visit'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb:32:in `visit'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
       # ./spec/requests/users/registrations_spec.rb:10:in `block (3 levels) in '
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example.rb:51:in `instance_eval'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example.rb:51:in `block in run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example.rb:110:in `with_around_hooks'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example.rb:48:in `run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:306:in `block in run_examples'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:302:in `map'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:302:in `run_examples'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:274:in `run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:275:in `block in run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:275:in `map'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/example_group.rb:275:in `run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:24:in `map'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:24:in `block in run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/reporter.rb:12:in `report'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:21:in `run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:66:in `rescue in run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:62:in `run'
       # .rvm/gems/ruby-1.9.3-p0@foo/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
  
  </pre>