title: Rspec controller spec on namespaced controller finds the global controller with same name
body: <p>I have a weird issue when creating a controller spec for a namespaced controller when there also is a global controller with the same name. </p>
  
  <p>The controller names are <code>HomeController</code> and <code>Backend::HomeController</code>.</p>
  
  <p>Note that <strong>I have not yet created</strong> the file <code>app/controllers/backend/home_controller.rb</code>, only the global controller exists <code>app/controllers/home_controller.rb</code></p>
  
  <p>Therefore I expect the test to explode with errors, but it does not. It passes, all green and happy.</p>
  
  <p>My spec looks like this</p>
  
  <pre><code>#spec/controllers/backend/home_controller_spec.rb
  require 'rails_helper'
  
  RSpec.describe Backend::HomeController, type: :controller do
    before do
      user = FactoryGirl.create(:user)
      allow(controller).to receive(:authenticate_user!).and_return(true)
      allow(controller).to receive(:current_user).and_return(user)
    end
    describe "GET #index" do
      it "returns http success" do
        get :index
        expect(response).to have_http_status(:success)
      end
    end
  
  end
  </code></pre>
  
  <p>However if I change the name in my global <code>HomeController</code> to something else, e.g <code>NotMyHomeController</code> the test fails with errors saying</p>
  
  <pre><code>Unable to autoload constant HomeController, expected app/controllers/home_controller.rb to define it
  </code></pre>
  
  <p>Which makes me suspect that Rspec doesn't bother with the "Backend" part in the <code>Rspec.describe</code> function.</p>
  
  <p>Am I doing something wrong or am I missing some other vital part? IMHO, this spec shouldn't pass (to paraphrase Gandalf).</p>
  
  <p>I'm using Rails 4.2.6, Rspec-Rails 3.4.2</p>
  
  <p><strong>Update</strong></p>
  
  <p>As Max pointed out, this is probably not at Rspec issue but instead something with Rails autoloading.</p>
  
  <p>However i tried just typing</p>
  
  <pre><code>Backend::HomeController
  </code></pre>
  
  <p>In the Rails console, but there I get the expected error</p>
  
  <pre><code>NameError: uninitialized constant Backend::HomeController
  </code></pre>
  
  <p>And <a href="http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-availability" rel="nofollow">according to the Rails guide</a>, both the console and the test suite autoloads. However I think I'm on the right track here.</p>