capybara-typhoeus 0.3.2 → 0.3.3
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.
- checksums.yaml +4 -4
- data/lib/capybara/typhoeus/browser.rb +5 -5
- data/lib/capybara/typhoeus/driver.rb +8 -0
- data/lib/capybara/typhoeus/session.rb +8 -0
- data/spec/session/typhoeus_spec.rb +28 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb8884b4c542041879eeda795a83633bbc167f3
|
4
|
+
data.tar.gz: 43d6478d4c8376549bc606c21e2c6d7880e89be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f1bcf2f21aa51973fc86516d719c5c643435a0898e7efe2ca105c93c417f5d2f6012a6d0745386b742c7e147f5e57b1d0dbd0a276c0c3f02d8ce06dd3c8a0a2
|
7
|
+
data.tar.gz: fa128e1af2746c0ff908f16d5d5e564b24c003d9d25a428b0c21648b199b3dd644d5ec6b27c5b650270e21d9375ac7d0a3c20ae434fba81172a0c4e684d82342
|
@@ -12,6 +12,7 @@ end
|
|
12
12
|
|
13
13
|
class Capybara::Typhoeus::Browser < Capybara::RackTest::Browser
|
14
14
|
|
15
|
+
attr_accessor :request_body
|
15
16
|
attr_reader :last_response, :client
|
16
17
|
|
17
18
|
def initialize(driver)
|
@@ -75,11 +76,10 @@ class Capybara::Typhoeus::Browser < Capybara::RackTest::Browser
|
|
75
76
|
opts[:httpauth] = :basic
|
76
77
|
opts[:userpwd] = "#{driver.login}:#{driver.password}"
|
77
78
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
opts[:body] = params
|
79
|
+
opts[:params] = driver.with_params.merge(params)
|
80
|
+
if request_body
|
81
|
+
opts[:body] = request_body
|
82
|
+
@request_body = nil
|
83
83
|
end
|
84
84
|
request = Typhoeus::Request.new uri.to_s, opts
|
85
85
|
client.queue request
|
@@ -47,9 +47,9 @@ describe Capybara::Typhoeus::Session do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
context "timeout" do
|
50
|
-
|
51
|
-
subject{ described_class.new :typhoeus, TestApp }
|
50
|
+
subject{ described_class.new :typhoeus, TestApp }
|
52
51
|
|
52
|
+
context "default" do
|
53
53
|
it "is 3 seconds" do
|
54
54
|
subject.driver.options[:timeout].should == 3
|
55
55
|
end
|
@@ -89,5 +89,31 @@ describe Capybara::Typhoeus::Session do
|
|
89
89
|
subject.host_url("http://www.example.com:443/demo/test").should == "http://www.example.com:443/demo/test"
|
90
90
|
end
|
91
91
|
end
|
92
|
+
|
93
|
+
context "can upload file by setting the body per request" do
|
94
|
+
subject do
|
95
|
+
app = Sinatra.new do
|
96
|
+
post("/"){ request.body }
|
97
|
+
end
|
98
|
+
described_class.new :typhoeus, app
|
99
|
+
end
|
100
|
+
|
101
|
+
it "body is nil be default" do
|
102
|
+
subject.request_body.should be_nil
|
103
|
+
subject.post "/"
|
104
|
+
subject.status_code.should be 200
|
105
|
+
subject.source.should == ""
|
106
|
+
end
|
107
|
+
|
108
|
+
it "I can send data by setting the body" do
|
109
|
+
body = "**raw file content**"
|
110
|
+
subject.request_body = body
|
111
|
+
subject.request_body.should == body
|
112
|
+
subject.post "/"
|
113
|
+
subject.status_code.should be 200
|
114
|
+
subject.source.should == body
|
115
|
+
subject.request_body.should be_nil
|
116
|
+
end
|
117
|
+
end
|
92
118
|
end
|
93
119
|
end
|