capybara-typhoeus 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,10 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
16
16
|
|
17
17
|
def initialize(app, options={})
|
18
18
|
@app = app
|
19
|
-
@options =
|
19
|
+
@options = {
|
20
|
+
:timeout => 3, # 3 seconds
|
21
|
+
:forbid_reuse => true,
|
22
|
+
}.merge options
|
20
23
|
@rack_server = Capybara::Server.new(@app)
|
21
24
|
@rack_server.boot if Capybara.run_server
|
22
25
|
end
|
@@ -143,9 +146,7 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
143
146
|
opts = {
|
144
147
|
:method => method,
|
145
148
|
:headers => with_headers.merge(headers.merge("Content-Type" => as, "Accept" => as)),
|
146
|
-
|
147
|
-
:forbid_reuse => true,
|
148
|
-
}
|
149
|
+
}.merge(options)
|
149
150
|
opts.merge!({
|
150
151
|
:userpwd => "#{login}:#{password}",
|
151
152
|
:httpauth => :basic,
|
@@ -161,9 +162,9 @@ class Capybara::Driver::Typhoeus < Capybara::Driver::Base
|
|
161
162
|
client.run
|
162
163
|
@response = request.response
|
163
164
|
if @response.timed_out?
|
164
|
-
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: time out"
|
165
|
+
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: time out" if $DEBUG
|
165
166
|
elsif @response.code==0
|
166
|
-
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: #{@response.curl_error_message}"
|
167
|
+
$stderr.puts "#{method.to_s.upcase} #{@current_uri}: #{@response.curl_error_message}" if $DEBUG
|
167
168
|
end
|
168
169
|
@response
|
169
170
|
end
|
@@ -37,4 +37,36 @@ describe Capybara::Driver::Typhoeus do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
context "timeout" do
|
41
|
+
context "default" do
|
42
|
+
subject do
|
43
|
+
driver = described_class.new TestApp
|
44
|
+
end
|
45
|
+
|
46
|
+
it "is 3 seconds" do
|
47
|
+
subject.options[:timeout].should == 3
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is used during request" do
|
51
|
+
response = subject.get "/slow_response"
|
52
|
+
response.should_not be_timed_out
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "accepts custom timeout" do
|
57
|
+
subject do
|
58
|
+
driver = described_class.new TestApp, timeout: 1
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is stored in options" do
|
62
|
+
subject.options[:timeout].should == 1
|
63
|
+
end
|
64
|
+
|
65
|
+
it "is used during request" do
|
66
|
+
response = subject.get "/slow_response"
|
67
|
+
response.should be_timed_out
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
40
72
|
end
|
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.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -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: 780856206997500836
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
none: false
|
158
158
|
requirements:
|