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 +4 -4
- data/History.md +7 -0
- data/lib/capybara/helpers.rb +1 -1
- data/lib/capybara/node/finders.rb +7 -0
- data/lib/capybara/rack_test/browser.rb +15 -1
- data/lib/capybara/selector/selector.rb +5 -1
- data/lib/capybara/spec/session/find_spec.rb +6 -0
- data/lib/capybara/spec/session/has_link_spec.rb +6 -0
- data/lib/capybara/spec/session/visit_spec.rb +6 -0
- data/lib/capybara/spec/test_app.rb +16 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/selector_spec.rb +1 -1
- 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: c7283f19c4364fa2c19379e8da670105ebf59754937fc80117d975cd89959b87
|
4
|
+
data.tar.gz: b4fe7210ee210667602e9ec0a9882a1a34d8a64ceddae4df888aba0dd6974940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71de08c12fdd479453fa743e0a7ef858e72ca96d9a32d2ecb0b1721b365a1f1e494309432b52536dcac5669af78fe50e60b1a9f886f0b08a2ac2fd378abfc52e
|
7
|
+
data.tar.gz: 91a2e75a15768ef02e8c9b9f1400c4ee1dd2e1e2562b4733dc520afddc4c71be962fcd5c0379481fa65938d0776cfe5434c75f5faf0e512246abca48b06b0c00
|
data/History.md
CHANGED
data/lib/capybara/helpers.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/capybara/version.rb
CHANGED
data/spec/selector_spec.rb
CHANGED
@@ -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.
|
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.
|
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-
|
12
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|