【发布时间】:2016-04-28 18:38:54
【问题描述】:
当我为我的应用程序创建功能测试时,出现以下错误:
ActionController::RoutingError:
No route matches [GET] "/example"
我的应用程序在这些子域中使用子域和子应用程序(引擎/模块)。现在,当我通过 feature_subdomain_helper 为 Capybara 设置 app_host 或 default_host 时
Capybara.app_host = "example.lvh.me" or
Capybara.default_host = "example.lvh.me"
并在我的 rails_helper.rb 中添加以下代码行
config.extend SubdomainHelpers, type: :feature
我得到同样的错误。现在我认为我的功能测试没有考虑配置的子域。
我的 Rspec 版本是:3.2 而Capybara版本是:2.4.4
我的示例功能测试如下所示:
require 'rails_helper'
feature 'Example Page' do
scenario 'visit example page' do
visit "/example"
expect(page).to have_content 'Example'
end
end
有人知道我做错了什么吗?
编辑: 主应用路由:
constraints(Subdomain) do
mount Example::Engine => '/', as: 'example'
end
引擎路线:
Example::Engine.routes.draw do
scope '/example', nav_scope: 'example' do
end
end
【问题讨论】:
-
你的 routes.rb 是什么样子的?
-
添加路线条目//已编辑
标签: ruby-on-rails-4 rspec capybara subdomain rspec-rails