capybara-typhoeus 0.5.1 → 0.6.0
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 +1 -0
- data/lib/capybara/typhoeus/driver.rb +11 -1
- data/spec/session/typhoeus_spec.rb +66 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26e640ff508b09fbfc06576cbdbb897b206ada1dfe57d31ec7ff416bb4018ae5
|
4
|
+
data.tar.gz: 6819055bb02895a56eff597358e6de6434ce21502c1494504dd2a779e57c2ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b6a0f1053763cc2373ec7d800bba199c3b235619adf6a881b6af2760b8eb56d39e2d21a04f7a8eea2af24f96cdea96b921afe79c97947508887a760e502c959
|
7
|
+
data.tar.gz: 9762988b272b898226c908d2859364296c3f8d12d8ff2e8f23d2fde8ba8e393cd5eebd283454ad2708316450dc5be1f4b51d8b4c1e5a3c878537f3c77a917154
|
@@ -86,6 +86,7 @@ class Capybara::Typhoeus::Browser < Capybara::RackTest::Browser
|
|
86
86
|
opts[:httpauth] = :basic
|
87
87
|
opts[:userpwd] = "#{driver.login}:#{driver.password}"
|
88
88
|
end
|
89
|
+
opts[:params_encoding] = params.delete(:params_encoding) || driver.params_encoding
|
89
90
|
opts[:params] = driver.with_params.merge(params)
|
90
91
|
if request_body
|
91
92
|
opts[:body] = request_body
|
@@ -1,11 +1,12 @@
|
|
1
1
|
class Capybara::Typhoeus::Driver < Capybara::RackTest::Driver
|
2
2
|
|
3
3
|
attr_writer :as, :with_headers, :with_params, :with_options
|
4
|
-
attr_reader :login, :password
|
4
|
+
attr_reader :login, :password, :params_encoding
|
5
5
|
|
6
6
|
def initialize(app, options = {})
|
7
7
|
raise ArgumentError, "typhoeus requires a rack application, but none was given" unless app
|
8
8
|
super app, {timeout: 3, forbid_reuse: true}.merge(options)
|
9
|
+
@params_encoding = :typhoeus
|
9
10
|
end
|
10
11
|
|
11
12
|
def browser
|
@@ -16,6 +17,15 @@ class Capybara::Typhoeus::Driver < Capybara::RackTest::Driver
|
|
16
17
|
true
|
17
18
|
end
|
18
19
|
|
20
|
+
PARAMS_ENCODING_ALLOWED_VALUES = [:typhoeus, :rack, :multi, :none]
|
21
|
+
def params_encoding=(value)
|
22
|
+
if PARAMS_ENCODING_ALLOWED_VALUES.include?(value)
|
23
|
+
@params_encoding = value
|
24
|
+
else
|
25
|
+
raise ArgumentError, "Allowed values are: #{PARAMS_ENCODING_ALLOWED_VALUES.map(&:inspect).join(", ")}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
19
29
|
[:get, :post, :put, :delete, :head, :patch, :request].each do |method|
|
20
30
|
define_method(method) do |url, params={}, headers={}, &block|
|
21
31
|
browser.reset_host!
|
@@ -37,6 +37,10 @@ Capybara::SpecHelper.run_specs TestSessions::TyphoeusTest, 'Typhoeus', capybara_
|
|
37
37
|
skip "Typhoeus driver doesn't support #select"
|
38
38
|
when /#unselect/
|
39
39
|
skip "Typhoeus driver doesn't support #unselect"
|
40
|
+
when /#has_css\? with spatial requirements/
|
41
|
+
skip "Typhoeus driver doesn't support #has_css? with spatial requirements"
|
42
|
+
when /#find with spatial filters/
|
43
|
+
skip "Typhoeus driver doesn't support #find with spatial filters"
|
40
44
|
when /has_css\? should support case insensitive :class and :id options/
|
41
45
|
skip "Nokogiri doesn't support case insensitive CSS attribute matchers"
|
42
46
|
end
|
@@ -91,6 +95,68 @@ RSpec.describe Capybara::Typhoeus::Session do
|
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
98
|
+
context "params encoding" do
|
99
|
+
context "setting on driver" do
|
100
|
+
let(:driver) { session.driver }
|
101
|
+
it "defaults to :typhoeus" do
|
102
|
+
expect( driver.params_encoding ).to eq :typhoeus
|
103
|
+
end
|
104
|
+
it "can be set to :rack, :multi or :none" do
|
105
|
+
driver.params_encoding = :rack
|
106
|
+
expect( driver.params_encoding ).to eq :rack
|
107
|
+
driver.params_encoding = :multi
|
108
|
+
expect( driver.params_encoding ).to eq :multi
|
109
|
+
driver.params_encoding = :none
|
110
|
+
expect( driver.params_encoding ).to eq :none
|
111
|
+
|
112
|
+
expect do
|
113
|
+
driver.params_encoding = :unknown
|
114
|
+
end.to raise_error ArgumentError, "Allowed values are: :typhoeus, :rack, :multi, :none"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
context "usage in requests" do
|
118
|
+
subject do
|
119
|
+
app = Sinatra.new do
|
120
|
+
get("/"){ params.inspect }
|
121
|
+
end
|
122
|
+
described_class.new :typhoeus, app
|
123
|
+
end
|
124
|
+
it "defaults to driver setting" do
|
125
|
+
subject.get "/", ids: [1, 2, 3]
|
126
|
+
expect( subject.body ).to eq '{"ids"=>{"0"=>"1", "1"=>"2", "2"=>"3"}}'
|
127
|
+
|
128
|
+
subject.driver.params_encoding = :rack
|
129
|
+
subject.get "/", ids: [1, 2, 3]
|
130
|
+
expect( subject.body ).to eq '{"ids"=>["1", "2", "3"]}'
|
131
|
+
|
132
|
+
subject.driver.params_encoding = :multi
|
133
|
+
subject.get "/", ids: [1, 2, 3]
|
134
|
+
expect( subject.body ).to eq '{"ids"=>"3"}'
|
135
|
+
|
136
|
+
subject.driver.params_encoding = :none
|
137
|
+
subject.get "/", ids: [1, 2, 3]
|
138
|
+
expect( subject.body ).to eq '{"ids"=>"[1, 2, 3]"}'
|
139
|
+
end
|
140
|
+
it "can be overriden per request" do
|
141
|
+
subject.driver.params_encoding = :none
|
142
|
+
|
143
|
+
subject.get "/", ids: [1, 2, 3], params_encoding: :typhoeus
|
144
|
+
expect( subject.body ).to eq '{"ids"=>{"0"=>"1", "1"=>"2", "2"=>"3"}}'
|
145
|
+
|
146
|
+
subject.get "/", ids: [1, 2, 3], params_encoding: :rack
|
147
|
+
expect( subject.body ).to eq '{"ids"=>["1", "2", "3"]}'
|
148
|
+
|
149
|
+
subject.get "/", ids: [1, 2, 3], params_encoding: :multi
|
150
|
+
expect( subject.body ).to eq '{"ids"=>"3"}'
|
151
|
+
|
152
|
+
subject.driver.params_encoding = :typhoeus
|
153
|
+
|
154
|
+
subject.get "/", ids: [1, 2, 3], params_encoding: :none
|
155
|
+
expect( subject.body ).to eq '{"ids"=>"[1, 2, 3]"}'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
94
160
|
context "timeout" do
|
95
161
|
subject{ described_class.new :typhoeus, TestApp }
|
96
162
|
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph HALTER
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|