プロジェクトにSubdomain-fuを追加しました。ApplicationControllerには、URLをチェックしてapp.comをwww.app.comに、www.subdomain.app.comをsubdomain.app.comにリダイレクトし、アカウントの存在をチェックするbefore_filterがあります(存在しない場合はホームにリダイレクトします)。
before_filter :check_uri
def check_uri
if !subdomain?
redirect_to http_protocol + "www." + current_host + request.request_uri if !/^www\./.match(current_host)
elsif /^www\./.match(current_host)
redirect_to http_protocol + current_host.gsub(/^www\./, '') + request.request_uri
elsif !account_subdomain?
redirect_to http_protocol + "www" + current_host.gsub(account_subdomain, '')
end
end
上記のコードはかなりうまく機能します。しかし、このスニペットを追加した後、私のキュウリはテストします。これです:
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!"'
これをbefore_filterとコメントすると、すべてがうまく機能します。誰かが理由を知っていますか?