There seems to be a lot of confusion about this. The tl;dr summary is that this rails commit claims that the reason this is hard “stems from the fact that subdomain is defined in ActionDispatch:Request and the test session uses Rack::Request”. The solution was to “Extend assert_recognizes and assert_generates to support passing full urls as the path argument. This allows testing of routing constraints such as subdomain and host within functional tests.”
So your code should read as:
describe "GET /index_exists" do it "works! (now write some real specs)" do get "http://subdomain.domain.com" response.status.should be(200) end end
—
So that’s a solution. Let’s talk about the problems. If you search for rails integration test subdomains, the first link is for a stackoverflow question and answer that suggests the following:
def setup host! "my.host" end
When I try this, I get:
No route matches [GET] “<no hostname>/path”
—