capybara 3.32.0 → 3.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +99 -15
- data/README.md +9 -4
- data/lib/capybara.rb +18 -8
- data/lib/capybara/config.rb +4 -6
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/helpers.rb +25 -1
- data/lib/capybara/minitest.rb +2 -3
- data/lib/capybara/minitest/spec.rb +14 -11
- data/lib/capybara/node/actions.rb +16 -21
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/element.rb +1 -5
- data/lib/capybara/node/finders.rb +7 -6
- data/lib/capybara/node/matchers.rb +12 -12
- data/lib/capybara/node/simple.rb +5 -1
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +40 -18
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +7 -1
- data/lib/capybara/rack_test/browser.rb +7 -3
- data/lib/capybara/rack_test/driver.rb +1 -0
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +1 -1
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +3 -2
- data/lib/capybara/result.rb +10 -11
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/rspec/matcher_proxies.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +7 -6
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_text.rb +1 -1
- data/lib/capybara/rspec/matchers/match_style.rb +5 -0
- data/lib/capybara/selector.rb +12 -3
- data/lib/capybara/selector/builders/css_builder.rb +1 -1
- data/lib/capybara/selector/builders/xpath_builder.rb +3 -1
- data/lib/capybara/selector/definition.rb +11 -9
- data/lib/capybara/selector/definition/button.rb +26 -14
- data/lib/capybara/selector/definition/css.rb +1 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +2 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +1 -1
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/select.rb +1 -1
- data/lib/capybara/selector/definition/table.rb +1 -1
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/filter_set.rb +2 -2
- data/lib/capybara/selector/selector.rb +9 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +51 -7
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +9 -11
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +9 -11
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +3 -3
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +1 -1
- data/lib/capybara/selenium/node.rb +23 -6
- data/lib/capybara/selenium/nodes/chrome_node.rb +23 -5
- data/lib/capybara/selenium/nodes/firefox_node.rb +7 -2
- data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
- data/lib/capybara/selenium/patches/action_pauser.rb +4 -1
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +7 -9
- data/lib/capybara/server/animation_disabler.rb +8 -3
- data/lib/capybara/server/middleware.rb +4 -2
- data/lib/capybara/session.rb +23 -14
- data/lib/capybara/session/config.rb +3 -1
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/spec/public/test.js +13 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +11 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/has_button_spec.rb +51 -0
- data/lib/capybara/spec/session/has_css_spec.rb +2 -1
- data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
- data/lib/capybara/spec/session/has_field_spec.rb +16 -0
- data/lib/capybara/spec/session/has_select_spec.rb +4 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +0 -11
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +29 -9
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +12 -12
- data/lib/capybara/spec/test_app.rb +23 -21
- data/lib/capybara/spec/views/form.erb +28 -1
- data/lib/capybara/spec/views/with_animation.erb +8 -0
- data/lib/capybara/spec/views/with_dragula.erb +3 -1
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +3 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +3 -7
- data/spec/basic_node_spec.rb +9 -8
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +14 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +3 -2
- data/spec/rack_test_spec.rb +16 -5
- data/spec/result_spec.rb +1 -17
- data/spec/rspec/features_spec.rb +3 -1
- data/spec/rspec/scenarios_spec.rb +4 -0
- data/spec/rspec/shared_spec_matchers.rb +63 -51
- data/spec/rspec_spec.rb +4 -0
- data/spec/selector_spec.rb +17 -2
- data/spec/selenium_spec_chrome.rb +39 -20
- data/spec/selenium_spec_chrome_remote.rb +5 -1
- data/spec/selenium_spec_firefox.rb +15 -13
- data/spec/server_spec.rb +60 -49
- data/spec/shared_selenium_node.rb +10 -0
- data/spec/shared_selenium_session.rb +98 -7
- data/spec/spec_helper.rb +1 -1
- metadata +50 -15
- data/lib/capybara/spec/session/source_spec.rb +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -25,6 +25,7 @@ Capybara::SpecHelper.spec '#refresh' do
|
|
25
25
|
@session.visit('/form')
|
26
26
|
@session.select('Sweden', from: 'form_region')
|
27
27
|
@session.click_button('awesome')
|
28
|
+
sleep 2
|
28
29
|
expect do
|
29
30
|
@session.refresh
|
30
31
|
sleep 2
|
@@ -31,7 +31,7 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
31
31
|
it 'can store files in a specified directory' do
|
32
32
|
Capybara.save_path = alternative_path
|
33
33
|
@session.save_page
|
34
|
-
path = Dir.glob(alternative_path
|
34
|
+
path = Dir.glob("#{alternative_path}/capybara-*.html").first
|
35
35
|
expect(File.read(path)).to include('Another World')
|
36
36
|
end
|
37
37
|
|
@@ -43,14 +43,14 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
43
43
|
it 'can store files in a specified directory with a given filename' do
|
44
44
|
Capybara.save_path = alternative_path
|
45
45
|
@session.save_page('capybara-001133.html')
|
46
|
-
path = alternative_path
|
46
|
+
path = "#{alternative_path}/capybara-001133.html"
|
47
47
|
expect(File.read(path)).to include('Another World')
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'can store files in a specified directory with a given relative filename' do
|
51
51
|
Capybara.save_path = alternative_path
|
52
52
|
@session.save_page('tmp/capybara-001144.html')
|
53
|
-
path = alternative_path
|
53
|
+
path = "#{alternative_path}/tmp/capybara-001144.html"
|
54
54
|
expect(File.read(path)).to include('Another World')
|
55
55
|
end
|
56
56
|
|
@@ -63,7 +63,7 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
63
63
|
it 'returns an absolute path in given directory' do
|
64
64
|
Capybara.save_path = alternative_path
|
65
65
|
result = @session.save_page
|
66
|
-
path = File.expand_path(Dir.glob(alternative_path
|
66
|
+
path = File.expand_path(Dir.glob("#{alternative_path}/capybara-*.html").first, alternative_path)
|
67
67
|
expect(result).to eq(path)
|
68
68
|
end
|
69
69
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -30,6 +30,7 @@ module Capybara
|
|
30
30
|
Capybara.visible_text_only = false
|
31
31
|
Capybara.match = :smart
|
32
32
|
Capybara.enable_aria_label = false
|
33
|
+
Capybara.enable_aria_role = false
|
33
34
|
Capybara.default_set_options = {}
|
34
35
|
Capybara.disable_animation = false
|
35
36
|
Capybara.test_id = nil
|
@@ -57,7 +58,7 @@ module Capybara
|
|
57
58
|
|
58
59
|
def run_specs(session, name, **options, &filter_block)
|
59
60
|
specs = @specs
|
60
|
-
RSpec.describe Capybara::Session, name, options do
|
61
|
+
RSpec.describe Capybara::Session, name, options do
|
61
62
|
include Capybara::SpecHelper
|
62
63
|
include Capybara::RSpecMatchers
|
63
64
|
|
@@ -71,11 +72,11 @@ module Capybara
|
|
71
72
|
end
|
72
73
|
|
73
74
|
before :each, psc: true do
|
74
|
-
SpecHelper.reset_threadsafe(true, session)
|
75
|
+
SpecHelper.reset_threadsafe(bool: true, session: session)
|
75
76
|
end
|
76
77
|
|
77
78
|
after psc: true do
|
78
|
-
SpecHelper.reset_threadsafe(
|
79
|
+
SpecHelper.reset_threadsafe(session: session)
|
79
80
|
end
|
80
81
|
|
81
82
|
before :each, :exact_false do
|
@@ -83,15 +84,16 @@ module Capybara
|
|
83
84
|
end
|
84
85
|
|
85
86
|
specs.each do |spec_name, spec_options, block|
|
86
|
-
describe spec_name, *spec_options do
|
87
|
+
describe spec_name, *spec_options do
|
87
88
|
class_eval(&block)
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
|
-
def reset_threadsafe(bool
|
94
|
-
|
94
|
+
def reset_threadsafe(bool: false, session: nil)
|
95
|
+
# Work around limit on when threadsafe can be changed
|
96
|
+
Capybara::Session.class_variable_set(:@@instance_created, false) # rubocop:disable Style/ClassVars
|
95
97
|
Capybara.threadsafe = bool
|
96
98
|
session = session.current_session if session.respond_to?(:current_session)
|
97
99
|
session&.instance_variable_set(:@config, nil)
|
@@ -107,11 +109,9 @@ module Capybara
|
|
107
109
|
stream.reopen(old_stream)
|
108
110
|
end
|
109
111
|
|
110
|
-
def quietly
|
111
|
-
silence_stream(
|
112
|
-
silence_stream(
|
113
|
-
yield
|
114
|
-
end
|
112
|
+
def quietly(&block)
|
113
|
+
silence_stream($stdout) do
|
114
|
+
silence_stream($stderr, &block)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -131,4 +131,4 @@ module Capybara
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
Dir[File.dirname(__FILE__)
|
134
|
+
Dir["#{File.dirname(__FILE__)}/session/**/*.rb"].each { |file| require_relative file }
|
@@ -7,8 +7,10 @@ require 'yaml'
|
|
7
7
|
|
8
8
|
class TestApp < Sinatra::Base
|
9
9
|
class TestAppError < Exception; end # rubocop:disable Lint/InheritException
|
10
|
+
|
10
11
|
class TestAppOtherError < Exception # rubocop:disable Lint/InheritException
|
11
12
|
def initialize(string1, msg)
|
13
|
+
super()
|
12
14
|
@something = string1
|
13
15
|
@message = msg
|
14
16
|
end
|
@@ -33,6 +35,10 @@ class TestApp < Sinatra::Base
|
|
33
35
|
redirect '/redirect_again'
|
34
36
|
end
|
35
37
|
|
38
|
+
get '/redirect_with_fragment' do
|
39
|
+
redirect '/landed#with_fragment'
|
40
|
+
end
|
41
|
+
|
36
42
|
get '/redirect_again' do
|
37
43
|
redirect '/landed'
|
38
44
|
end
|
@@ -85,11 +91,11 @@ class TestApp < Sinatra::Base
|
|
85
91
|
end
|
86
92
|
|
87
93
|
get '/form/get' do
|
88
|
-
|
94
|
+
%(<pre id="results">#{params[:form].to_yaml}</pre>)
|
89
95
|
end
|
90
96
|
|
91
97
|
post '/relative' do
|
92
|
-
|
98
|
+
%(<pre id="results">#{params[:form].to_yaml}</pre>)
|
93
99
|
end
|
94
100
|
|
95
101
|
get '/favicon.ico' do
|
@@ -176,7 +182,7 @@ class TestApp < Sinatra::Base
|
|
176
182
|
|
177
183
|
post '/form' do
|
178
184
|
self.class.form_post_count += 1
|
179
|
-
|
185
|
+
%(<pre id="results">#{params[:form].merge('post_count' => self.class.form_post_count).to_yaml}</pre>)
|
180
186
|
end
|
181
187
|
|
182
188
|
post '/upload_empty' do
|
@@ -188,28 +194,24 @@ class TestApp < Sinatra::Base
|
|
188
194
|
end
|
189
195
|
|
190
196
|
post '/upload' do
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
'No file uploaded'
|
198
|
-
end
|
197
|
+
buffer = []
|
198
|
+
buffer << "Content-type: #{params.dig(:form, :document, :type)}"
|
199
|
+
buffer << "File content: #{params.dig(:form, :document, :tempfile).read}"
|
200
|
+
buffer.join(' | ')
|
201
|
+
rescue StandardError
|
202
|
+
'No file uploaded'
|
199
203
|
end
|
200
204
|
|
201
205
|
post '/upload_multiple' do
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
buffer << "File content: #{doc[:tempfile].read}"
|
208
|
-
end
|
209
|
-
buffer.join(' | ')
|
210
|
-
rescue StandardError
|
211
|
-
'No files uploaded'
|
206
|
+
docs = params.dig(:form, :multiple_documents)
|
207
|
+
buffer = [docs.size.to_s]
|
208
|
+
docs.each do |doc|
|
209
|
+
buffer << "Content-type: #{doc[:type]}"
|
210
|
+
buffer << "File content: #{doc[:tempfile].read}"
|
212
211
|
end
|
212
|
+
buffer.join(' | ')
|
213
|
+
rescue StandardError
|
214
|
+
'No files uploaded'
|
213
215
|
end
|
214
216
|
|
215
217
|
get '/apple-touch-icon-precomposed.png' do
|
@@ -140,7 +140,11 @@
|
|
140
140
|
|
141
141
|
<p>
|
142
142
|
<label for="form_zipcode">Zipcode</label>
|
143
|
-
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" />
|
143
|
+
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" pattern="[0-9]{5,9}" />
|
144
|
+
</p>
|
145
|
+
|
146
|
+
<p>
|
147
|
+
<input maxlength="35" id="long_length" />
|
144
148
|
</p>
|
145
149
|
|
146
150
|
<p>
|
@@ -452,7 +456,18 @@ New line after and before textarea tag
|
|
452
456
|
<button type="submit" name="form[no_value]">No Value!</button>
|
453
457
|
<button id="no_type">No Type!</button>
|
454
458
|
<button><img alt="A horse eating hay"/></button>
|
459
|
+
<button id="button_with_label"></button>
|
460
|
+
<label for="button_with_label">button with label element</label>
|
461
|
+
<label>
|
462
|
+
button within label element
|
463
|
+
<button></button>
|
464
|
+
</label>
|
465
|
+
<label>
|
466
|
+
role=button within label element
|
467
|
+
<span role="button">with other text</span>
|
468
|
+
</label>
|
455
469
|
<input type="button" disabled="disabled" value="Disabled button"/>
|
470
|
+
<span role="button">ARIA button</span>
|
456
471
|
</p>
|
457
472
|
|
458
473
|
<p>
|
@@ -679,3 +694,15 @@ New line after and before textarea tag
|
|
679
694
|
<p>
|
680
695
|
<input id="special" {custom}="abcdef" value="custom attribute"/>
|
681
696
|
</p>
|
697
|
+
|
698
|
+
|
699
|
+
<label for="multi_label_checkbox">
|
700
|
+
Label to click
|
701
|
+
</label>
|
702
|
+
<div>Something random that justifies the usage of a separate label</div>
|
703
|
+
<label>
|
704
|
+
<div>
|
705
|
+
<input type="checkbox" id="multi_label_checkbox" style="display: none"/>
|
706
|
+
<div>Visual representation of the checkbox</div>
|
707
|
+
</div>
|
708
|
+
</label>
|
@@ -15,7 +15,9 @@
|
|
15
15
|
</div>
|
16
16
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/dragula/3.7.2/dragula.js" type="text/javascript"></script>
|
17
17
|
<script>
|
18
|
-
|
18
|
+
let container = document.getElementById("sortable");
|
19
|
+
dragula([container]);
|
20
|
+
container.className = "ready"
|
19
21
|
</script>
|
20
22
|
</body>
|
21
23
|
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
5
|
+
<title>with_jquery_animation</title>
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
height: 2000px;
|
9
|
+
}
|
10
|
+
</style>
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body id="with_animation">
|
14
|
+
<a href="#" id='scroll'>scroll top 500</a>
|
15
|
+
|
16
|
+
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
17
|
+
<script type='text/javascript'>
|
18
|
+
$('#scroll').click(function(e){
|
19
|
+
e.preventDefault();
|
20
|
+
$('html, body').animate({ scrollTop: 500 }, 'slow');
|
21
|
+
});
|
22
|
+
</script>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -35,6 +35,8 @@
|
|
35
35
|
|
36
36
|
<p><a href="#" id="clickable">Click me</a></p>
|
37
37
|
<p><a href="#" id="slow-click">Slowly</a></p>
|
38
|
+
<p><span id="aria-button" role="button">ARIA button</span></p>
|
39
|
+
<p><span role="button">ARIA button2</span></p>
|
38
40
|
|
39
41
|
<p>
|
40
42
|
<select id="waiter">
|
@@ -151,6 +153,7 @@
|
|
151
153
|
<p>This is an HTML5 draggable element.</p>
|
152
154
|
</div>
|
153
155
|
|
156
|
+
<div id="shadow"></div>
|
154
157
|
<script type="text/javascript">
|
155
158
|
// a javascript comment
|
156
159
|
var aVar = 123;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<head>
|
3
3
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
4
4
|
<title>with_sortable_js</title>
|
5
|
-
<script src="https://sortablejs.
|
5
|
+
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.12.0/dist/sortable.umd.min.js" type="text/javascript"></script>
|
6
6
|
</head>
|
7
7
|
|
8
8
|
<body id="with_sortable_js">
|
data/lib/capybara/version.rb
CHANGED
data/lib/capybara/window.rb
CHANGED
@@ -4,7 +4,7 @@ module Capybara
|
|
4
4
|
##
|
5
5
|
# The {Window} class represents a browser window.
|
6
6
|
#
|
7
|
-
# You can get an instance of the class by calling
|
7
|
+
# You can get an instance of the class by calling any of:
|
8
8
|
#
|
9
9
|
# * {Capybara::Session#windows}
|
10
10
|
# * {Capybara::Session#current_window}
|
@@ -82,8 +82,8 @@ module Capybara
|
|
82
82
|
# Resize window.
|
83
83
|
#
|
84
84
|
# @macro about_current
|
85
|
-
# @param width [
|
86
|
-
# @param height [
|
85
|
+
# @param width [Integer] the new window width in pixels
|
86
|
+
# @param height [Integer] the new window height in pixels
|
87
87
|
#
|
88
88
|
def resize_to(width, height)
|
89
89
|
wait_for_stable_size { @driver.resize_window_to(handle, width, height) }
|
@@ -138,9 +138,5 @@ module Capybara
|
|
138
138
|
end
|
139
139
|
raise Capybara::WindowError, "Window size not stable within #{seconds} seconds."
|
140
140
|
end
|
141
|
-
|
142
|
-
def raise_unless_current(what)
|
143
|
-
raise Capybara::WindowError, "#{what} not current window is not possible." unless current?
|
144
|
-
end
|
145
141
|
end
|
146
142
|
end
|
data/spec/basic_node_spec.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Capybara do
|
6
|
+
include Capybara::RSpecMatchers
|
6
7
|
describe '.string' do
|
7
8
|
let :string do
|
8
9
|
described_class.string <<-STRING
|
@@ -129,25 +130,25 @@ RSpec.describe Capybara do
|
|
129
130
|
|
130
131
|
describe '#has_title?' do
|
131
132
|
it 'returns whether the page has the given title' do
|
132
|
-
expect(string.has_title?('simple_node')).to
|
133
|
-
expect(string.has_title?('monkey')).to
|
133
|
+
expect(string.has_title?('simple_node')).to be true
|
134
|
+
expect(string.has_title?('monkey')).to be false
|
134
135
|
end
|
135
136
|
|
136
137
|
it 'allows regexp matches' do
|
137
|
-
expect(string.has_title?(/s[a-z]+_node/)).to
|
138
|
-
expect(string.has_title?(/monkey/)).to
|
138
|
+
expect(string.has_title?(/s[a-z]+_node/)).to be true
|
139
|
+
expect(string.has_title?(/monkey/)).to be false
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
143
|
describe '#has_no_title?' do
|
143
144
|
it 'returns whether the page does not have the given title' do
|
144
|
-
expect(string.has_no_title?('simple_node')).to
|
145
|
-
expect(string.has_no_title?('monkey')).to
|
145
|
+
expect(string.has_no_title?('simple_node')).to be false
|
146
|
+
expect(string.has_no_title?('monkey')).to be true
|
146
147
|
end
|
147
148
|
|
148
149
|
it 'allows regexp matches' do
|
149
|
-
expect(string.has_no_title?(/s[a-z]+_node/)).to
|
150
|
-
expect(string.has_no_title?(/monkey/)).to
|
150
|
+
expect(string.has_no_title?(/s[a-z]+_node/)).to be false
|
151
|
+
expect(string.has_no_title?(/monkey/)).to be true
|
151
152
|
end
|
152
153
|
end
|
153
154
|
end
|