Skip to content

Instantly share code, notes, and snippets.

@semaperepelitsa
Created October 24, 2013 13:25
Show Gist options
  • Save semaperepelitsa/7137278 to your computer and use it in GitHub Desktop.
Save semaperepelitsa/7137278 to your computer and use it in GitHub Desktop.
Functional test for subdomain locale engine
# encoding: UTF-8
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
Rails.backtrace_cleaner.remove_silencers!
class HelloControllerTest < ActionController::TestCase
def test_links
@request.host = "example.com"
get :world
menu = css_select("menu a")
assert_equal "http://www.example.com/", menu[0]["href"]
assert_equal "http://ru.example.com/", menu[1]["href"]
assert_equal "http://ua.example.com/", menu[2]["href"]
end
def test_default
@request.host = "www.example.com"
get :world
assert_response :ok
assert_select "p", "Hello"
end
def test_direct
@request.host = "ru.example.com"
get :world
assert_response :ok
assert_select "p", "Привет"
end
def test_custom
@request.host = "ua.example.com"
get :world
assert_response :ok
assert_select "p", "Привіт"
end
def test_other
skip "Should fall back to default?"
@request.host = "wtf.example.com"
get :world
assert_response :ok
assert_select "p", "Hello"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment