capybara-typhoeus 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/capybara/driver/typhoeus_driver.rb +18 -5
- metadata +6 -6
@@ -8,7 +8,7 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
attr_writer :as, :with_headers, :with_params, :with_options
|
11
|
-
attr_reader :app, :rack_server, :options, :response
|
11
|
+
attr_reader :app, :rack_server, :options, :response, :login, :password
|
12
12
|
|
13
13
|
def client
|
14
14
|
@client ||= Typhoeus::Hydra.new
|
@@ -88,7 +88,7 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
88
88
|
alias_method :source, :body
|
89
89
|
|
90
90
|
def response_headers
|
91
|
-
response.
|
91
|
+
response.headers
|
92
92
|
end
|
93
93
|
|
94
94
|
def status_code
|
@@ -103,6 +103,8 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
103
103
|
@client = nil
|
104
104
|
@response = nil
|
105
105
|
@current_uri = nil
|
106
|
+
@login = nil
|
107
|
+
@password = nil
|
106
108
|
reset_cache
|
107
109
|
end
|
108
110
|
|
@@ -128,13 +130,27 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
128
130
|
@with_options ||= {}
|
129
131
|
end
|
130
132
|
|
133
|
+
def authenticate_with(login, password)
|
134
|
+
@login, @password = login, password
|
135
|
+
end
|
136
|
+
|
137
|
+
def auth?
|
138
|
+
login && password
|
139
|
+
end
|
140
|
+
|
131
141
|
def process(method, path, params = {}, headers = {})
|
132
142
|
@current_uri = url path
|
133
143
|
opts = {
|
134
144
|
:method => method,
|
135
145
|
:headers => with_headers.merge(headers.merge("Content-Type" => as, "Accept" => as)),
|
136
146
|
:timeout => 2000, # 2 seconds
|
147
|
+
:forbid_reuse => true,
|
137
148
|
}
|
149
|
+
opts.merge!({
|
150
|
+
:username => login,
|
151
|
+
:password => password,
|
152
|
+
:auth_method => :basic,
|
153
|
+
}) if auth?
|
138
154
|
if params.is_a?(Hash)
|
139
155
|
opts[:params] = with_params.merge(params)
|
140
156
|
else
|
@@ -144,11 +160,8 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
144
160
|
request = Typhoeus::Request.new @current_uri, with_options.merge(opts)
|
145
161
|
client.queue request
|
146
162
|
client.run
|
147
|
-
# $stdout.puts request.inspect
|
148
163
|
@response = request.response
|
149
|
-
# $stdout.puts response.inspect
|
150
164
|
if @response.timed_out?
|
151
|
-
`open #{@current_uri}`
|
152
165
|
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: time out"
|
153
166
|
elsif @response.code==0
|
154
167
|
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: #{@response.curl_error_message}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-typhoeus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -33,17 +33,17 @@ dependencies:
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - '='
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.
|
38
|
+
version: 0.5.0
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - '='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.5.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yajl-ruby
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
segments:
|
154
154
|
- 0
|
155
|
-
hash:
|
155
|
+
hash: 3275742578761015137
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
none: false
|
158
158
|
requirements:
|