0
,路線如下:爲什麼這個命名空間路由失敗?
namespace :admin do
get 'statistics', to: 'dashboard#statistics', as: :statistics
end
這裏的路由規格:
it 'routes to #statistics' do
expect(get: '/admin/statistics').to route_to 'admin/dashboard#statistics'
end
它通過完美。
然而,該控制器規範,使用上述路線,失敗:
RSpec.describe Admin::DashboardController, :type => :controller do
let(:user){ FactoryGirl.create :user }
let(:admin){ FactoryGirl.create :admin }
describe '#statistics:' do
let(:request){ get :statisitcs }
context 'When guest;' do
before { request }
describe 'response' do
subject { response }
its(:status){ should eq 302 }
its(:content_type){ should eq 'text/html' }
it{ should redirect_to 'new' }
end
end
end
end
的問題是:
1) Admin::DashboardController#statistics: When admin; response content_type
Failure/Error: let(:request){ get :statisitcs }
ActionController::UrlGenerationError:
No route matches {:action=>"statisitcs", :controller=>"admin/dashboard"}
,但不會路由規範證明這樣的路由存在?
*我的臉蛋* – Starkers 2014-08-30 09:33:45