frameworks-capybara 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +0 -2
- data/Gemfile.lock +1 -1
- data/lib/frameworks/capybara.rb +1 -0
- data/lib/monkey-patches/net-http-persistent-patches.rb +72 -0
- data/lib/monkey-patches/webdriver-patches.rb +26 -0
- data/lib/version.rb +1 -1
- metadata +5 -4
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/frameworks/capybara.rb
CHANGED
@@ -4,6 +4,7 @@ require 'monkey-patches/capybara-patches'
|
|
4
4
|
require 'monkey-patches/capybara-mechanize-patches'
|
5
5
|
require 'monkey-patches/mechanize-patches'
|
6
6
|
require 'monkey-patches/send-keys'
|
7
|
+
require 'monkey-patches/net-http-persistent-patches'
|
7
8
|
require 'selenium-webdriver'
|
8
9
|
require 'capybara/mechanize/cucumber'
|
9
10
|
require 'capybara/celerity'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#Adding no_proxy_host logic for Mechanize2 which uses this
|
2
|
+
#gem for it's HTTP client logic
|
3
|
+
#TODO: Grab from envirnment variable optionally, or provide list
|
4
|
+
class Net::HTTP::Persistent
|
5
|
+
|
6
|
+
##
|
7
|
+
# Creates a new connection for +uri+
|
8
|
+
def connection_for uri
|
9
|
+
Thread.current[@generation_key] ||= Hash.new { |h,k| h[k] = {} }
|
10
|
+
Thread.current[@ssl_generation_key] ||= Hash.new { |h,k| h[k] = {} }
|
11
|
+
Thread.current[@request_key] ||= Hash.new 0
|
12
|
+
Thread.current[@timeout_key] ||= Hash.new EPOCH
|
13
|
+
|
14
|
+
use_ssl = uri.scheme.downcase == 'https'
|
15
|
+
|
16
|
+
if use_ssl then
|
17
|
+
ssl_generation = @ssl_generation
|
18
|
+
|
19
|
+
ssl_cleanup ssl_generation
|
20
|
+
|
21
|
+
connections = Thread.current[@ssl_generation_key][ssl_generation]
|
22
|
+
else
|
23
|
+
generation = @generation
|
24
|
+
|
25
|
+
cleanup generation
|
26
|
+
|
27
|
+
connections = Thread.current[@generation_key][generation]
|
28
|
+
end
|
29
|
+
|
30
|
+
net_http_args = [uri.host, uri.port]
|
31
|
+
connection_id = net_http_args.join ':'
|
32
|
+
#
|
33
|
+
#Frameworks patch (and condition)
|
34
|
+
if @proxy_uri and !uri.host.include? 'sandbox' then
|
35
|
+
connection_id << @proxy_connection_id
|
36
|
+
net_http_args.concat @proxy_args
|
37
|
+
end
|
38
|
+
|
39
|
+
connection = connections[connection_id]
|
40
|
+
|
41
|
+
unless connection = connections[connection_id] then
|
42
|
+
connections[connection_id] = http_class.new(*net_http_args)
|
43
|
+
connection = connections[connection_id]
|
44
|
+
ssl connection if use_ssl
|
45
|
+
else
|
46
|
+
reset connection if expired? connection
|
47
|
+
end
|
48
|
+
|
49
|
+
unless connection.started? then
|
50
|
+
connection.set_debug_output @debug_output if @debug_output
|
51
|
+
connection.open_timeout = @open_timeout if @open_timeout
|
52
|
+
connection.read_timeout = @read_timeout if @read_timeout
|
53
|
+
|
54
|
+
connection.start
|
55
|
+
|
56
|
+
socket = connection.instance_variable_get :@socket
|
57
|
+
|
58
|
+
if socket then # for fakeweb
|
59
|
+
@socket_options.each do |option|
|
60
|
+
socket.io.setsockopt(*option)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
connection
|
66
|
+
rescue Errno::ECONNREFUSED
|
67
|
+
raise Error, "connection refused: #{connection.address}:#{connection.port}"
|
68
|
+
rescue Errno::EHOSTDOWN
|
69
|
+
raise Error, "host down: #{connection.address}:#{connection.port}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -33,3 +33,29 @@ module Selenium
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
#Workaround for http://code.google.com/p/selenium/issues/detail?id=4007
|
38
|
+
module Selenium
|
39
|
+
module WebDriver
|
40
|
+
module Remote
|
41
|
+
module Http
|
42
|
+
class Default
|
43
|
+
def new_http_client
|
44
|
+
if @proxy
|
45
|
+
unless @proxy.respond_to?(:http) && url = @proxy.http
|
46
|
+
raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
|
47
|
+
end
|
48
|
+
|
49
|
+
proxy = URI.parse(url)
|
50
|
+
|
51
|
+
clazz = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)
|
52
|
+
clazz.new(server_url.host, server_url.port)
|
53
|
+
else
|
54
|
+
Net::HTTP.new server_url.host, server_url.port
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frameworks-capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 9
|
10
|
+
version: 0.2.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- matt robbins
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-06 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/monkey-patches/capybara-patches.rb
|
166
166
|
- lib/monkey-patches/cucumber-patches.rb
|
167
167
|
- lib/monkey-patches/mechanize-patches.rb
|
168
|
+
- lib/monkey-patches/net-http-persistent-patches.rb
|
168
169
|
- lib/monkey-patches/send-keys.rb
|
169
170
|
- lib/monkey-patches/webdriver-patches.rb
|
170
171
|
- lib/tasks/frameworks-tasks.rb
|