capybara 3.37.0 → 3.37.1

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: 125837a4db6ae6c9b12ab2339f5daa673397ef9cdb9054689fb1d155a5d6e62f
4
- data.tar.gz: 445b064e8ae642678457cbf2739a1a6124b7d35dd6aaf295d3d9edce4f6ee8f3
3
+ metadata.gz: c7283f19c4364fa2c19379e8da670105ebf59754937fc80117d975cd89959b87
4
+ data.tar.gz: b4fe7210ee210667602e9ec0a9882a1a34d8a64ceddae4df888aba0dd6974940
5
5
  SHA512:
6
- metadata.gz: 95154994ad904eae4c9eeb73605bcc273daef240a0cbf241afa8cf1bcfef1ca2de52ecd159fe551ee2d863a0a9a07a2fb9a3beab659f334ec5782f50c5af4ba1
7
- data.tar.gz: 600e6610c5c48ac5619d1c4cf2ddfc83b86d5315ea259c7d8a6476863a14d4a209bcec0c6334dab5f3ebefac5eaeb1ccaa8a263114a5838f7a49a8483fb44538
6
+ metadata.gz: 71de08c12fdd479453fa743e0a7ef858e72ca96d9a32d2ecb0b1721b365a1f1e494309432b52536dcac5669af78fe50e60b1a9f886f0b08a2ac2fd378abfc52e
7
+ data.tar.gz: 91a2e75a15768ef02e8c9b9f1400c4ee1dd2e1e2562b4733dc520afddc4c71be962fcd5c0379481fa65938d0776cfe5434c75f5faf0e512246abca48b06b0c00
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ # Version 3.37.1
2
+ Relesae date: 2022-05-09
3
+
4
+ ### Fixed
5
+
6
+ * Regression in rack-test visit - Issue #2548
7
+
1
8
  # Version 3.37.0
2
9
  Release date: 2022-05-07
3
10
 
@@ -73,7 +73,7 @@ module Capybara
73
73
  def filter_backtrace(trace)
74
74
  return 'No backtrace' unless trace
75
75
 
76
- filter = %r{lib/capybara/|lib/rspec/|lib/minitest/}
76
+ filter = %r{lib/capybara/|lib/rspec/|lib/minitest/|delegate.rb}
77
77
  new_trace = trace.take_while { |line| line !~ filter }
78
78
  new_trace = trace.grep_v(filter) if new_trace.empty?
79
79
  new_trace = trace.dup if new_trace.empty?
@@ -50,6 +50,13 @@ module Capybara
50
50
  #
51
51
  def find(*args, **options, &optional_filter_block)
52
52
  options[:session_options] = session_options
53
+ count_options = options.slice(*Capybara::Queries::BaseQuery::COUNT_KEYS)
54
+ unless count_options.empty?
55
+ Capybara::Helpers.warn(
56
+ "'find' does not support count options (#{count_options}) ignoring. " \
57
+ "Called from: #{Capybara::Helpers.filter_backtrace(caller)}"
58
+ )
59
+ end
53
60
  synced_resolve Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
54
61
  end
55
62
 
@@ -20,6 +20,8 @@ class Capybara::RackTest::Browser
20
20
  end
21
21
 
22
22
  def visit(path, **attributes)
23
+ @new_visit_request = true
24
+ reset_cache!
23
25
  reset_host!
24
26
  process_and_follow_redirects(:get, path, attributes)
25
27
  end
@@ -45,7 +47,6 @@ class Capybara::RackTest::Browser
45
47
  def process_and_follow_redirects(method, path, attributes = {}, env = {})
46
48
  @current_fragment = build_uri(path).fragment
47
49
  process(method, path, attributes, env)
48
-
49
50
  return unless driver.follow_redirects?
50
51
 
51
52
  driver.redirect_limit.times do
@@ -69,6 +70,7 @@ class Capybara::RackTest::Browser
69
70
  @current_scheme, @current_host, @current_port = new_uri.select(:scheme, :host, :port)
70
71
  @current_fragment = new_uri.fragment || @current_fragment
71
72
  reset_cache!
73
+ @new_visit_request = false
72
74
  send(method, new_uri.to_s, attributes, env.merge(options[:headers] || {}))
73
75
  end
74
76
 
@@ -127,6 +129,18 @@ class Capybara::RackTest::Browser
127
129
  dom.title
128
130
  end
129
131
 
132
+ def last_request
133
+ raise Rack::Test::Error if @new_visit_request
134
+
135
+ super
136
+ end
137
+
138
+ def last_response
139
+ raise Rack::Test::Error if @new_visit_request
140
+
141
+ super
142
+ end
143
+
130
144
  protected
131
145
 
132
146
  def base_href
@@ -66,7 +66,11 @@ module Capybara
66
66
  end
67
67
  ensure
68
68
  unless locator_valid?(locator)
69
- warn "Locator #{locator.class}:#{locator.inspect} for selector #{name.inspect} must #{locator_description}. This will raise an error in a future version of Capybara."
69
+ Capybara::Helpers.warn(
70
+ "Locator #{locator.class}:#{locator.inspect} for selector #{name.inspect} must #{locator_description}. " \
71
+ 'This will raise an error in a future version of Capybara. ' \
72
+ "Called from: #{Capybara::Helpers.filter_backtrace(caller)}"
73
+ )
70
74
  end
71
75
  end
72
76
 
@@ -528,4 +528,10 @@ Capybara::SpecHelper.spec '#find' do
528
528
  expect(@session.find(:link, 'test-foo')[:id]).to eq 'foo'
529
529
  end
530
530
  end
531
+
532
+ it 'should warn if passed count options' do
533
+ allow(Capybara::Helpers).to receive(:warn)
534
+ @session.find('//h1', count: 44)
535
+ expect(Capybara::Helpers).to have_received(:warn).with(/'find' does not support count options/)
536
+ end
531
537
  end
@@ -19,6 +19,12 @@ Capybara::SpecHelper.spec '#has_link?' do
19
19
  expect(@session).not_to have_link('A link', href: /nonexistent/)
20
20
  end
21
21
 
22
+ it 'should notify if an invalid locator is specified' do
23
+ allow(Capybara::Helpers).to receive(:warn).and_return(nil)
24
+ @session.has_link?(@session)
25
+ expect(Capybara::Helpers).to have_received(:warn).with(/Called from: .+/)
26
+ end
27
+
22
28
  context 'with focused:', requires: [:active_element] do
23
29
  it 'should be true if the given link is on the page and has focus' do
24
30
  @session.send_keys(:tab)
@@ -214,5 +214,11 @@ Capybara::SpecHelper.spec '#visit' do
214
214
  @session.click_link('Bare query')
215
215
  expect(@session).to have_current_path('/?a=3')
216
216
  end
217
+
218
+ it 'should not use the base href with a new visit call' do
219
+ @session.visit('/base/with_other_base')
220
+ @session.visit('with_html')
221
+ expect(@session).to have_current_path('/with_html')
222
+ end
217
223
  end
218
224
  end
@@ -193,6 +193,22 @@ class TestApp < Sinatra::Base
193
193
  HTML
194
194
  end
195
195
 
196
+ get '/base/with_other_base' do
197
+ <<-HTML
198
+ <!DOCTYPE html>
199
+ <html>
200
+ <head>
201
+ <base href="/base/">
202
+ <title>Origin</title>
203
+ </head>
204
+ <body>
205
+ <a href="with_title">Title page</a>
206
+ <a href="?a=3">Bare query</a>
207
+ </body>
208
+ </html>
209
+ HTML
210
+ end
211
+
196
212
  get '/csp' do
197
213
  response.headers['Content-Security-Policy'] = "default-src 'none'; connect-src 'self'; base-uri 'none'; font-src 'self'; img-src 'self' data:; object-src 'none'; script-src 'self' 'nonce-jAviMuMisoTisVXjgLoWdA=='; style-src 'self' 'nonce-jAviMuMisoTisVXjgLoWdA=='; form-action 'self';"
198
214
  <<-HTML
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.37.0'
4
+ VERSION = '3.37.1'
5
5
  end
@@ -471,7 +471,7 @@ RSpec.describe Capybara do
471
471
  end
472
472
 
473
473
  it 'includes wildcarded keys in description' do
474
- expect { string.find(:element, 'input', not_there: 'bad', presence: true, absence: false, count: 1) }
474
+ expect { string.all(:element, 'input', not_there: 'bad', presence: true, absence: false, count: 1) }
475
475
  .to(raise_error do |e|
476
476
  expect(e).to be_a(Capybara::ElementNotFound)
477
477
  expect(e.message).to include 'not_there => bad'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.37.0
4
+ version: 3.37.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Walpole
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-05-07 00:00:00.000000000 Z
12
+ date: 2022-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable