在 Rails 3.2.9 中,我有这样的自定义错误页面定义:
# application.rb
config.exceptions_app = self.routes
# routes.rb
match '/404' => 'errors#not_found'
哪个像预期的那样工作。当我进入时config.consider_all_requests_local = false
,development.rb
我会not_found
在参观时看到风景/foo
但是如何使用 Rspec + Capybara 进行测试?
我试过这个:
# /spec/features/not_found_spec.rb
require 'spec_helper'
describe 'not found page' do
it 'should respond with 404 page' do
visit '/foo'
page.should have_content('not found')
end
end
当我运行这个规范时,我得到:
1) not found page should respond with 404 page
Failure/Error: visit '/foo'
ActionController::RoutingError:
No route matches [GET] "/foo"
我该如何测试呢?
编辑:
忘了说:我已经config.consider_all_requests_local = false
进去了test.rb