Aug 16, 2011 rails2 · rspec1 · rails · ruby · acceptance-testing · integration

Rails2/RSpec1 subdomain testing (with SubdomainFu)?

Just stub SubdomainFu.current_domain like this in your spec_helper (or test_helper)

class << SubdomainFu
  def current_subdomain= subdomain
    @current_subdomain = subdomain
  end
  alias original_current_subdomain current_subdomain
  def current_subdomain request
    @current_subdomain || original_current_subdomain(request)
  end
end

and in your specs before (or test setup):

SubdomainFu.current_subdomain = fair.domain

Note: This works for me with Rails2 + RSpec1 acceptance specs done with Steak and Capybara