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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bc08b3f8d4765b5663ba6ffb9ce05ebc283bba3
4
- data.tar.gz: 5816acdf0d73ae05618319fd0e8d86789379c932
3
+ metadata.gz: edb8884b4c542041879eeda795a83633bbc167f3
4
+ data.tar.gz: 43d6478d4c8376549bc606c21e2c6d7880e89be2
5
5
  SHA512:
6
- metadata.gz: b7b2cd702a64a27d7178d87134eaaff6fe1fccb354579b71b00a68bf5eb3e33289abb81da639d4e4a03bdb7ade20eeb62b9c98e91fc1af64d270e86482f27204
7
- data.tar.gz: 1b3d9639556d82a5df749226f2047115fc651f3d52012e3729af1ec1fe4de7043c3b6a17e7f62f25ebea2c5b8962b547affc0c281e504f69dd54fb8e23baafba
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
- if params.is_a? Hash
79
- opts[:params] = driver.with_params.merge(params)
80
- else
81
- opts[:params] = driver.with_params
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
@@ -80,4 +80,12 @@ class Capybara::Typhoeus::Driver < Capybara::RackTest::Driver
80
80
  browser.json
81
81
  end
82
82
 
83
+ def request_body
84
+ browser.request_body
85
+ end
86
+
87
+ def request_body=(value)
88
+ browser.request_body = value
89
+ end
90
+
83
91
  end
@@ -34,4 +34,12 @@ class Capybara::Typhoeus::Session < Capybara::Session
34
34
  url
35
35
  end
36
36
 
37
+ def request_body
38
+ driver.request_body
39
+ end
40
+
41
+ def request_body=(value)
42
+ driver.request_body = value
43
+ end
44
+
37
45
  end
@@ -47,9 +47,9 @@ describe Capybara::Typhoeus::Session do
47
47
  end
48
48
 
49
49
  context "timeout" do
50
- context "default" do
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
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph HALTER