Testing subdomains in Rails System tests


#1

My application is using subdomains and test them i have to rewrite Capybara.app_host in Rails System tests.

Here is a code i wrote that work locally on my machine, but fails on CircleCi:

Capybara.server_port = 7171

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :poltergeist, screen_size: [1400, 1400], options: { js_errors: true }

  def with_subdomain subdomain
    old_subdomain = Capybara.app_host
    Capybara.app_host = "http://#{subdomain}.localhost.dev:#{Capybara.server_port}"
    yield
  ensure
    Capybara.app_host = old_subdomain
  end
end

My build is failing with this error:

Request to ‘http://243343622.localhost.dev:7171/’ failed to reach server, check DNS and/or server status

I’ve tried tons of different variations and it still doesn’t work on CircleCI. Anyone has some clue I can test this?


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.