Ruby on rails Cucumber/webrat测试在添加子域fu和重定向功能后失败
我在我的项目中添加了子域fu。在ApplicationController中,我有一个before_筛选器,它检查url并将app.com重定向到www.app.com,将www.subdomain.app.com重定向到subdomain.app.com并检查帐户是否存在(如果不存在,则重定向到主页): 上面的代码非常好用。但是在添加了这个片段之后,我的Cumber测试,例如:Ruby on rails Cucumber/webrat测试在添加子域fu和重定向功能后失败,ruby-on-rails,cucumber,redirect,webrat,subdomain-fu,Ruby On Rails,Cucumber,Redirect,Webrat,Subdomain Fu,我在我的项目中添加了子域fu。在ApplicationController中,我有一个before_筛选器,它检查url并将app.com重定向到www.app.com,将www.subdomain.app.com重定向到subdomain.app.com并检查帐户是否存在(如果不存在,则重定向到主页): 上面的代码非常好用。但是在添加了这个片段之后,我的Cumber测试,例如: Scenario: Successful sign up Given I am an anonymous
Scenario: Successful sign up
Given I am an anonymous user
And an Accept Language header
And I am on the home page
When I follow "Join now!"
And ...
因错误而失败:
Webrat::NotFoundError: Could not find link with text or title or id "Join now!"
(eval):2:in `/^I follow "([^\"]*)"$/'
features/manage_users.feature:10:in `When I follow "Join now!"'
如果我在过滤前对此进行评论,一切都会很好。
有人知道为什么吗?我可以看出,Webrat非常喜欢域“example.com”,并模仿它的所有步骤 因此,如果不使用子域,可以在步骤中编写:
Before do
host! "example.com"
end
你所有的重定向都应该有效(我不检查)。
子域fu的情况更糟。要正确配置子域fu配置文件,请执行以下操作:
SubdomainFu.tld_sizes = {:development => 0,
:test => 1, # not 0, even if you use *.localhost in development
:production => 1}
在没有任何主机的情况下,重定向测试也可以正常工作!“example.com”
SubdomainFu.tld_sizes = {:development => 0,
:test => 1, # not 0, even if you use *.localhost in development
:production => 1}