2
votes

I want to test my namespaced controllers but when I raise controller nothing raised and test is passing. I get no routes error. They all work fine. But it must raise error. Actually it must call index action but it does not. What is the cause?

dashboard_controller_spec.rb

require 'spec_helper'

describe Admin::DashboardController do
    it "gets index" do 
        get :index
    end
end

routes.rb

namespace :admin do
    match 'dashboard'    => 'dashboard#index',       :as => :dashboard
end

dashboard_controller.rb

class Admin::DashboardController < Admin::ApplicationController
    def index
        raise "asd"
    end
end
1

1 Answers

0
votes

Hi you can write the route path as follow so get index action

describe :route do
      subject { {get: "/Admin/dashboardes"} }
      it { should route_to(controller: "Admin/dashboardes", action: "index") }
end

like example :

  describe "#index" do
    describe :route do
      subject { {get: "/administration/users"} }
        it { should route_to(controller: "administration/users", action: "index") }
      end
    end