当我为我的应用程序创建功能测试时,会出现以下错误:
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
让某人知道我做错了什么?
编辑: Mainapp路线:
constraints(Subdomain) do
mount Example::Engine => '/', as: 'example'
end
引擎路线:
Example::Engine.routes.draw do
scope '/example', nav_scope: 'example' do
end
end
答案 0 :(得分:0)
Capybara.default_host和Capybara.app_host的名称略有误导,因为它们都需要设置为URL才能正常运行
Capybara.default_host = "http://example.lvh.me"
如果这不能解决您的问题,请检查rake routes
并确保您认为的操作已安装在' / example'真的是。