2013-06-26 169 views
2

我想測試我的命名空間控制器,但是當我提升控制器沒有提高和測試通過。我沒有得到路線錯誤。他們都很好。但它必須引發錯誤。實際上它必須調用索引操作,但它不會。原因是什麼?Rspec命名空間控制器失敗

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 

回答

0

嗨,你可以寫的路線路徑遵循這樣得到索引操作

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