Skip to content

Instantly share code, notes, and snippets.

@mkdynamic
Created November 26, 2009 20:46
Show Gist options
  • Save mkdynamic/243649 to your computer and use it in GitHub Desktop.
Save mkdynamic/243649 to your computer and use it in GitHub Desktop.
context "#domain" do
should "return correct domain from given host" do
examples = {
"foo.bar.mydomain.com" => "mydomain.com",
"foo.bar.www.mydomain.com" => "www.mydomain.com",
"foo.bar.www.mydomain.co.uk" => "www.mydomain.co.uk",
"www.mydomain.com" => "www.mydomain.com",
"foo.mydomain.co.uk" => "mydomain.co.uk",
"foo.bar.www.my-domain.com" => "www.my-domain.com",
"foo.m.net" => "m.net",
"foo-bar.mydomain.www.mydomain.co.uk" => "www.mydomain.co.uk",
"www.www.mydomain.com" => "www.mydomain.com"
}
examples.each do |host, domain|
@request.host = host
get :index
assert_equal domain, @controller.send(:domain)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment