capybara 2.15.1 → 3.35.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +1 -1
- data/History.md +871 -9
- data/License.txt +1 -1
- data/README.md +99 -75
- data/lib/capybara/config.rb +20 -59
- data/lib/capybara/cucumber.rb +2 -3
- data/lib/capybara/driver/base.rb +35 -18
- data/lib/capybara/driver/node.rb +35 -9
- data/lib/capybara/dsl.rb +15 -6
- data/lib/capybara/helpers.rb +72 -28
- data/lib/capybara/minitest/spec.rb +173 -81
- data/lib/capybara/minitest.rb +220 -111
- data/lib/capybara/node/actions.rb +270 -172
- data/lib/capybara/node/base.rb +41 -34
- data/lib/capybara/node/document.rb +15 -3
- data/lib/capybara/node/document_matchers.rb +19 -21
- data/lib/capybara/node/element.rb +353 -137
- data/lib/capybara/node/finders.rb +144 -138
- data/lib/capybara/node/matchers.rb +369 -209
- data/lib/capybara/node/simple.rb +55 -26
- data/lib/capybara/queries/ancestor_query.rb +11 -9
- data/lib/capybara/queries/base_query.rb +39 -28
- data/lib/capybara/queries/current_path_query.rb +22 -25
- data/lib/capybara/queries/match_query.rb +14 -7
- data/lib/capybara/queries/selector_query.rb +633 -145
- data/lib/capybara/queries/sibling_query.rb +10 -9
- data/lib/capybara/queries/style_query.rb +45 -0
- data/lib/capybara/queries/text_query.rb +56 -38
- data/lib/capybara/queries/title_query.rb +8 -11
- data/lib/capybara/rack_test/browser.rb +57 -41
- data/lib/capybara/rack_test/css_handlers.rb +6 -4
- data/lib/capybara/rack_test/driver.rb +18 -13
- data/lib/capybara/rack_test/errors.rb +6 -0
- data/lib/capybara/rack_test/form.rb +73 -58
- data/lib/capybara/rack_test/node.rb +182 -78
- data/lib/capybara/rails.rb +3 -7
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +42 -0
- data/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
- data/lib/capybara/registrations/servers.rb +45 -0
- data/lib/capybara/result.rb +96 -62
- data/lib/capybara/rspec/features.rb +17 -50
- data/lib/capybara/rspec/matcher_proxies.rb +51 -14
- 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 +43 -0
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
- data/lib/capybara/rspec/matchers.rb +144 -264
- data/lib/capybara/rspec.rb +7 -11
- data/lib/capybara/selector/builders/css_builder.rb +84 -0
- data/lib/capybara/selector/builders/xpath_builder.rb +71 -0
- data/lib/capybara/selector/css.rb +89 -17
- data/lib/capybara/selector/definition/button.rb +63 -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 +28 -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 +278 -0
- data/lib/capybara/selector/filter.rb +2 -17
- data/lib/capybara/selector/filter_set.rb +83 -33
- data/lib/capybara/selector/filters/base.rb +50 -6
- data/lib/capybara/selector/filters/expression_filter.rb +8 -26
- data/lib/capybara/selector/filters/locator_filter.rb +29 -0
- data/lib/capybara/selector/filters/node_filter.rb +16 -12
- data/lib/capybara/selector/regexp_disassembler.rb +214 -0
- data/lib/capybara/selector/selector.rb +89 -210
- data/lib/capybara/selector/xpath_extensions.rb +17 -0
- data/lib/capybara/selector.rb +226 -526
- 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 +334 -277
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +117 -0
- 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 +228 -0
- data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
- data/lib/capybara/selenium/extensions/scroll.rb +76 -0
- data/lib/capybara/selenium/logger_suppressor.rb +40 -0
- data/lib/capybara/selenium/node.rb +506 -124
- data/lib/capybara/selenium/nodes/chrome_node.rb +137 -0
- data/lib/capybara/selenium/nodes/edge_node.rb +104 -0
- data/lib/capybara/selenium/nodes/firefox_node.rb +136 -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 +9 -0
- data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
- data/lib/capybara/server/animation_disabler.rb +63 -0
- data/lib/capybara/server/checker.rb +44 -0
- data/lib/capybara/server/middleware.rb +71 -0
- data/lib/capybara/server.rb +59 -67
- data/lib/capybara/session/config.rb +79 -59
- data/lib/capybara/session/matchers.rb +41 -25
- data/lib/capybara/session.rb +360 -356
- data/lib/capybara/spec/public/jquery.js +5 -5
- data/lib/capybara/spec/public/offset.js +6 -0
- data/lib/capybara/spec/public/test.js +159 -13
- data/lib/capybara/spec/session/accept_alert_spec.rb +12 -11
- data/lib/capybara/spec/session/accept_confirm_spec.rb +6 -5
- data/lib/capybara/spec/session/accept_prompt_spec.rb +34 -6
- data/lib/capybara/spec/session/all_spec.rb +163 -55
- data/lib/capybara/spec/session/ancestor_spec.rb +27 -24
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +68 -38
- data/lib/capybara/spec/session/assert_current_path_spec.rb +75 -0
- data/lib/capybara/spec/session/assert_selector_spec.rb +143 -0
- data/lib/capybara/spec/session/assert_style_spec.rb +26 -0
- data/lib/capybara/spec/session/{assert_text.rb → assert_text_spec.rb} +91 -59
- data/lib/capybara/spec/session/{assert_title.rb → assert_title_spec.rb} +22 -12
- data/lib/capybara/spec/session/attach_file_spec.rb +138 -69
- data/lib/capybara/spec/session/body_spec.rb +12 -13
- data/lib/capybara/spec/session/check_spec.rb +107 -55
- data/lib/capybara/spec/session/choose_spec.rb +58 -31
- data/lib/capybara/spec/session/click_button_spec.rb +231 -173
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +55 -35
- data/lib/capybara/spec/session/click_link_spec.rb +82 -58
- data/lib/capybara/spec/session/current_scope_spec.rb +11 -10
- data/lib/capybara/spec/session/current_url_spec.rb +57 -39
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +4 -4
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +3 -2
- data/lib/capybara/spec/session/element/{assert_match_selector.rb → assert_match_selector_spec.rb} +11 -9
- data/lib/capybara/spec/session/element/match_css_spec.rb +18 -10
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +9 -7
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +71 -57
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +23 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +30 -9
- data/lib/capybara/spec/session/execute_script_spec.rb +10 -8
- data/lib/capybara/spec/session/fill_in_spec.rb +128 -43
- data/lib/capybara/spec/session/find_button_spec.rb +25 -24
- data/lib/capybara/spec/session/find_by_id_spec.rb +10 -9
- data/lib/capybara/spec/session/find_field_spec.rb +37 -41
- data/lib/capybara/spec/session/find_link_spec.rb +36 -17
- data/lib/capybara/spec/session/find_spec.rb +245 -144
- data/lib/capybara/spec/session/first_spec.rb +79 -51
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +33 -20
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +50 -32
- data/lib/capybara/spec/session/go_back_spec.rb +2 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +2 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
- 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 +70 -13
- data/lib/capybara/spec/session/has_css_spec.rb +272 -137
- data/lib/capybara/spec/session/has_current_path_spec.rb +87 -45
- data/lib/capybara/spec/session/has_field_spec.rb +115 -59
- data/lib/capybara/spec/session/has_link_spec.rb +10 -9
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +78 -0
- data/lib/capybara/spec/session/has_select_spec.rb +103 -74
- data/lib/capybara/spec/session/has_selector_spec.rb +105 -71
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/has_table_spec.rb +172 -5
- data/lib/capybara/spec/session/has_text_spec.rb +113 -61
- data/lib/capybara/spec/session/has_title_spec.rb +20 -14
- data/lib/capybara/spec/session/has_xpath_spec.rb +57 -38
- data/lib/capybara/spec/session/{headers.rb → headers_spec.rb} +3 -2
- data/lib/capybara/spec/session/html_spec.rb +14 -6
- data/lib/capybara/spec/session/matches_style_spec.rb +35 -0
- data/lib/capybara/spec/session/node_spec.rb +950 -152
- data/lib/capybara/spec/session/node_wrapper_spec.rb +39 -0
- data/lib/capybara/spec/session/refresh_spec.rb +12 -6
- data/lib/capybara/spec/session/reset_session_spec.rb +69 -35
- data/lib/capybara/spec/session/{response_code.rb → response_code_spec.rb} +2 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +3 -2
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +8 -12
- data/lib/capybara/spec/session/save_page_spec.rb +42 -55
- data/lib/capybara/spec/session/save_screenshot_spec.rb +16 -14
- data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/scroll_spec.rb +117 -0
- data/lib/capybara/spec/session/select_spec.rb +107 -80
- data/lib/capybara/spec/session/selectors_spec.rb +52 -19
- data/lib/capybara/spec/session/sibling_spec.rb +10 -10
- data/lib/capybara/spec/session/text_spec.rb +37 -21
- data/lib/capybara/spec/session/title_spec.rb +17 -5
- data/lib/capybara/spec/session/uncheck_spec.rb +42 -22
- data/lib/capybara/spec/session/unselect_spec.rb +39 -38
- data/lib/capybara/spec/session/visit_spec.rb +99 -32
- data/lib/capybara/spec/session/window/become_closed_spec.rb +24 -20
- data/lib/capybara/spec/session/window/current_window_spec.rb +5 -3
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +5 -3
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +27 -22
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +12 -6
- data/lib/capybara/spec/session/window/window_spec.rb +97 -63
- data/lib/capybara/spec/session/window/windows_spec.rb +12 -10
- data/lib/capybara/spec/session/window/within_window_spec.rb +31 -86
- data/lib/capybara/spec/session/within_spec.rb +70 -44
- data/lib/capybara/spec/spec_helper.rb +48 -43
- data/lib/capybara/spec/test_app.rb +78 -40
- data/lib/capybara/spec/views/animated.erb +49 -0
- data/lib/capybara/spec/views/form.erb +130 -39
- 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/initial_alert.erb +10 -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 +68 -1
- data/lib/capybara/spec/views/with_animation.erb +82 -0
- data/lib/capybara/spec/views/with_dragula.erb +24 -0
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
- data/lib/capybara/spec/views/with_hover.erb +6 -0
- data/lib/capybara/spec/views/with_hover1.erb +10 -0
- data/lib/capybara/spec/views/with_html.erb +69 -10
- data/lib/capybara/spec/views/with_html5_svg.erb +20 -0
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +37 -0
- data/lib/capybara/spec/views/with_jstree.erb +26 -0
- data/lib/capybara/spec/views/with_namespace.erb +20 -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/spec/views/within_frames.erb +4 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +35 -33
- data/lib/capybara.rb +131 -104
- data/spec/basic_node_spec.rb +47 -34
- data/spec/capybara_spec.rb +53 -104
- data/spec/css_builder_spec.rb +101 -0
- data/spec/css_splitter_spec.rb +38 -0
- data/spec/dsl_spec.rb +81 -62
- data/spec/filter_set_spec.rb +27 -9
- data/spec/fixtures/certificate.pem +25 -0
- data/spec/fixtures/key.pem +27 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +5 -4
- data/spec/fixtures/selenium_driver_rspec_success.rb +5 -4
- data/spec/minitest_spec.rb +49 -7
- data/spec/minitest_spec_spec.rb +94 -59
- data/spec/per_session_config_spec.rb +14 -13
- data/spec/rack_test_spec.rb +176 -125
- data/spec/regexp_dissassembler_spec.rb +250 -0
- data/spec/result_spec.rb +101 -46
- data/spec/rspec/features_spec.rb +37 -31
- data/spec/rspec/scenarios_spec.rb +9 -7
- data/spec/rspec/shared_spec_matchers.rb +448 -421
- data/spec/rspec/views_spec.rb +5 -3
- data/spec/rspec_matchers_spec.rb +27 -11
- data/spec/rspec_spec.rb +109 -89
- data/spec/sauce_spec_chrome.rb +43 -0
- data/spec/selector_spec.rb +396 -67
- data/spec/selenium_spec_chrome.rb +184 -35
- data/spec/selenium_spec_chrome_remote.rb +100 -0
- data/spec/selenium_spec_edge.rb +47 -0
- data/spec/selenium_spec_firefox.rb +183 -41
- data/spec/selenium_spec_firefox_remote.rb +80 -0
- data/spec/selenium_spec_ie.rb +150 -0
- data/spec/selenium_spec_safari.rb +148 -0
- data/spec/server_spec.rb +198 -99
- data/spec/session_spec.rb +53 -16
- data/spec/shared_selenium_node.rb +83 -0
- data/spec/shared_selenium_session.rb +486 -97
- data/spec/spec_helper.rb +93 -7
- data/spec/xpath_builder_spec.rb +93 -0
- metadata +338 -64
- data/.yard/templates_custom/default/class/html/selectors.erb +0 -38
- data/.yard/templates_custom/default/class/html/setup.rb +0 -17
- data/.yard/yard_extensions.rb +0 -78
- data/lib/capybara/query.rb +0 -7
- data/lib/capybara/rspec/compound.rb +0 -95
- data/lib/capybara/spec/session/assert_current_path.rb +0 -72
- data/lib/capybara/spec/session/assert_selector.rb +0 -148
- data/lib/capybara/spec/session/source_spec.rb +0 -0
- data/spec/selenium_spec_marionette.rb +0 -117
@@ -1,38 +0,0 @@
|
|
1
|
-
<div id="selectors">
|
2
|
-
<h2>Built-in Selectors</h2>
|
3
|
-
<ul>
|
4
|
-
<% @selectors.each do |name, selector| %>
|
5
|
-
<li>
|
6
|
-
<h3>:<%= name %></h3>
|
7
|
-
<div class="docstring">
|
8
|
-
<div class="discussion">
|
9
|
-
<p><%= h(selector.docstring) %></p>
|
10
|
-
</div>
|
11
|
-
</div>
|
12
|
-
<div class="tags">
|
13
|
-
<p class="inline">Locator:</p>
|
14
|
-
<% if locator=selector.tag('locator') %>
|
15
|
-
<p class="inline"><%= h locator.text %></p>
|
16
|
-
<% end %>
|
17
|
-
<% if selector.has_tag?('filter') %>
|
18
|
-
<p>Filters:</p>
|
19
|
-
<ul class="param">
|
20
|
-
<% selector.tags('filter').each do |filter| %>
|
21
|
-
<li>
|
22
|
-
<span class="name"><%= filter.name %></span>
|
23
|
-
<% if filter.types %>
|
24
|
-
<span class="type">(<tt><%= h(filter.types.join(', ')) %></tt>)</span>
|
25
|
-
<% end %>
|
26
|
-
<% if filter.text %>
|
27
|
-
—
|
28
|
-
<div class="inline"><p><%= h filter.text %></p></div>
|
29
|
-
<% end %>
|
30
|
-
</li>
|
31
|
-
<% end %>
|
32
|
-
</ul>
|
33
|
-
<% end %>
|
34
|
-
</div
|
35
|
-
</li>
|
36
|
-
<% end %>
|
37
|
-
</ul>
|
38
|
-
</div>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
def init
|
2
|
-
super
|
3
|
-
sections.place(:builtins).before(:subclasses)
|
4
|
-
end
|
5
|
-
|
6
|
-
def builtins
|
7
|
-
return if object.path != "Capybara::Selector" # only show built-in selectors for Selector class
|
8
|
-
|
9
|
-
@selectors = Registry.all(:selector)
|
10
|
-
return if @selectors.nil? || @selectors.empty?
|
11
|
-
|
12
|
-
@selectors = @selectors.map do |selector|
|
13
|
-
[selector.name, selector]
|
14
|
-
end
|
15
|
-
|
16
|
-
erb(:selectors)
|
17
|
-
end
|
data/.yard/yard_extensions.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
YARD::Templates::Engine.register_template_path Pathname.new('./.yard/templates_custom')
|
2
|
-
|
3
|
-
YARD::Tags::Library.define_tag "Locator", :locator
|
4
|
-
YARD::Tags::Library.define_tag "Filter", :filter, :with_types_and_name
|
5
|
-
|
6
|
-
class SelectorObject < YARD::CodeObjects::Base
|
7
|
-
def path
|
8
|
-
"__Capybara" + sep + super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class AddSelectorHandler < YARD::Handlers::Ruby::Base
|
13
|
-
handles method_call(:add_selector)
|
14
|
-
namespace_only
|
15
|
-
process do
|
16
|
-
name = statement.parameters.first.jump(:tstring_content, :ident).source
|
17
|
-
# object = YARD::CodeObjects::MethodObject.new(namespace, name.to_sym)
|
18
|
-
# object = SelectorObject.new(YARD::Registry.resolve(P("Capybara"), "#add_selector", false, true), name.to_sym)
|
19
|
-
object = SelectorObject.new(namespace, name)
|
20
|
-
register(object)
|
21
|
-
parse_block(statement.last.last, :owner => object)
|
22
|
-
|
23
|
-
# modify the object
|
24
|
-
object.dynamic = true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class AddExpressionFilterHandler < YARD::Handlers::Ruby::Base
|
29
|
-
handles method_call(:xpath)
|
30
|
-
handles method_call(:css)
|
31
|
-
|
32
|
-
process do
|
33
|
-
return unless owner.is_a?(SelectorObject)
|
34
|
-
return if statement.parameters.empty?
|
35
|
-
# names = statement.parameters.children.map { |p| p.jump(:tstring_content, :ident).source.sub(/^:/, '') }
|
36
|
-
names = statement.parameters.children.map &:source
|
37
|
-
current_names = owner.tags(:filter).map(&:name)
|
38
|
-
(names-current_names).each do |name|
|
39
|
-
owner.add_tag(YARD::Tags::Tag.new(:filter, nil, nil, name))
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class AddFilterHandler < YARD::Handlers::Ruby::Base
|
45
|
-
handles method_call(:filter)
|
46
|
-
|
47
|
-
process do
|
48
|
-
return unless owner.is_a?(SelectorObject)
|
49
|
-
return if statement.parameters.empty?
|
50
|
-
name = statement.parameters.first.source
|
51
|
-
type = if statement.parameters[1] && statement.parameters[1].source == ':boolean'
|
52
|
-
'Boolean'
|
53
|
-
else
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
if owner.tags(:filter).none? {|tag| tag.name == name }
|
57
|
-
filter_tag = YARD::Tags::Tag.new(:filter, nil, type, name)
|
58
|
-
owner.add_tag(filter_tag)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class FilterSetHandler < YARD::Handlers::Ruby::Base
|
64
|
-
handles method_call(:filter_set)
|
65
|
-
|
66
|
-
process do
|
67
|
-
return unless owner.is_a?(SelectorObject)
|
68
|
-
return if statement.parameters.empty? || !statement.parameters[1]
|
69
|
-
|
70
|
-
names = statement.parameters[1].flatten.map { |name| ":#{name}" }
|
71
|
-
names.each do |name|
|
72
|
-
if owner.tags(:filter).none? {|tag| tag.name == name }
|
73
|
-
filter_tag = YARD::Tags::Tag.new(:filter, nil, nil, name)
|
74
|
-
owner.add_tag(filter_tag)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/capybara/query.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'capybara/queries/selector_query'
|
3
|
-
module Capybara
|
4
|
-
# @deprecated This class and its methods are not supposed to be used by users of Capybara's public API.
|
5
|
-
# It may be removed in future versions of Capybara.
|
6
|
-
Query = Queries::SelectorQuery
|
7
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module RSpecMatchers
|
3
|
-
module Compound
|
4
|
-
include ::RSpec::Matchers::Composable
|
5
|
-
|
6
|
-
def and(matcher)
|
7
|
-
Capybara::RSpecMatchers::Compound::And.new(self,matcher)
|
8
|
-
end
|
9
|
-
|
10
|
-
def and_then(matcher)
|
11
|
-
::RSpec::Matchers::BuiltIn::Compound::And.new(self, matcher)
|
12
|
-
end
|
13
|
-
|
14
|
-
def or(matcher)
|
15
|
-
Capybara::RSpecMatchers::Compound::Or.new(self, matcher)
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
class CapybaraEvaluator
|
20
|
-
def initialize(actual, matcher_1, matcher_2)
|
21
|
-
@actual = actual
|
22
|
-
@matcher_1 = matcher_1
|
23
|
-
@matcher_2 = matcher_2
|
24
|
-
@match_results = Hash.new { |h, matcher| h[matcher] = matcher.matches?(@actual) }
|
25
|
-
end
|
26
|
-
|
27
|
-
def matcher_matches?(matcher)
|
28
|
-
@match_results[matcher]
|
29
|
-
end
|
30
|
-
|
31
|
-
def reset
|
32
|
-
@match_results.clear
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class And < ::RSpec::Matchers::BuiltIn::Compound::And
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def match(_expected, actual)
|
41
|
-
@evaluator = CapybaraEvaluator.new(actual, matcher_1, matcher_2)
|
42
|
-
syncer = sync_element(actual)
|
43
|
-
begin
|
44
|
-
syncer.synchronize do
|
45
|
-
@evaluator.reset
|
46
|
-
raise ::Capybara::ElementNotFound unless [matcher_1_matches?, matcher_2_matches?].all?
|
47
|
-
true
|
48
|
-
end
|
49
|
-
rescue
|
50
|
-
false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def sync_element(el)
|
55
|
-
if el.respond_to? :synchronize
|
56
|
-
el
|
57
|
-
elsif el.respond_to? :current_scope
|
58
|
-
el.current_scope
|
59
|
-
else
|
60
|
-
Capybara.string(el)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class Or < ::RSpec::Matchers::BuiltIn::Compound::Or
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def match(_expected, actual)
|
70
|
-
@evaluator = CapybaraEvaluator.new(actual, matcher_1, matcher_2)
|
71
|
-
syncer = sync_element(actual)
|
72
|
-
begin
|
73
|
-
syncer.synchronize do
|
74
|
-
@evaluator.reset
|
75
|
-
raise ::Capybara::ElementNotFound unless [matcher_1_matches?, matcher_2_matches?].any?
|
76
|
-
true
|
77
|
-
end
|
78
|
-
rescue
|
79
|
-
false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def sync_element(el)
|
84
|
-
if el.respond_to? :synchronize
|
85
|
-
el
|
86
|
-
elsif el.respond_to? :current_scope
|
87
|
-
el.current_scope
|
88
|
-
else
|
89
|
-
Capybara.string(el)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
Capybara::SpecHelper.spec '#assert_current_path' do
|
3
|
-
before do
|
4
|
-
@session.visit('/with_js')
|
5
|
-
end
|
6
|
-
|
7
|
-
it "should not raise if the page has the given current path" do
|
8
|
-
expect {@session.assert_current_path('/with_js')}.not_to raise_error
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should allow regexp matches" do
|
12
|
-
expect { @session.assert_current_path(/w[a-z]{3}_js/) }.not_to raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should wait for current_path", requires: [:js] do
|
16
|
-
@session.click_link("Change page")
|
17
|
-
expect { @session.assert_current_path("/with_html") }.not_to raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should raise if the page has not the given current_path" do
|
21
|
-
expect{@session.assert_current_path('/with_html')}.to raise_error(Capybara::ExpectationNotMet, 'expected "/with_js" to equal "/with_html"')
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should check query options" do
|
25
|
-
@session.visit('/with_js?test=test')
|
26
|
-
expect{@session.assert_current_path('/with_js?test=test')}.not_to raise_error
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should compare the full url" do
|
30
|
-
expect{@session.assert_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true)}.not_to raise_error
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should ignore the query" do
|
34
|
-
@session.visit('/with_js?test=test')
|
35
|
-
expect{@session.assert_current_path('/with_js', only_path: true)}.not_to raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should not cause an exception when current_url is nil" do
|
39
|
-
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
40
|
-
|
41
|
-
expect{@session.assert_current_path(nil)}.not_to raise_error
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
Capybara::SpecHelper.spec '#assert_no_current_path?' do
|
46
|
-
before do
|
47
|
-
@session.visit('/with_js')
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should raise if the page has the given current_path" do
|
51
|
-
expect{@session.assert_no_current_path('/with_js')}.to raise_error(Capybara::ExpectationNotMet)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should allow regexp matches" do
|
55
|
-
expect{@session.assert_no_current_path(/monkey/)}.not_to raise_error
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should wait for current_path to disappear", requires: [:js] do
|
59
|
-
@session.click_link("Change page")
|
60
|
-
expect{@session.assert_no_current_path('/with_js')}.not_to raise_error
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should not raise if the page has not the given current_path" do
|
64
|
-
expect{@session.assert_no_current_path('/with_html')}.not_to raise_error
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should not cause an exception when current_url is nil" do
|
68
|
-
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
69
|
-
|
70
|
-
expect{@session.assert_no_current_path('/with_html')}.not_to raise_error
|
71
|
-
end
|
72
|
-
end
|
@@ -1,148 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
Capybara::SpecHelper.spec '#assert_selector' do
|
3
|
-
before do
|
4
|
-
@session.visit('/with_html')
|
5
|
-
end
|
6
|
-
|
7
|
-
it "should be true if the given selector is on the page" do
|
8
|
-
@session.assert_selector(:xpath, "//p")
|
9
|
-
@session.assert_selector(:css, "p a#foo")
|
10
|
-
@session.assert_selector("//p[contains(.,'est')]")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should be false if the given selector is not on the page" do
|
14
|
-
expect { @session.assert_selector(:xpath, "//abbr") }.to raise_error(Capybara::ElementNotFound)
|
15
|
-
expect { @session.assert_selector(:css, "p a#doesnotexist") }.to raise_error(Capybara::ElementNotFound)
|
16
|
-
expect { @session.assert_selector("//p[contains(.,'thisstringisnotonpage')]") }.to raise_error(Capybara::ElementNotFound)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should use default selector" do
|
20
|
-
Capybara.default_selector = :css
|
21
|
-
expect { @session.assert_selector("p a#doesnotexist") }.to raise_error(Capybara::ElementNotFound)
|
22
|
-
@session.assert_selector("p a#foo")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should respect scopes" do
|
26
|
-
@session.within "//p[@id='first']" do
|
27
|
-
@session.assert_selector(".//a[@id='foo']")
|
28
|
-
expect { @session.assert_selector(".//a[@id='red']") }.to raise_error(Capybara::ElementNotFound)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with count" do
|
33
|
-
it "should be true if the content is on the page the given number of times" do
|
34
|
-
@session.assert_selector("//p", count: 3)
|
35
|
-
@session.assert_selector("//p//a[@id='foo']", count: 1)
|
36
|
-
@session.assert_selector("//p[contains(.,'est')]", count: 1)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should be false if the content is on the page the given number of times" do
|
40
|
-
expect { @session.assert_selector("//p", count: 6) }.to raise_error(Capybara::ElementNotFound)
|
41
|
-
expect { @session.assert_selector("//p//a[@id='foo']", count: 2) }.to raise_error(Capybara::ElementNotFound)
|
42
|
-
expect { @session.assert_selector("//p[contains(.,'est')]", count: 5) }.to raise_error(Capybara::ElementNotFound)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should be false if the content isn't on the page at all" do
|
46
|
-
expect { @session.assert_selector("//abbr", count: 2) }.to raise_error(Capybara::ElementNotFound)
|
47
|
-
expect { @session.assert_selector("//p//a[@id='doesnotexist']", count: 1) }.to raise_error(Capybara::ElementNotFound)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "with text" do
|
52
|
-
it "should discard all matches where the given string is not contained" do
|
53
|
-
@session.assert_selector("//p//a", text: "Redirect", count: 1)
|
54
|
-
expect { @session.assert_selector("//p", text: "Doesnotexist") }.to raise_error(Capybara::ElementNotFound)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should discard all matches where the given regexp is not matched" do
|
58
|
-
@session.assert_selector("//p//a", text: /re[dab]i/i, count: 1)
|
59
|
-
expect { @session.assert_selector("//p//a", text: /Red$/) }.to raise_error(Capybara::ElementNotFound)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "with wait", requires: [:js] do
|
64
|
-
it "should find element if it appears before given wait duration" do
|
65
|
-
Capybara.using_wait_time(0.1) do
|
66
|
-
@session.visit('/with_js')
|
67
|
-
@session.click_link('Click me')
|
68
|
-
@session.assert_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 2)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
Capybara::SpecHelper.spec '#refute_selector' do
|
75
|
-
it "should be an alias of #assert_no_selector" do
|
76
|
-
expect(Capybara::Node::Matchers.instance_method(:refute_selector)).to eq Capybara::Node::Matchers.instance_method(:assert_no_selector)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
Capybara::SpecHelper.spec '#assert_no_selector' do
|
81
|
-
before do
|
82
|
-
@session.visit('/with_html')
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should be false if the given selector is on the page" do
|
86
|
-
expect { @session.assert_no_selector(:xpath, "//p") }.to raise_error(Capybara::ElementNotFound)
|
87
|
-
expect { @session.assert_no_selector(:css, "p a#foo") }.to raise_error(Capybara::ElementNotFound)
|
88
|
-
expect { @session.assert_no_selector("//p[contains(.,'est')]") }.to raise_error(Capybara::ElementNotFound)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should be true if the given selector is not on the page" do
|
92
|
-
@session.assert_no_selector(:xpath, "//abbr")
|
93
|
-
@session.assert_no_selector(:css, "p a#doesnotexist")
|
94
|
-
@session.assert_no_selector("//p[contains(.,'thisstringisnotonpage')]")
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should use default selector" do
|
98
|
-
Capybara.default_selector = :css
|
99
|
-
@session.assert_no_selector("p a#doesnotexist")
|
100
|
-
expect { @session.assert_no_selector("p a#foo") }.to raise_error(Capybara::ElementNotFound)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should respect scopes" do
|
104
|
-
@session.within "//p[@id='first']" do
|
105
|
-
expect { @session.assert_no_selector(".//a[@id='foo']") }.to raise_error(Capybara::ElementNotFound)
|
106
|
-
@session.assert_no_selector(".//a[@id='red']")
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "with count" do
|
111
|
-
it "should be false if the content is on the page the given number of times" do
|
112
|
-
expect { @session.assert_no_selector("//p", count: 3) }.to raise_error(Capybara::ElementNotFound)
|
113
|
-
expect { @session.assert_no_selector("//p//a[@id='foo']", count: 1) }.to raise_error(Capybara::ElementNotFound)
|
114
|
-
expect { @session.assert_no_selector("//p[contains(.,'est')]", count: 1) }.to raise_error(Capybara::ElementNotFound)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should be true if the content is on the page the wrong number of times" do
|
118
|
-
@session.assert_no_selector("//p", count: 6)
|
119
|
-
@session.assert_no_selector("//p//a[@id='foo']", count: 2)
|
120
|
-
@session.assert_no_selector("//p[contains(.,'est')]", count: 5)
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should be true if the content isn't on the page at all" do
|
124
|
-
@session.assert_no_selector("//abbr", count: 2)
|
125
|
-
@session.assert_no_selector("//p//a[@id='doesnotexist']", count: 1)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "with text" do
|
130
|
-
it "should discard all matches where the given string is contained" do
|
131
|
-
expect { @session.assert_no_selector("//p//a", text: "Redirect", count: 1) }.to raise_error(Capybara::ElementNotFound)
|
132
|
-
@session.assert_no_selector("//p", text: "Doesnotexist")
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should discard all matches where the given regexp is matched" do
|
136
|
-
expect { @session.assert_no_selector("//p//a", text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
|
137
|
-
@session.assert_no_selector("//p//a", text: /Red$/)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context "with wait", requires: [:js] do
|
142
|
-
it "should not find element if it appears after given wait duration" do
|
143
|
-
@session.visit('/with_js')
|
144
|
-
@session.click_link('Click me')
|
145
|
-
@session.assert_no_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 0.1)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|