capybara 3.8.1 → 3.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/History.md +465 -0
- data/License.txt +1 -1
- data/README.md +58 -57
- data/lib/capybara/config.rb +10 -4
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +2 -2
- data/lib/capybara/driver/node.rb +26 -5
- data/lib/capybara/dsl.rb +12 -4
- data/lib/capybara/helpers.rb +8 -4
- data/lib/capybara/minitest/spec.rb +162 -85
- data/lib/capybara/minitest.rb +248 -148
- data/lib/capybara/node/actions.rb +149 -96
- data/lib/capybara/node/base.rb +27 -10
- data/lib/capybara/node/document.rb +12 -0
- data/lib/capybara/node/document_matchers.rb +9 -5
- data/lib/capybara/node/element.rb +254 -109
- data/lib/capybara/node/finders.rb +83 -76
- data/lib/capybara/node/matchers.rb +279 -141
- data/lib/capybara/node/simple.rb +25 -6
- data/lib/capybara/queries/ancestor_query.rb +5 -7
- data/lib/capybara/queries/base_query.rb +11 -5
- data/lib/capybara/queries/current_path_query.rb +3 -3
- data/lib/capybara/queries/match_query.rb +1 -0
- data/lib/capybara/queries/selector_query.rb +467 -103
- data/lib/capybara/queries/sibling_query.rb +5 -4
- data/lib/capybara/queries/style_query.rb +6 -2
- data/lib/capybara/queries/text_query.rb +17 -3
- data/lib/capybara/queries/title_query.rb +2 -2
- data/lib/capybara/rack_test/browser.rb +22 -15
- data/lib/capybara/rack_test/driver.rb +10 -1
- data/lib/capybara/rack_test/errors.rb +6 -0
- data/lib/capybara/rack_test/form.rb +33 -28
- data/lib/capybara/rack_test/node.rb +74 -6
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/patches/puma_ssl.rb +27 -0
- data/lib/capybara/registrations/servers.rb +44 -0
- data/lib/capybara/result.rb +55 -23
- data/lib/capybara/rspec/features.rb +4 -4
- data/lib/capybara/rspec/matcher_proxies.rb +36 -15
- data/lib/capybara/rspec/matchers/base.rb +111 -0
- data/lib/capybara/rspec/matchers/become_closed.rb +33 -0
- data/lib/capybara/rspec/matchers/compound.rb +88 -0
- data/lib/capybara/rspec/matchers/count_sugar.rb +37 -0
- data/lib/capybara/rspec/matchers/have_ancestor.rb +28 -0
- data/lib/capybara/rspec/matchers/have_current_path.rb +29 -0
- data/lib/capybara/rspec/matchers/have_selector.rb +77 -0
- data/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
- data/lib/capybara/rspec/matchers/have_text.rb +33 -0
- data/lib/capybara/rspec/matchers/have_title.rb +29 -0
- data/lib/capybara/rspec/matchers/match_selector.rb +27 -0
- data/lib/capybara/rspec/matchers/match_style.rb +38 -0
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
- data/lib/capybara/rspec/matchers.rb +117 -311
- data/lib/capybara/selector/builders/css_builder.rb +84 -0
- data/lib/capybara/selector/builders/xpath_builder.rb +69 -0
- data/lib/capybara/selector/css.rb +17 -15
- data/lib/capybara/selector/definition/button.rb +52 -0
- data/lib/capybara/selector/definition/checkbox.rb +26 -0
- data/lib/capybara/selector/definition/css.rb +10 -0
- data/lib/capybara/selector/definition/datalist_input.rb +35 -0
- data/lib/capybara/selector/definition/datalist_option.rb +25 -0
- data/lib/capybara/selector/definition/element.rb +27 -0
- data/lib/capybara/selector/definition/field.rb +40 -0
- data/lib/capybara/selector/definition/fieldset.rb +14 -0
- data/lib/capybara/selector/definition/file_field.rb +13 -0
- data/lib/capybara/selector/definition/fillable_field.rb +33 -0
- data/lib/capybara/selector/definition/frame.rb +17 -0
- data/lib/capybara/selector/definition/id.rb +6 -0
- data/lib/capybara/selector/definition/label.rb +62 -0
- data/lib/capybara/selector/definition/link.rb +54 -0
- data/lib/capybara/selector/definition/link_or_button.rb +16 -0
- data/lib/capybara/selector/definition/option.rb +27 -0
- data/lib/capybara/selector/definition/radio_button.rb +27 -0
- data/lib/capybara/selector/definition/select.rb +81 -0
- data/lib/capybara/selector/definition/table.rb +109 -0
- data/lib/capybara/selector/definition/table_row.rb +21 -0
- data/lib/capybara/selector/definition/xpath.rb +5 -0
- data/lib/capybara/selector/definition.rb +277 -0
- data/lib/capybara/selector/filter.rb +1 -0
- data/lib/capybara/selector/filter_set.rb +26 -19
- data/lib/capybara/selector/filters/base.rb +24 -5
- data/lib/capybara/selector/filters/expression_filter.rb +3 -3
- data/lib/capybara/selector/filters/locator_filter.rb +29 -0
- data/lib/capybara/selector/filters/node_filter.rb +16 -2
- data/lib/capybara/selector/regexp_disassembler.rb +214 -0
- data/lib/capybara/selector/selector.rb +73 -367
- data/lib/capybara/selector/xpath_extensions.rb +17 -0
- data/lib/capybara/selector.rb +221 -480
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -0
- data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -0
- data/lib/capybara/selenium/atoms/src/getAttribute.js +161 -0
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +454 -0
- data/lib/capybara/selenium/driver.rb +203 -86
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +88 -14
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +124 -0
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +89 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +26 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +24 -0
- data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
- data/lib/capybara/selenium/extensions/find.rb +110 -0
- data/lib/capybara/selenium/extensions/html5_drag.rb +191 -22
- data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
- data/lib/capybara/selenium/extensions/scroll.rb +78 -0
- data/lib/capybara/selenium/logger_suppressor.rb +34 -0
- data/lib/capybara/selenium/node.rb +298 -93
- data/lib/capybara/selenium/nodes/chrome_node.rb +100 -8
- data/lib/capybara/selenium/nodes/edge_node.rb +104 -0
- data/lib/capybara/selenium/nodes/firefox_node.rb +131 -0
- data/lib/capybara/selenium/nodes/ie_node.rb +22 -0
- data/lib/capybara/selenium/nodes/safari_node.rb +118 -0
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +18 -0
- data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
- data/lib/capybara/selenium/patches/logs.rb +45 -0
- data/lib/capybara/selenium/patches/pause_duration_fix.rb +1 -3
- data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
- data/lib/capybara/server/animation_disabler.rb +4 -3
- data/lib/capybara/server/checker.rb +6 -2
- data/lib/capybara/server/middleware.rb +23 -13
- data/lib/capybara/server.rb +30 -7
- data/lib/capybara/session/config.rb +14 -10
- data/lib/capybara/session/matchers.rb +11 -7
- data/lib/capybara/session.rb +152 -111
- data/lib/capybara/spec/public/offset.js +6 -0
- data/lib/capybara/spec/public/test.js +101 -10
- data/lib/capybara/spec/session/all_spec.rb +96 -6
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +29 -0
- data/lib/capybara/spec/session/assert_current_path_spec.rb +5 -2
- data/lib/capybara/spec/session/assert_selector_spec.rb +0 -10
- data/lib/capybara/spec/session/assert_style_spec.rb +4 -4
- data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
- data/lib/capybara/spec/session/attach_file_spec.rb +63 -36
- data/lib/capybara/spec/session/check_spec.rb +10 -4
- data/lib/capybara/spec/session/choose_spec.rb +8 -2
- data/lib/capybara/spec/session/click_button_spec.rb +117 -61
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +16 -0
- data/lib/capybara/spec/session/click_link_spec.rb +17 -6
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +40 -39
- data/lib/capybara/spec/session/evaluate_script_spec.rb +13 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +1 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +47 -6
- data/lib/capybara/spec/session/find_field_spec.rb +1 -1
- data/lib/capybara/spec/session/find_spec.rb +74 -4
- data/lib/capybara/spec/session/first_spec.rb +1 -1
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +13 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +1 -1
- data/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
- data/lib/capybara/spec/session/has_any_selectors_spec.rb +25 -0
- data/lib/capybara/spec/session/has_button_spec.rb +16 -0
- data/lib/capybara/spec/session/has_css_spec.rb +122 -12
- data/lib/capybara/spec/session/has_current_path_spec.rb +6 -4
- data/lib/capybara/spec/session/has_field_spec.rb +55 -0
- data/lib/capybara/spec/session/has_select_spec.rb +34 -6
- data/lib/capybara/spec/session/has_selector_spec.rb +11 -4
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/has_table_spec.rb +166 -0
- data/lib/capybara/spec/session/has_text_spec.rb +48 -1
- data/lib/capybara/spec/session/has_xpath_spec.rb +17 -0
- data/lib/capybara/spec/session/html_spec.rb +7 -0
- data/lib/capybara/spec/session/matches_style_spec.rb +35 -0
- data/lib/capybara/spec/session/node_spec.rb +643 -18
- data/lib/capybara/spec/session/node_wrapper_spec.rb +1 -1
- data/lib/capybara/spec/session/refresh_spec.rb +4 -0
- data/lib/capybara/spec/session/reset_session_spec.rb +23 -8
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/scroll_spec.rb +117 -0
- data/lib/capybara/spec/session/select_spec.rb +10 -10
- data/lib/capybara/spec/session/selectors_spec.rb +36 -5
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/session/window/become_closed_spec.rb +20 -17
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +4 -0
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +4 -0
- data/lib/capybara/spec/session/window/window_spec.rb +59 -58
- data/lib/capybara/spec/session/window/windows_spec.rb +4 -0
- data/lib/capybara/spec/session/within_spec.rb +23 -0
- data/lib/capybara/spec/spec_helper.rb +16 -6
- data/lib/capybara/spec/test_app.rb +28 -23
- data/lib/capybara/spec/views/animated.erb +49 -0
- data/lib/capybara/spec/views/form.erb +48 -7
- data/lib/capybara/spec/views/frame_child.erb +3 -2
- data/lib/capybara/spec/views/frame_one.erb +1 -0
- data/lib/capybara/spec/views/obscured.erb +47 -0
- data/lib/capybara/spec/views/offset.erb +32 -0
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/spec/views/scroll.erb +20 -0
- data/lib/capybara/spec/views/spatial.erb +31 -0
- data/lib/capybara/spec/views/tables.erb +67 -0
- data/lib/capybara/spec/views/with_animation.erb +29 -1
- data/lib/capybara/spec/views/with_dragula.erb +24 -0
- data/lib/capybara/spec/views/with_hover.erb +1 -0
- data/lib/capybara/spec/views/with_hover1.erb +10 -0
- data/lib/capybara/spec/views/with_html.erb +32 -6
- data/lib/capybara/spec/views/with_js.erb +3 -1
- data/lib/capybara/spec/views/with_jstree.erb +26 -0
- data/lib/capybara/spec/views/with_scope_other.erb +6 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +11 -11
- data/lib/capybara.rb +118 -111
- data/spec/basic_node_spec.rb +14 -3
- data/spec/capybara_spec.rb +29 -29
- data/spec/css_builder_spec.rb +101 -0
- data/spec/dsl_spec.rb +46 -21
- data/spec/filter_set_spec.rb +5 -5
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +18 -4
- data/spec/minitest_spec_spec.rb +59 -44
- data/spec/rack_test_spec.rb +117 -89
- data/spec/regexp_dissassembler_spec.rb +250 -0
- data/spec/result_spec.rb +51 -49
- data/spec/rspec/features_spec.rb +3 -0
- data/spec/rspec/shared_spec_matchers.rb +112 -97
- data/spec/rspec_spec.rb +35 -17
- data/spec/sauce_spec_chrome.rb +43 -0
- data/spec/selector_spec.rb +244 -28
- data/spec/selenium_spec_chrome.rb +125 -54
- data/spec/selenium_spec_chrome_remote.rb +26 -12
- data/spec/selenium_spec_edge.rb +23 -8
- data/spec/selenium_spec_firefox.rb +208 -0
- data/spec/selenium_spec_firefox_remote.rb +15 -18
- data/spec/selenium_spec_ie.rb +82 -13
- data/spec/selenium_spec_safari.rb +148 -0
- data/spec/server_spec.rb +118 -77
- data/spec/session_spec.rb +19 -3
- data/spec/shared_selenium_node.rb +83 -0
- data/spec/shared_selenium_session.rb +110 -65
- data/spec/spec_helper.rb +57 -9
- data/spec/xpath_builder_spec.rb +93 -0
- metadata +257 -17
- data/lib/capybara/rspec/compound.rb +0 -94
- data/lib/capybara/selenium/driver_specializations/marionette_driver.rb +0 -49
- data/lib/capybara/selenium/nodes/marionette_node.rb +0 -121
- data/lib/capybara/spec/session/has_style_spec.rb +0 -25
- data/spec/selenium_spec_marionette.rb +0 -172
data/spec/dsl_spec.rb
CHANGED
@@ -8,10 +8,21 @@ class TestClass
|
|
8
8
|
end
|
9
9
|
|
10
10
|
Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
|
11
|
-
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver
|
12
|
-
]
|
11
|
+
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation
|
12
|
+
] do |example|
|
13
|
+
case example.metadata[:full_description]
|
14
|
+
when /has_css\? should support case insensitive :class and :id options/
|
15
|
+
pending "Nokogiri doesn't support case insensitive CSS attribute matchers"
|
16
|
+
when /#click_button should follow permanent redirects that maintain method/
|
17
|
+
pending "Rack < 2 doesn't support 308" if Gem.loaded_specs['rack'].version < Gem::Version.new('2.0.0')
|
18
|
+
end
|
19
|
+
end
|
13
20
|
|
14
21
|
RSpec.describe Capybara::DSL do
|
22
|
+
before do
|
23
|
+
Capybara.use_default_driver
|
24
|
+
end
|
25
|
+
|
15
26
|
after do
|
16
27
|
Capybara.session_name = nil
|
17
28
|
Capybara.default_driver = nil
|
@@ -85,7 +96,7 @@ RSpec.describe Capybara::DSL do
|
|
85
96
|
driver_before_block = Capybara.current_driver
|
86
97
|
begin
|
87
98
|
Capybara.using_driver(:selenium) { raise 'ohnoes!' }
|
88
|
-
rescue Exception # rubocop:disable Lint/RescueException,Lint/
|
99
|
+
rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
|
89
100
|
end
|
90
101
|
expect(Capybara.current_driver).to eq(driver_before_block)
|
91
102
|
end
|
@@ -108,14 +119,11 @@ RSpec.describe Capybara::DSL do
|
|
108
119
|
end
|
109
120
|
end
|
110
121
|
|
122
|
+
# rubocop:disable RSpec/InstanceVariable
|
111
123
|
describe '#using_wait_time' do
|
112
|
-
before
|
113
|
-
@previous_wait_time = Capybara.default_max_wait_time
|
114
|
-
end
|
124
|
+
before { @previous_wait_time = Capybara.default_max_wait_time }
|
115
125
|
|
116
|
-
after
|
117
|
-
Capybara.default_max_wait_time = @previous_wait_time
|
118
|
-
end
|
126
|
+
after { Capybara.default_max_wait_time = @previous_wait_time }
|
119
127
|
|
120
128
|
it 'should switch the wait time and switch it back' do
|
121
129
|
in_block = nil
|
@@ -135,6 +143,7 @@ RSpec.describe Capybara::DSL do
|
|
135
143
|
expect(Capybara.default_max_wait_time).to eq(@previous_wait_time)
|
136
144
|
end
|
137
145
|
end
|
146
|
+
# rubocop:enable RSpec/InstanceVariable
|
138
147
|
|
139
148
|
describe '#app' do
|
140
149
|
it 'should be changeable' do
|
@@ -203,7 +212,7 @@ RSpec.describe Capybara::DSL do
|
|
203
212
|
Capybara.using_session(:raise) do
|
204
213
|
raise
|
205
214
|
end
|
206
|
-
rescue Exception # rubocop:disable Lint/RescueException,Lint/
|
215
|
+
rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
|
207
216
|
end
|
208
217
|
expect(Capybara.session_name).to eq(:default)
|
209
218
|
end
|
@@ -224,6 +233,24 @@ RSpec.describe Capybara::DSL do
|
|
224
233
|
end
|
225
234
|
expect(Capybara.session_name).to eq(:default)
|
226
235
|
end
|
236
|
+
|
237
|
+
it 'should allow a session object' do
|
238
|
+
original_session = Capybara.current_session
|
239
|
+
new_session = Capybara::Session.new(:rack_test, proc {})
|
240
|
+
Capybara.using_session(new_session) do
|
241
|
+
expect(Capybara.current_session).to eq(new_session)
|
242
|
+
end
|
243
|
+
expect(Capybara.current_session).to eq(original_session)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should pass the new session if block accepts' do
|
247
|
+
original_session = Capybara.current_session
|
248
|
+
Capybara.using_session(:administrator) do |admin_session, prev_session|
|
249
|
+
expect(admin_session).to be(Capybara.current_session)
|
250
|
+
expect(prev_session).to be(original_session)
|
251
|
+
expect(prev_session).not_to be(admin_session)
|
252
|
+
end
|
253
|
+
end
|
227
254
|
end
|
228
255
|
|
229
256
|
describe '#session_name' do
|
@@ -233,31 +260,29 @@ RSpec.describe Capybara::DSL do
|
|
233
260
|
end
|
234
261
|
|
235
262
|
describe 'the DSL' do
|
236
|
-
|
237
|
-
@session = Class.new { include Capybara::DSL }.new
|
238
|
-
end
|
263
|
+
let(:session) { Class.new { include Capybara::DSL }.new }
|
239
264
|
|
240
265
|
it 'should be possible to include it in another class' do
|
241
|
-
|
242
|
-
|
243
|
-
expect(
|
266
|
+
session.visit('/with_html')
|
267
|
+
session.click_link('ullamco')
|
268
|
+
expect(session.body).to include('Another World')
|
244
269
|
end
|
245
270
|
|
246
271
|
it "should provide a 'page' shortcut for more expressive tests" do
|
247
|
-
|
248
|
-
|
249
|
-
expect(
|
272
|
+
session.page.visit('/with_html')
|
273
|
+
session.page.click_link('ullamco')
|
274
|
+
expect(session.page.body).to include('Another World')
|
250
275
|
end
|
251
276
|
|
252
277
|
it "should provide an 'using_session' shortcut" do
|
253
278
|
allow(Capybara).to receive(:using_session)
|
254
|
-
|
279
|
+
session.using_session(:name)
|
255
280
|
expect(Capybara).to have_received(:using_session).with(:name)
|
256
281
|
end
|
257
282
|
|
258
283
|
it "should provide a 'using_wait_time' shortcut" do
|
259
284
|
allow(Capybara).to receive(:using_wait_time)
|
260
|
-
|
285
|
+
session.using_wait_time(6)
|
261
286
|
expect(Capybara).to have_received(:using_wait_time).with(6)
|
262
287
|
end
|
263
288
|
end
|
data/spec/filter_set_spec.rb
CHANGED
@@ -4,11 +4,11 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe Capybara::Selector::FilterSet do
|
6
6
|
after do
|
7
|
-
|
7
|
+
described_class.remove(:test)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'allows node filters' do
|
11
|
-
fs =
|
11
|
+
fs = described_class.add(:test) do
|
12
12
|
node_filter(:node_test, :boolean) { |_node, _value| true }
|
13
13
|
expression_filter(:expression_test, :boolean) { |_expr, _value| true }
|
14
14
|
end
|
@@ -18,7 +18,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'allows expression filters' do
|
21
|
-
fs =
|
21
|
+
fs = described_class.add(:test) do
|
22
22
|
node_filter(:node_test, :boolean) { |_node, _value| true }
|
23
23
|
expression_filter(:expression_test, :boolean) { |_expr, _value| true }
|
24
24
|
end
|
@@ -28,7 +28,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'allows node filter and expression filter with the same name' do
|
31
|
-
fs =
|
31
|
+
fs = described_class.add(:test) do
|
32
32
|
node_filter(:test, :boolean) { |_node, _value| true }
|
33
33
|
expression_filter(:test, :boolean) { |_expr, _value| true }
|
34
34
|
end
|
@@ -37,7 +37,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'allows `filter` as an alias of `node_filter`' do
|
40
|
-
fs =
|
40
|
+
fs = described_class.add(:test) do
|
41
41
|
filter(:node_test, :boolean) { |_node, _value| true }
|
42
42
|
end
|
43
43
|
|
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
|
6
6
|
RSpec.describe Capybara::Selenium::Driver do
|
7
7
|
it 'should exit with a non-zero exit status' do
|
8
8
|
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
9
|
-
browser =
|
9
|
+
browser = described_class.new(TestApp, options).browser
|
10
10
|
expect(browser).to be_truthy
|
11
11
|
expect(true).to eq(false) # rubocop:disable RSpec/ExpectActual
|
12
12
|
end
|
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
|
6
6
|
RSpec.describe Capybara::Selenium::Driver do
|
7
7
|
it 'should exit with a zero exit status' do
|
8
8
|
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
9
|
-
browser =
|
9
|
+
browser = described_class.new(TestApp, options).browser
|
10
10
|
expect(browser).to be_truthy
|
11
11
|
expect(true).to eq(true) # rubocop:disable RSpec/ExpectActual
|
12
12
|
end
|
data/spec/minitest_spec.rb
CHANGED
@@ -16,7 +16,7 @@ class MinitestTest < Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_assert_text
|
19
|
-
assert_text('Form')
|
19
|
+
assert_text('Form', normalize_ws: false)
|
20
20
|
assert_no_text('Not on the page')
|
21
21
|
refute_text('Also Not on the page')
|
22
22
|
end
|
@@ -105,6 +105,10 @@ class MinitestTest < Minitest::Test
|
|
105
105
|
assert_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
|
106
106
|
end
|
107
107
|
|
108
|
+
def test_assert_any_of_selectors
|
109
|
+
assert_any_of_selectors(:css, 'input#not_on_page', 'select#form_other_title')
|
110
|
+
end
|
111
|
+
|
108
112
|
def test_assert_matches_selector
|
109
113
|
assert_matches_selector(find(:field, 'customer_email'), :field, 'customer_email')
|
110
114
|
assert_not_matches_selector(find(:select, 'form_title'), :field, 'customer_email')
|
@@ -121,10 +125,20 @@ class MinitestTest < Minitest::Test
|
|
121
125
|
refute_matches_xpath(find(:select, 'form_title'), './/select[@id="form_other_title"]')
|
122
126
|
end
|
123
127
|
|
124
|
-
def
|
128
|
+
def test_assert_matches_style
|
125
129
|
skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
|
126
130
|
visit('/with_html')
|
127
|
-
|
131
|
+
assert_matches_style(find(:css, '#second'), display: 'inline')
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_assert_ancestor
|
135
|
+
option = find(:option, 'Finnish')
|
136
|
+
assert_ancestor(option, :css, '#form_locale')
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_assert_sibling
|
140
|
+
option = find(:css, '#form_title').find(:option, 'Mrs')
|
141
|
+
assert_sibling(option, :option, 'Mr')
|
128
142
|
end
|
129
143
|
end
|
130
144
|
|
@@ -144,6 +158,6 @@ RSpec.describe 'capybara/minitest' do
|
|
144
158
|
reporter.start
|
145
159
|
MinitestTest.run reporter, {}
|
146
160
|
reporter.report
|
147
|
-
expect(output.string).to include('
|
161
|
+
expect(output.string).to include('22 runs, 52 assertions, 0 failures, 0 errors, 1 skips')
|
148
162
|
end
|
149
163
|
end
|
data/spec/minitest_spec_spec.rb
CHANGED
@@ -17,110 +17,125 @@ class MinitestSpecTest < Minitest::Spec
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'supports text expectations' do
|
20
|
-
page.must_have_text('Form', minimum: 1)
|
21
|
-
page.wont_have_text('Not a form')
|
20
|
+
_(page).must_have_text('Form', minimum: 1)
|
21
|
+
_(page).wont_have_text('Not a form')
|
22
22
|
form = find(:css, 'form', text: 'Title')
|
23
|
-
form.must_have_text('Customer Email')
|
24
|
-
form.wont_have_text('Some other email')
|
23
|
+
_(form).must_have_text('Customer Email')
|
24
|
+
_(form).wont_have_text('Some other email')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'supports current_path expectations' do
|
28
|
-
page.must_have_current_path('/form')
|
29
|
-
page.wont_have_current_path('/form2')
|
28
|
+
_(page).must_have_current_path('/form')
|
29
|
+
_(page).wont_have_current_path('/form2')
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'supports title expectations' do
|
33
33
|
visit('/with_title')
|
34
|
-
page.must_have_title('Test Title')
|
35
|
-
page.wont_have_title('Not the title')
|
34
|
+
_(page).must_have_title('Test Title')
|
35
|
+
_(page).wont_have_title('Not the title')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'supports xpath expectations' do
|
39
|
-
page.must_have_xpath('.//input[@id="customer_email"]')
|
40
|
-
page.wont_have_xpath('.//select[@id="not_form_title"]')
|
41
|
-
page.wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
|
39
|
+
_(page).must_have_xpath('.//input[@id="customer_email"]')
|
40
|
+
_(page).wont_have_xpath('.//select[@id="not_form_title"]')
|
41
|
+
_(page).wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
|
42
42
|
select = find(:select, 'form_title')
|
43
|
-
select.must_have_xpath('.//option[@class="title"]')
|
44
|
-
select.must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
|
45
|
-
select.wont_have_xpath('.//input[@id="customer_email"]')
|
43
|
+
_(select).must_have_xpath('.//option[@class="title"]')
|
44
|
+
_(select).must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
|
45
|
+
_(select).wont_have_xpath('.//input[@id="customer_email"]')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'support css expectations' do
|
49
|
-
page.must_have_css('input#customer_email')
|
50
|
-
page.wont_have_css('select#not_form_title')
|
49
|
+
_(page).must_have_css('input#customer_email')
|
50
|
+
_(page).wont_have_css('select#not_form_title')
|
51
51
|
el = find(:select, 'form_title')
|
52
|
-
el.must_have_css('option.title')
|
53
|
-
el.wont_have_css('input#customer_email')
|
52
|
+
_(el).must_have_css('option.title')
|
53
|
+
_(el).wont_have_css('input#customer_email')
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'supports link expectations' do
|
57
57
|
visit('/with_html')
|
58
|
-
page.must_have_link('A link')
|
59
|
-
page.wont_have_link('Not on page')
|
58
|
+
_(page).must_have_link('A link')
|
59
|
+
_(page).wont_have_link('Not on page')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'supports button expectations' do
|
63
|
-
page.must_have_button('fresh_btn')
|
64
|
-
page.wont_have_button('not_btn')
|
63
|
+
_(page).must_have_button('fresh_btn')
|
64
|
+
_(page).wont_have_button('not_btn')
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'supports field expectations' do
|
68
|
-
page.must_have_field('customer_email')
|
69
|
-
page.wont_have_field('not_on_the_form')
|
68
|
+
_(page).must_have_field('customer_email')
|
69
|
+
_(page).wont_have_field('not_on_the_form')
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'supports select expectations' do
|
73
|
-
page.must_have_select('form_title')
|
74
|
-
page.wont_have_select('not_form_title')
|
73
|
+
_(page).must_have_select('form_title')
|
74
|
+
_(page).wont_have_select('not_form_title')
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'supports checked_field expectations' do
|
78
|
-
page.must_have_checked_field('form_pets_dog')
|
79
|
-
page.wont_have_checked_field('form_pets_cat')
|
78
|
+
_(page).must_have_checked_field('form_pets_dog')
|
79
|
+
_(page).wont_have_checked_field('form_pets_cat')
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'supports unchecked_field expectations' do
|
83
|
-
page.must_have_unchecked_field('form_pets_cat')
|
84
|
-
page.wont_have_unchecked_field('form_pets_dog')
|
83
|
+
_(page).must_have_unchecked_field('form_pets_cat')
|
84
|
+
_(page).wont_have_unchecked_field('form_pets_dog')
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'supports table expectations' do
|
88
88
|
visit('/tables')
|
89
|
-
page.must_have_table('agent_table')
|
90
|
-
page.wont_have_table('not_on_form')
|
89
|
+
_(page).must_have_table('agent_table')
|
90
|
+
_(page).wont_have_table('not_on_form')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'supports all_of_selectors expectations' do
|
94
|
-
page.must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
|
94
|
+
_(page).must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'supports none_of_selectors expectations' do
|
98
|
-
page.must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
|
98
|
+
_(page).must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'supports any_of_selectors expectations' do
|
102
|
+
_(page).must_have_any_of_selectors(:css, 'select#form_other_title', 'input#not_on_page')
|
99
103
|
end
|
100
104
|
|
101
105
|
it 'supports match_selector expectations' do
|
102
|
-
find(:field, 'customer_email').must_match_selector(:field, 'customer_email')
|
103
|
-
find(:select, 'form_title').wont_match_selector(:field, 'customer_email')
|
106
|
+
_(find(:field, 'customer_email')).must_match_selector(:field, 'customer_email')
|
107
|
+
_(find(:select, 'form_title')).wont_match_selector(:field, 'customer_email')
|
104
108
|
end
|
105
109
|
|
106
110
|
it 'supports match_css expectations' do
|
107
|
-
find(:select, 'form_title').must_match_css('select#form_title')
|
108
|
-
find(:select, 'form_title').wont_match_css('select#form_other_title')
|
111
|
+
_(find(:select, 'form_title')).must_match_css('select#form_title')
|
112
|
+
_(find(:select, 'form_title')).wont_match_css('select#form_other_title')
|
109
113
|
end
|
110
114
|
|
111
115
|
it 'supports match_xpath expectations' do
|
112
|
-
find(:select, 'form_title').must_match_xpath('.//select[@id="form_title"]')
|
113
|
-
find(:select, 'form_title').wont_match_xpath('.//select[@id="not_on_page"]')
|
116
|
+
_(find(:select, 'form_title')).must_match_xpath('.//select[@id="form_title"]')
|
117
|
+
_(find(:select, 'form_title')).wont_match_xpath('.//select[@id="not_on_page"]')
|
114
118
|
end
|
115
119
|
|
116
120
|
it 'handles failures' do
|
117
|
-
page.must_have_select('non_existing_form_title')
|
121
|
+
_(page).must_have_select('non_existing_form_title')
|
118
122
|
end
|
119
123
|
|
120
124
|
it 'supports style expectations' do
|
121
125
|
skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
|
122
126
|
visit('/with_html')
|
123
|
-
find(:css, '#second').must_have_style('display' => 'inline')
|
127
|
+
_(find(:css, '#second')).must_have_style('display' => 'inline') # deprecated
|
128
|
+
_(find(:css, '#second')).must_match_style('display' => 'inline')
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'supports ancestor expectations' do
|
132
|
+
option = find(:option, 'Finnish')
|
133
|
+
_(option).must_have_ancestor(:css, '#form_locale')
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'supports sibling expectations' do
|
137
|
+
option = find(:css, '#form_title').find(:option, 'Mrs')
|
138
|
+
_(option).must_have_sibling(:option, 'Mr')
|
124
139
|
end
|
125
140
|
end
|
126
141
|
|
@@ -140,8 +155,8 @@ RSpec.describe 'capybara/minitest/spec' do
|
|
140
155
|
reporter.start
|
141
156
|
MinitestSpecTest.run reporter, {}
|
142
157
|
reporter.report
|
143
|
-
expect(output.string).to include('
|
158
|
+
expect(output.string).to include('22 runs, 44 assertions, 1 failures, 0 errors, 1 skips')
|
144
159
|
# Make sure error messages are displayed
|
145
|
-
expect(output.string).to
|
160
|
+
expect(output.string).to match(/expected to find select box "non_existing_form_title" .*but there were no matches/)
|
146
161
|
end
|
147
162
|
end
|