Module: Capybara::Webmock
- Defined in:
- lib/capybara/webmock.rb,
lib/capybara/webmock/version.rb
Defined Under Namespace
Classes: Proxy
Constant Summary collapse
- VERSION =
"0.4.2"
Class Attribute Summary collapse
-
.port_number ⇒ Object
Returns the value of attribute port_number.
Class Method Summary collapse
- .chrome_switches ⇒ Object
- .firefox_profile ⇒ Object
- .phantomjs_options ⇒ Object
- .start ⇒ Object
- .stop ⇒ Object
Class Attribute Details
.port_number ⇒ Object
Returns the value of attribute port_number.
10 11 12 |
# File 'lib/capybara/webmock.rb', line 10 def port_number @port_number end |
Class Method Details
.chrome_switches ⇒ Object
37 38 39 |
# File 'lib/capybara/webmock.rb', line 37 def chrome_switches ["--proxy-server=127.0.0.1:#{port_number}"] end |
.firefox_profile ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/capybara/webmock.rb', line 26 def firefox_profile proxy_host = '127.0.0.1' profile = ::Selenium::WebDriver::Firefox::Profile.new profile["network.proxy.type"] = 1 profile["network.proxy.http"] = proxy_host profile["network.proxy.http_port"] = port_number profile["network.proxy.ssl"] = proxy_host profile["network.proxy.ssl_port"] = port_number profile end |
.phantomjs_options ⇒ Object
41 42 43 |
# File 'lib/capybara/webmock.rb', line 41 def ["--proxy=127.0.0.1:#{port_number}"] end |
.start ⇒ Object
12 13 14 15 16 17 |
# File 'lib/capybara/webmock.rb', line 12 def start log_file = File.join('log', 'test.log') gem_path = File.dirname(__FILE__) proxy_file = File.join(gem_path, 'webmock', 'config.ru') IO.popen("PROXY_PORT_NUMBER=#{port_number} rackup #{proxy_file} >> #{log_file} 2>&1") end |
.stop ⇒ Object
19 20 21 22 23 24 |
# File 'lib/capybara/webmock.rb', line 19 def stop if File.exist?(::Webmock::Proxy::PID_FILE) rack_pid = File.read(::Webmock::Proxy::PID_FILE).to_i Process.kill('HUP', rack_pid) end end |