I am having trouble testing my a few controllers using Rspec, especially those that use namespaces in their routes. Does anyone have an idea for why this is happening and how I can correct it? It's driving me crazy.
Here is my error. Failure/Error: get 'show' ActionController::RoutingError: No route matches {:controller=>"community/vendors", :action=>"show"}
Here is my controller.
class Community::VendorsController < ApplicationController
def show
@vendor = Vendor.find_by_uuid(params[:uuid])
render :file => "#{Rails.root}/public/404.html", :status => 404 if @vendor.nil?
end
end
Here is my spec.
describe Community::VendorsController do
let(:vendor){FactoryGirl.create(:vendor)}
before(:each) do
@user = FactoryGirl.create(:vendor_single_user)
sign_in @user
end
it 'should return 404 if no vendor found' do
Vendor.stub(:find_by_uuid => nil)
get 'show'
response[:status].should == 404
end
end
Here are the routes.
namespace :community do
get ':uuid/intake' => 'vendors#show'
put ':uuid/intake/' => 'vendors#update'
get ':uuid/check-email' => 'vendors#check_email'
end