Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created May 14, 2012 13:14
Show Gist options
  • Select an option

  • Save rtekie/2693866 to your computer and use it in GitHub Desktop.

Select an option

Save rtekie/2693866 to your computer and use it in GitHub Desktop.

Revisions

  1. rtekie revised this gist May 14, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions subdomains_spec.rb
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    require 'spec_helper'

    describe "Subdomains", :js => true do

    it "should test subdomain" do
    switch_to_subdomain("mysubdomain")
    visit root_path
  2. rtekie revised this gist May 14, 2012. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions subdomains_spec.rb
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # Sample spec file
    require 'spec_helper'

    describe "Subdomains", :js => true do
    it "should test subdomain" do
    switch_to_subdomain("mysubdomain")
    visit root_path
    end
    describe "Subdomains", :js => true do
    it "should test subdomain" do
    switch_to_subdomain("mysubdomain")
    visit root_path
    end

    end
  3. rtekie created this gist May 14, 2012.
    21 changes: 21 additions & 0 deletions subdomains.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Support for Rspec / Capybara subdomain integration testing
    # Make sure this file is required by spec_helper.rb
    #
    # Sample subdomain test:
    # it "should test subdomain" do
    # switch_to_subdomain("mysubdomain")
    # visit root_path
    # end

    DEFAULT_HOST = "lvh.me"
    DEFAULT_PORT = 9887

    RSpec.configure do |config|
    Capybara.default_host = "http://#{DEFAULT_HOST}"
    Capybara.server_port = DEFAULT_PORT
    Capybara.app_host = "http://#{DEFAULT_HOST}:#{Capybara.server_port}"
    end

    def switch_to_subdomain(subdomain)
    Capybara.app_host = "http://#{subdomain}.#{DEFAULT_HOST}:#{DEFAULT_PORT}"
    end
    10 changes: 10 additions & 0 deletions subdomains_spec.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Sample spec file
    require 'spec_helper'

    describe "Subdomains", :js => true do
    it "should test subdomain" do
    switch_to_subdomain("mysubdomain")
    visit root_path
    end

    end