Module: Sauce::Capybara

Defined in:
lib/sauce/capybara.rb

Defined Under Namespace

Classes: Driver

Class Method Summary collapse

Class Method Details

.configure_capybaraObject


116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/sauce/capybara.rb', line 116

def self.configure_capybara
  ::Capybara.configure do |config|
    if Sauce::Config.new[:start_local_application]
      config.server_port = Sauce::Config.get_application_port
    end
    begin
      #config.always_include_port = true
    rescue
      # This option is only in Capybara 2+
    end
  end
end

.configure_capybara_for_rspecObject


129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/sauce/capybara.rb', line 129

def self.configure_capybara_for_rspec
  begin
    require "rspec/core"
    ::RSpec.configure do |config|
      config.before :suite do 
        ::Capybara.configure do |capy_config|
          sauce_config = Sauce::Config.new
          if capy_config.app_host.nil?
            if sauce_config[:start_local_application]
              host = sauce_config[:application_host] || "127.0.0.1"
              port = sauce_config[:application_port]
              capy_config.app_host = "http://#{host}:#{port}"
              capy_config.run_server = false
            end
          end
        end
      end
    end
  rescue LoadError => e
    # User is not using RSpec
  end
end