capybara-typhoeus 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52f3b94df91d387fd0497c1a1f774c4f4df7375e6eeee1b5949abfbdeb70ee24
4
- data.tar.gz: 7c06afed2246fac7ea2382be5edbeaf60bedb24a385a6249c78e2c9fb5e44072
3
+ metadata.gz: a75449aed1dfda86f9408839ea5773663f5e6003acffeabab56da064f6ea3245
4
+ data.tar.gz: bb467117bbe1443aea0a68103c16e8b0a7cc9a0494d1ebe1af4dab57ef4a2463
5
5
  SHA512:
6
- metadata.gz: 2c47183792966d74e52b71add37aba8c7300fcf877cc24a5a898e9aa65507bea423c20d2ce4cbc6805376aa155d441ecffff70316019134e7bab2d523dca3238
7
- data.tar.gz: f96e5e4a1f570d5a4a8f7275abb7e15d8cdd908cf6fb3eb5cbd08485747708dd28d3728e173cf6a8f36a9c19537f49603ffde82873be516c57cd20bec4109e00
6
+ metadata.gz: ca1628dd44027237678eba1ded8acff8e40c70723bbe34fb72a7d7c529e2492ce637f92e47d18e35d2932340512ffb410dc3e049cc4ea16b986c9e4b5629e4b9
7
+ data.tar.gz: 340cf912651cde51e4637c160af7ec66010e3a630e391a19df772564b14de831d19582227b3d8b1613b3c0ece4fc8fe8094d70394b359e5cf11a8e888563650e
data/README.md CHANGED
@@ -31,7 +31,7 @@ The following scenario will then be using the Typhoeus driver
31
31
  When you want to use this driver to test a remote application. You have to set the app_host:
32
32
 
33
33
  Capybara.app_host = "http://www.yourapp.com"
34
-
34
+
35
35
  Note that I haven't tested this case for my self yet. The Capybara tests pass for this situation though so it should work! Please provide me with feedback if it doesn't.
36
36
 
37
37
  ## Running tests
@@ -58,11 +58,11 @@ Everything related to submitting forms, clicking buttons, clicking checkboxes or
58
58
  Build Status
59
59
  ---------
60
60
 
61
- [![Build Status](http://travis-ci.org/TalentBox/capybara-typhoeus.png)](http://travis-ci.org/TalentBox/capybara-typhoeus)
61
+ ![Build Status](https://github.com/TalentBox/capybara-typhoeus/actions/workflows/ci.yml/badge.svg)
62
62
 
63
63
  Note on Patches/Pull Requests
64
64
  -----------------------------
65
-
65
+
66
66
  * Fork the project.
67
67
  * Make your feature addition or bug fix.
68
68
  * Add tests for it. This is important so I don't break it in a
@@ -73,4 +73,4 @@ Note on Patches/Pull Requests
73
73
 
74
74
  Copyright
75
75
  ---------
76
- Copyright (c) 2010 Tron Jonathan and HALTER Joseph. See LICENSE for details.
76
+ Copyright (c) 2010 Tron Jonathan and HALTER Joseph. See LICENSE for details.
@@ -36,7 +36,11 @@ class Capybara::Typhoeus::Browser < Capybara::RackTest::Browser
36
36
  end
37
37
 
38
38
  def current_url
39
- last_response ? last_response.effective_url : ""
39
+ return "" unless last_response
40
+
41
+ uri = build_uri(last_response.effective_url)
42
+ uri.fragment = @current_fragment if @current_fragment
43
+ uri.to_s
40
44
  end
41
45
 
42
46
  def dom
@@ -86,6 +90,7 @@ class Capybara::Typhoeus::Browser < Capybara::RackTest::Browser
86
90
  opts[:httpauth] = :basic
87
91
  opts[:userpwd] = "#{driver.login}:#{driver.password}"
88
92
  end
93
+ opts[:params_encoding] = params.delete(:params_encoding) || driver.params_encoding
89
94
  opts[:params] = driver.with_params.merge(params)
90
95
  if request_body
91
96
  opts[:body] = request_body
@@ -1,11 +1,13 @@
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
- def initialize(app, options = {})
6
+ def initialize(app, **options)
7
7
  raise ArgumentError, "typhoeus requires a rack application, but none was given" unless app
8
- super app, {timeout: 3, forbid_reuse: true}.merge(options)
8
+ option_with_default = {timeout: 3, forbid_reuse: true}.merge(options)
9
+ super app, **option_with_default
10
+ @params_encoding = :typhoeus
9
11
  end
10
12
 
11
13
  def browser
@@ -16,6 +18,15 @@ class Capybara::Typhoeus::Driver < Capybara::RackTest::Driver
16
18
  true
17
19
  end
18
20
 
21
+ PARAMS_ENCODING_ALLOWED_VALUES = [:typhoeus, :rack, :multi, :none]
22
+ def params_encoding=(value)
23
+ if PARAMS_ENCODING_ALLOWED_VALUES.include?(value)
24
+ @params_encoding = value
25
+ else
26
+ raise ArgumentError, "Allowed values are: #{PARAMS_ENCODING_ALLOWED_VALUES.map(&:inspect).join(", ")}"
27
+ end
28
+ end
29
+
19
30
  [:get, :post, :put, :delete, :head, :patch, :request].each do |method|
20
31
  define_method(method) do |url, params={}, headers={}, &block|
21
32
  browser.reset_host!
@@ -22,6 +22,9 @@ skipped_tests = %i[
22
22
  download
23
23
  css
24
24
  scroll
25
+ active_element
26
+ html_validation
27
+ shadow_dom
25
28
  ]
26
29
  Capybara::SpecHelper.run_specs TestSessions::TyphoeusTest, 'Typhoeus', capybara_skip: skipped_tests do |example|
27
30
  case example.metadata[:full_description]
@@ -37,6 +40,12 @@ Capybara::SpecHelper.run_specs TestSessions::TyphoeusTest, 'Typhoeus', capybara_
37
40
  skip "Typhoeus driver doesn't support #select"
38
41
  when /#unselect/
39
42
  skip "Typhoeus driver doesn't support #unselect"
43
+ when /#has_css\? with spatial requirements/
44
+ skip "Typhoeus driver doesn't support #has_css? with spatial requirements"
45
+ when /#find with spatial filters/
46
+ skip "Typhoeus driver doesn't support #find with spatial filters"
47
+ when /can set cookie if a blank path is specified/
48
+ skip "Typhoeus driver doesn't support cookie"
40
49
  when /has_css\? should support case insensitive :class and :id options/
41
50
  skip "Nokogiri doesn't support case insensitive CSS attribute matchers"
42
51
  end
@@ -91,6 +100,68 @@ RSpec.describe Capybara::Typhoeus::Session do
91
100
  end
92
101
  end
93
102
 
103
+ context "params encoding" do
104
+ context "setting on driver" do
105
+ let(:driver) { session.driver }
106
+ it "defaults to :typhoeus" do
107
+ expect( driver.params_encoding ).to eq :typhoeus
108
+ end
109
+ it "can be set to :rack, :multi or :none" do
110
+ driver.params_encoding = :rack
111
+ expect( driver.params_encoding ).to eq :rack
112
+ driver.params_encoding = :multi
113
+ expect( driver.params_encoding ).to eq :multi
114
+ driver.params_encoding = :none
115
+ expect( driver.params_encoding ).to eq :none
116
+
117
+ expect do
118
+ driver.params_encoding = :unknown
119
+ end.to raise_error ArgumentError, "Allowed values are: :typhoeus, :rack, :multi, :none"
120
+ end
121
+ end
122
+ context "usage in requests" do
123
+ subject do
124
+ app = Sinatra.new do
125
+ get("/"){ params.inspect }
126
+ end
127
+ described_class.new :typhoeus, app
128
+ end
129
+ it "defaults to driver setting" do
130
+ subject.get "/", ids: [1, 2, 3]
131
+ expect( subject.body ).to eq '{"ids"=>{"0"=>"1", "1"=>"2", "2"=>"3"}}'
132
+
133
+ subject.driver.params_encoding = :rack
134
+ subject.get "/", ids: [1, 2, 3]
135
+ expect( subject.body ).to eq '{"ids"=>["1", "2", "3"]}'
136
+
137
+ subject.driver.params_encoding = :multi
138
+ subject.get "/", ids: [1, 2, 3]
139
+ expect( subject.body ).to eq '{"ids"=>"3"}'
140
+
141
+ subject.driver.params_encoding = :none
142
+ subject.get "/", ids: [1, 2, 3]
143
+ expect( subject.body ).to eq '{"ids"=>"[1, 2, 3]"}'
144
+ end
145
+ it "can be overriden per request" do
146
+ subject.driver.params_encoding = :none
147
+
148
+ subject.get "/", ids: [1, 2, 3], params_encoding: :typhoeus
149
+ expect( subject.body ).to eq '{"ids"=>{"0"=>"1", "1"=>"2", "2"=>"3"}}'
150
+
151
+ subject.get "/", ids: [1, 2, 3], params_encoding: :rack
152
+ expect( subject.body ).to eq '{"ids"=>["1", "2", "3"]}'
153
+
154
+ subject.get "/", ids: [1, 2, 3], params_encoding: :multi
155
+ expect( subject.body ).to eq '{"ids"=>"3"}'
156
+
157
+ subject.driver.params_encoding = :typhoeus
158
+
159
+ subject.get "/", ids: [1, 2, 3], params_encoding: :none
160
+ expect( subject.body ).to eq '{"ids"=>"[1, 2, 3]"}'
161
+ end
162
+ end
163
+ end
164
+
94
165
  context "timeout" do
95
166
  subject{ described_class.new :typhoeus, TestApp }
96
167
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph HALTER
8
8
  - Jonathan TRON
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-27 00:00:00.000000000 Z
12
+ date: 2022-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -130,7 +130,7 @@ files:
130
130
  homepage: https://github.com/TalentBox/capybara-typhoeus
131
131
  licenses: []
132
132
  metadata: {}
133
- post_install_message:
133
+ post_install_message:
134
134
  rdoc_options:
135
135
  - "--main"
136
136
  - README.md
@@ -149,10 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.0.3
153
- signing_key:
152
+ rubygems_version: 3.3.7
153
+ signing_key:
154
154
  specification_version: 4
155
155
  summary: Typhoeus driver for Capybara
156
156
  test_files:
157
- - spec/spec_helper.rb
158
157
  - spec/session/typhoeus_spec.rb
158
+ - spec/spec_helper.rb