capybara 3.27.0 → 3.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +82 -0
  3. data/README.md +2 -2
  4. data/lib/capybara/config.rb +7 -3
  5. data/lib/capybara/driver/node.rb +4 -0
  6. data/lib/capybara/dsl.rb +10 -2
  7. data/lib/capybara/helpers.rb +3 -1
  8. data/lib/capybara/minitest.rb +231 -142
  9. data/lib/capybara/minitest/spec.rb +153 -97
  10. data/lib/capybara/node/actions.rb +24 -19
  11. data/lib/capybara/node/document.rb +2 -2
  12. data/lib/capybara/node/document_matchers.rb +3 -3
  13. data/lib/capybara/node/element.rb +55 -17
  14. data/lib/capybara/node/finders.rb +17 -11
  15. data/lib/capybara/node/matchers.rb +60 -45
  16. data/lib/capybara/node/simple.rb +5 -3
  17. data/lib/capybara/queries/ancestor_query.rb +1 -1
  18. data/lib/capybara/queries/base_query.rb +2 -1
  19. data/lib/capybara/queries/selector_query.rb +218 -4
  20. data/lib/capybara/queries/sibling_query.rb +1 -1
  21. data/lib/capybara/rack_test/browser.rb +7 -2
  22. data/lib/capybara/rack_test/driver.rb +1 -1
  23. data/lib/capybara/rack_test/form.rb +1 -1
  24. data/lib/capybara/rack_test/node.rb +38 -3
  25. data/lib/capybara/registrations/patches/puma_ssl.rb +27 -0
  26. data/lib/capybara/registrations/servers.rb +5 -2
  27. data/lib/capybara/result.rb +30 -9
  28. data/lib/capybara/rspec/matcher_proxies.rb +4 -4
  29. data/lib/capybara/rspec/matchers.rb +27 -27
  30. data/lib/capybara/rspec/matchers/base.rb +14 -6
  31. data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
  32. data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
  33. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  34. data/lib/capybara/rspec/matchers/have_selector.rb +15 -7
  35. data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
  36. data/lib/capybara/rspec/matchers/have_text.rb +2 -2
  37. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  38. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  39. data/lib/capybara/rspec/matchers/match_style.rb +2 -2
  40. data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
  41. data/lib/capybara/selector.rb +35 -17
  42. data/lib/capybara/selector/css.rb +1 -1
  43. data/lib/capybara/selector/definition.rb +2 -2
  44. data/lib/capybara/selector/definition/button.rb +7 -2
  45. data/lib/capybara/selector/definition/checkbox.rb +2 -2
  46. data/lib/capybara/selector/definition/css.rb +3 -1
  47. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  48. data/lib/capybara/selector/definition/datalist_option.rb +1 -1
  49. data/lib/capybara/selector/definition/element.rb +1 -1
  50. data/lib/capybara/selector/definition/field.rb +1 -1
  51. data/lib/capybara/selector/definition/file_field.rb +1 -1
  52. data/lib/capybara/selector/definition/fillable_field.rb +2 -2
  53. data/lib/capybara/selector/definition/label.rb +4 -2
  54. data/lib/capybara/selector/definition/radio_button.rb +2 -2
  55. data/lib/capybara/selector/definition/select.rb +32 -13
  56. data/lib/capybara/selector/definition/table.rb +5 -2
  57. data/lib/capybara/selector/filter_set.rb +11 -9
  58. data/lib/capybara/selector/filters/base.rb +6 -1
  59. data/lib/capybara/selector/filters/locator_filter.rb +1 -1
  60. data/lib/capybara/selector/selector.rb +4 -2
  61. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
  62. data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
  63. data/lib/capybara/selenium/driver.rb +24 -11
  64. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +1 -5
  65. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +6 -4
  66. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -8
  67. data/lib/capybara/selenium/driver_specializations/safari_driver.rb +0 -4
  68. data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
  69. data/lib/capybara/selenium/extensions/find.rb +19 -9
  70. data/lib/capybara/selenium/extensions/html5_drag.rb +37 -15
  71. data/lib/capybara/selenium/node.rb +116 -23
  72. data/lib/capybara/selenium/nodes/chrome_node.rb +13 -18
  73. data/lib/capybara/selenium/nodes/edge_node.rb +32 -14
  74. data/lib/capybara/selenium/nodes/firefox_node.rb +5 -7
  75. data/lib/capybara/selenium/nodes/safari_node.rb +0 -4
  76. data/lib/capybara/selenium/patches/action_pauser.rb +23 -0
  77. data/lib/capybara/server.rb +15 -3
  78. data/lib/capybara/server/checker.rb +1 -1
  79. data/lib/capybara/server/middleware.rb +20 -10
  80. data/lib/capybara/session.rb +40 -23
  81. data/lib/capybara/session/config.rb +6 -2
  82. data/lib/capybara/session/matchers.rb +6 -6
  83. data/lib/capybara/spec/public/test.js +62 -6
  84. data/lib/capybara/spec/session/all_spec.rb +60 -5
  85. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  86. data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
  87. data/lib/capybara/spec/session/click_button_spec.rb +5 -0
  88. data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
  89. data/lib/capybara/spec/session/find_spec.rb +55 -0
  90. data/lib/capybara/spec/session/has_css_spec.rb +24 -3
  91. data/lib/capybara/spec/session/has_field_spec.rb +18 -0
  92. data/lib/capybara/spec/session/has_select_spec.rb +28 -0
  93. data/lib/capybara/spec/session/has_table_spec.rb +51 -5
  94. data/lib/capybara/spec/session/has_text_spec.rb +35 -0
  95. data/lib/capybara/spec/session/node_spec.rb +185 -30
  96. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  97. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  98. data/lib/capybara/spec/session/selectors_spec.rb +15 -2
  99. data/lib/capybara/spec/session/window/window_spec.rb +7 -7
  100. data/lib/capybara/spec/spec_helper.rb +1 -2
  101. data/lib/capybara/spec/views/form.erb +18 -2
  102. data/lib/capybara/spec/views/spatial.erb +31 -0
  103. data/lib/capybara/spec/views/with_html.erb +12 -3
  104. data/lib/capybara/spec/views/with_jstree.erb +26 -0
  105. data/lib/capybara/version.rb +1 -1
  106. data/spec/dsl_spec.rb +3 -3
  107. data/spec/minitest_spec_spec.rb +46 -46
  108. data/spec/rack_test_spec.rb +13 -1
  109. data/spec/regexp_dissassembler_spec.rb +40 -36
  110. data/spec/result_spec.rb +43 -16
  111. data/spec/rspec/features_spec.rb +1 -0
  112. data/spec/rspec/shared_spec_matchers.rb +3 -3
  113. data/spec/rspec_spec.rb +4 -4
  114. data/spec/selenium_spec_chrome.rb +12 -3
  115. data/spec/selenium_spec_chrome_remote.rb +2 -6
  116. data/spec/selenium_spec_edge.rb +14 -15
  117. data/spec/selenium_spec_firefox.rb +7 -4
  118. data/spec/selenium_spec_firefox_remote.rb +0 -8
  119. data/spec/selenium_spec_ie.rb +1 -6
  120. data/spec/server_spec.rb +42 -0
  121. data/spec/session_spec.rb +1 -1
  122. data/spec/shared_selenium_node.rb +11 -3
  123. data/spec/shared_selenium_session.rb +8 -7
  124. metadata +9 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2fb2005b8e78a2ee5cd0cf72bdfe2143988cce46abf19422f00bc78ac6336fa
4
- data.tar.gz: 17f7b3eba5799d74ba90bddd6bacec90f1318e3c731097a4cb362f211272652b
3
+ metadata.gz: 0f60918220b590a4a64f3bb1a42b7e8c5dac86dddcec48d46c0f92c1ac6c491f
4
+ data.tar.gz: aab5f09c11d94dc1becdb514d753011cdfad7f2a43f0e59b074ff6e69aa49847
5
5
  SHA512:
6
- metadata.gz: 28e92147279b5b2ee953853fd93071e143719ec099fb68187ea4fa666fbe3593606876968861c9104967e7b7bbd2033b2105ce9720bb00b4de94cd98c8473553
7
- data.tar.gz: 25aee95fc26cc88c27e5229f73665a1cf6b2a8658ece2b8503809a520a45afe5622b28825206cff599ad7a2e749dbc168941dcc298995bc43fd61545b6a306a1
6
+ metadata.gz: 7adcf8fbe5fe95d42c3c7fe513f62236cf93dd0f95bbccb20d31c1022a5e87bd64514d2fd6f57a263d31b96945a2e1c7a300d6b16db018651b929abd137e8290
7
+ data.tar.gz: d28874576cd8613f16b1d455785e4e6fba9cb387b8580ba0bdc0c46f13255661f07e47a51f5d7f2c28afa6691a4c330e094ff9625a89bb4f6f5d9532a3123063
data/History.md CHANGED
@@ -1,3 +1,85 @@
1
+ # Version 3.32.0
2
+ Relesae date: 2020-03-29
3
+
4
+ ### Added
5
+
6
+ * Support `delay` setting on click with Selenium
7
+ * Implement rapid set for values longer thn 30 characters in text fields with Selenium
8
+
9
+ ### Fixed
10
+
11
+ * Result#[] and negative max on ranges (Issue #2302/2303) [Jeremy Evans]
12
+ * RackTest form submission rewrites query string when using GET method
13
+ * Ruby 2.7 deprecation warnings in RSpec matcher proxies
14
+
15
+ # Version 3.31.0
16
+ Release date: 2020-01-26
17
+
18
+ ### Added
19
+
20
+ * Support setting range inputs with the selenium driver [Andrew White]
21
+ * Support setting range inputs with the rack driver
22
+ * Support drop modifier keys in drag & drop [Elliot Crosby-McCullough]
23
+ * `enabled_options` and `disabled options` filters for select selector
24
+ * Support beginless ranges
25
+ * Optionally allow `all` results to be reloaded when stable - Beta feature - may be removed in
26
+ future version if problems occur
27
+
28
+ ### Fixed
29
+
30
+ * Fix Ruby 2.7 deprecation notices around keyword arguments. I have tried to do this without
31
+ any breaking changes, but due to the nature of the 2.7 changes and some selector types accepting
32
+ Hashes as locators there are a lot of edge cases. If you find any broken cases please report
33
+ them and I'll see if they're fixable.
34
+ * Clicking on details/summary element behavior in rack_test driver_
35
+
36
+ # Version 3.30.0
37
+ Release date: 2019-12-24
38
+
39
+ ### Added
40
+
41
+ * Display pending requests when they don't complete in time [Juan Carlos Medina]
42
+ * :order option in selector queries - set to :reverse to for reverse document order results
43
+ * Support regexp for :name and :placeholder options in selectors that import filters from
44
+ _field filter set
45
+
46
+ ### Fixed
47
+
48
+ * Issue around automatic port assignment - Issue #2245
49
+ * Label selector when label has no id - Issue #2260
50
+ * Preserve clientX/clientY in Selenium HTML5 drag emulation [Nicolò G.]
51
+ * table selector using :with_cols option if last specified column matched but others didn't - Issue #2287
52
+ * Some tests updated for Ruby 2.7 behavior change around keyword args
53
+
54
+ # Version 3.29.0
55
+ Release date: 2019-09-02
56
+
57
+ ### Added
58
+
59
+ * Allow clicking on file input when using the block version of `attach_file` with Chrome and Firefox
60
+ * Spatial filters (`left_of`, `right_of`, `above`, `below`, `near`)
61
+ * rack_test driver now supports clicking on details elements to open/close them
62
+
63
+ ### Fixed
64
+
65
+ * rack_test driver correctly determines visibility for open details elements descendants
66
+
67
+ ### Changed
68
+
69
+ * Results will now be lazily evaluated when using JRuby >= 9.2.8.0
70
+
71
+
72
+ # Version 3.28.0
73
+ Release date: 2019-08-03
74
+
75
+ ### Added
76
+
77
+ * Allow forcing HTML5 or legacy dragging via the `:html5` option to `drag_to` when using Selenium with Chrome or Firefox
78
+ * Autodetection of drag type interprets not seeing the mousedown event as legacy.
79
+ * HTML5 form validation `:valid` node filter added to `:field` and `:fillable_field` selectors
80
+ * When using Capybara registered :puma server - patches Puma 4.0.x to fix SSL connection behavior. Removes
81
+ default `queue_requests` setting - Issue #2227
82
+
1
83
  # Version 3.27.0
2
84
  Release date: 2019-07-28
3
85
 
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
9
9
 
10
- **Note** You are viewing the README for the 3.27.x version of Capybara
10
+ **Note** You are viewing the README for the 3.32.x version of Capybara.
11
11
 
12
12
  Capybara helps you test web applications by simulating how a real user would
13
13
  interact with your app. It is agnostic about the driver running your tests and
@@ -391,7 +391,7 @@ Capybara supports [Selenium 3.5+
391
391
  In order to use Selenium, you'll need to install the `selenium-webdriver` gem,
392
392
  and add it to your Gemfile if you're using bundler.
393
393
 
394
- Capybara pre-registers a number of named drives that use Selenium - they are:
394
+ Capybara pre-registers a number of named drivers that use Selenium - they are:
395
395
 
396
396
  * :selenium => Selenium driving Firefox
397
397
  * :selenium_headless => Selenium driving Firefox in a headless configuration
@@ -27,7 +27,9 @@ module Capybara
27
27
  attr_writer :reuse_server
28
28
 
29
29
  def threadsafe=(bool)
30
- raise 'Threadsafe setting cannot be changed once a session is created' if (bool != threadsafe) && Session.instance_created?
30
+ if (bool != threadsafe) && Session.instance_created?
31
+ raise 'Threadsafe setting cannot be changed once a session is created'
32
+ end
31
33
 
32
34
  @threadsafe = bool
33
35
  end
@@ -59,7 +61,7 @@ module Capybara
59
61
  @server = if name.respond_to? :call
60
62
  name
61
63
  elsif options
62
- proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, options) }
64
+ proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, **options) }
63
65
  else
64
66
  Capybara.servers[name.to_sym]
65
67
  end
@@ -83,7 +85,9 @@ module Capybara
83
85
 
84
86
  def deprecate(method, alternate_method, once = false)
85
87
  @deprecation_notified ||= {}
86
- warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead" unless once && @deprecation_notified[method]
88
+ unless once && @deprecation_notified[method]
89
+ warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
90
+ end
87
91
  @deprecation_notified[method] = true
88
92
  end
89
93
  end
@@ -113,6 +113,10 @@ module Capybara
113
113
  !!self[:multiple]
114
114
  end
115
115
 
116
+ def rect
117
+ raise NotSupportedByDriverError, 'Capybara::Driver::Node#rect'
118
+ end
119
+
116
120
  def path
117
121
  raise NotSupportedByDriverError, 'Capybara::Driver::Node#path'
118
122
  end
@@ -47,8 +47,16 @@ module Capybara
47
47
  end
48
48
 
49
49
  Session::DSL_METHODS.each do |method|
50
- define_method method do |*args, &block|
51
- page.send method, *args, &block
50
+ if RUBY_VERSION >= '2.7'
51
+ class_eval <<~METHOD, __FILE__, __LINE__ + 1
52
+ def #{method}(...)
53
+ page.method("#{method}").call(...)
54
+ end
55
+ METHOD
56
+ else
57
+ define_method method do |*args, &block|
58
+ page.send method, *args, &block
59
+ end
52
60
  end
53
61
  end
54
62
  end
@@ -87,7 +87,9 @@ module Capybara
87
87
  end
88
88
 
89
89
  def expired?
90
- raise Capybara::FrozenInTime, 'Time appears to be frozen. Capybara does not work with libraries which freeze time, consider using time travelling instead' if stalled?
90
+ if stalled?
91
+ raise Capybara::FrozenInTime, 'Time appears to be frozen. Capybara does not work with libraries which freeze time, consider using time travelling instead'
92
+ end
91
93
 
92
94
  current - @start >= @expire_in
93
95
  end
@@ -6,41 +6,47 @@ require 'capybara/dsl'
6
6
  module Capybara
7
7
  module Minitest
8
8
  module Assertions
9
- ## Assert text exists
9
+ ##
10
+ # Assert text exists
10
11
  #
12
+ # @!method assert_content
11
13
  # @!method assert_text
12
- # @see Capybara::Node::Matchers#assert_text
14
+ # See {Capybara::Node::Matchers#assert_text}
13
15
 
14
- ## Assert text does not exist
16
+ ##
17
+ # Assert text does not exist
15
18
  #
19
+ # @!method refute_content
20
+ # @!method assert_no_content
21
+ # @!method refute_text
16
22
  # @!method assert_no_text
17
- # @see Capybara::Node::Matchers#assert_no_text
23
+ # See {Capybara::Node::Matchers#assert_no_text}
18
24
 
19
25
  ##
20
26
  # Assertion that page title does match
21
27
  #
22
28
  # @!method assert_title
23
- # @see Capybara::Node::DocumentMatchers#assert_title
29
+ # See {Capybara::Node::DocumentMatchers#assert_title}
24
30
 
25
31
  ##
26
32
  # Assertion that page title does not match
27
33
  #
28
34
  # @!method refute_title
29
35
  # @!method assert_no_title
30
- # @see Capybara::Node::DocumentMatchers#assert_no_title
36
+ # See {Capybara::Node::DocumentMatchers#assert_no_title}
31
37
 
32
38
  ##
33
39
  # Assertion that current path matches
34
40
  #
35
41
  # @!method assert_current_path
36
- # @see Capybara::SessionMatchers#assert_current_path
42
+ # See {Capybara::SessionMatchers#assert_current_path}
37
43
 
38
44
  ##
39
45
  # Assertion that current page does not match
40
46
  #
41
47
  # @!method refute_current_path
42
48
  # @!method assert_no_current_path
43
- # @see Capybara::SessionMatchers#assert_no_current_path
49
+ # See {Capybara::SessionMatchers#assert_no_current_path}
44
50
 
45
51
  %w[text no_text title no_title current_path no_current_path].each do |assertion_name|
46
52
  class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
@@ -52,6 +58,7 @@ module Capybara
52
58
  raise ::Minitest::Assertion, e.message
53
59
  end
54
60
  ASSERTION
61
+ ruby2_keywords "assert_#{assertion_name}" if respond_to?(:ruby2_keywords)
55
62
  end
56
63
 
57
64
  alias_method :refute_title, :assert_no_title
@@ -61,40 +68,81 @@ module Capybara
61
68
  alias_method :assert_content, :assert_text
62
69
  alias_method :assert_no_content, :refute_text
63
70
 
64
- ## Assert selector exists on page
71
+ ##
72
+ # Assert selector exists on page
65
73
  #
66
74
  # @!method assert_selector
67
- # @see Capybara::Node::Matchers#assert_selector
75
+ # See {Capybara::Node::Matchers#assert_selector}
68
76
 
69
- ## Assert selector does not exist on page
77
+ ##
78
+ # Assert selector does not exist on page
70
79
  #
80
+ # @!method refute_selector
71
81
  # @!method assert_no_selector
72
- # @see Capybara::Node::Matchers#assert_no_selector
82
+ # See {Capybara::Node::Matchers#assert_no_selector}
73
83
 
74
- ## Assert element matches selector
84
+ ##
85
+ # Assert element matches selector
75
86
  #
76
87
  # @!method assert_matches_selector
77
- # @see Capybara::Node::Matchers#assert_matches_selector
88
+ # See {Capybara::Node::Matchers#assert_matches_selector}
89
+
90
+ ##
91
+ # Assert element does not match selector
92
+ #
93
+ # @!method refute_matches_selector
94
+ # @!method assert_not_matches_selector
95
+ # See {Capybara::Node::Matchers#assert_not_matches_selector}
78
96
 
79
- ## Assert element does not match selector
97
+ ##
98
+ # Assert all of the provided selectors exist on page
80
99
  #
81
- # @!method assert_xpath
82
- # @see Capybara::Node::Matchers#assert_not_matches_selector
100
+ # @!method assert_all_of_selectors
101
+ # See {Capybara::Node::Matchers#assert_all_of_selectors}
102
+
103
+ ##
104
+ # Assert none of the provided selectors exist on page
105
+ #
106
+ # @!method assert_none_of_selectors
107
+ # See {Capybara::Node::Matchers#assert_none_of_selectors}
108
+
109
+ ##
110
+ # Assert any of the provided selectors exist on page
111
+ #
112
+ # @!method assert_any_of_selectors
113
+ # See {Capybara::Node::Matchers#assert_any_of_selectors}
83
114
 
84
- ## Assert element has the provided CSS styles
115
+ ##
116
+ # Assert element has the provided CSS styles
85
117
  #
86
118
  # @!method assert_matches_style
87
- # @see Capybara::Node::Matchers#assert_matches_style
119
+ # See {Capybara::Node::Matchers#assert_matches_style}
88
120
 
89
- ## Assert element has a matching sibling
121
+ ##
122
+ # Assert element has a matching sibling
90
123
  #
91
124
  # @!method assert_sibling
92
- # @see Capybara::Node::Matchers#assert_sibling
125
+ # See {Capybara::Node::Matchers#assert_sibling}
93
126
 
94
- ## Assert element has a matching ancestor
127
+ ##
128
+ # Assert element does not have a matching sibling
129
+ #
130
+ # @!method refute_sibling
131
+ # @!method assert_no_sibling
132
+ # See {Capybara::Node::Matchers#assert_no_sibling}
133
+
134
+ ##
135
+ # Assert element has a matching ancestor
95
136
  #
96
137
  # @!method assert_ancestor
97
- # @see Capybara::Node::Matchers#assert_ancestor
138
+ # See {Capybara::Node::Matchers#assert_ancestor}
139
+
140
+ ##
141
+ # Assert element does not have a matching ancestor
142
+ #
143
+ # @!method refute_ancestor
144
+ # @!method assert_no_ancestor
145
+ # See {Capybara::Node::Matchers#assert_no_ancestor}
98
146
 
99
147
  %w[selector no_selector matches_style
100
148
  all_of_selectors none_of_selectors any_of_selectors
@@ -109,6 +157,7 @@ module Capybara
109
157
  raise ::Minitest::Assertion, e.message
110
158
  end
111
159
  ASSERTION
160
+ ruby2_keywords "assert_#{assertion_name}" if respond_to?(:ruby2_keywords)
112
161
  end
113
162
 
114
163
  alias_method :refute_selector, :assert_no_selector
@@ -116,18 +165,137 @@ module Capybara
116
165
  alias_method :refute_ancestor, :assert_no_ancestor
117
166
  alias_method :refute_sibling, :assert_no_sibling
118
167
 
168
+ ##
169
+ # Assert that provided xpath exists
170
+ #
171
+ # @!method assert_xpath
172
+ # See {Capybara::Node::Matchers#has_xpath?}
173
+
174
+ ##
175
+ # Assert that provide xpath does not exist
176
+ #
177
+ # @!method refute_xpath
178
+ # @!method assert_no_xpath
179
+ # See {Capybara::Node::Matchers#has_no_xpath?}
180
+
181
+ ##
182
+ # Assert that provided css exists
183
+ #
184
+ # @!method assert_css
185
+ # See {Capybara::Node::Matchers#has_css?}
186
+
187
+ ##
188
+ # Assert that provided css does not exist
189
+ #
190
+ # @!method refute_css
191
+ # @!method assert_no_css
192
+ # See {Capybara::Node::Matchers#has_no_css?}
193
+
194
+ ##
195
+ # Assert that provided link exists
196
+ #
197
+ # @!method assert_link
198
+ # See {Capybara::Node::Matchers#has_link?}
199
+
200
+ ##
201
+ # Assert that provided link does not exist
202
+ #
203
+ # @!method assert_no_link
204
+ # @!method refute_link
205
+ # See {Capybara::Node::Matchers#has_no_link?}
206
+
207
+ ##
208
+ # Assert that provided button exists
209
+ #
210
+ # @!method assert_button
211
+ # See {Capybara::Node::Matchers#has_button?}
212
+
213
+ ##
214
+ # Assert that provided button does not exist
215
+ #
216
+ # @!method refute_button
217
+ # @!method assert_no_button
218
+ # See {Capybara::Node::Matchers#has_no_button?}
219
+
220
+ ##
221
+ # Assert that provided field exists
222
+ #
223
+ # @!method assert_field
224
+ # See {Capybara::Node::Matchers#has_field?}
225
+
226
+ ##
227
+ # Assert that provided field does not exist
228
+ #
229
+ # @!method refute_field
230
+ # @!method assert_no_field
231
+ # See {Capybara::Node::Matchers#has_no_field?}
232
+
233
+ ##
234
+ # Assert that provided checked field exists
235
+ #
236
+ # @!method assert_checked_field
237
+ # See {Capybara::Node::Matchers#has_checked_field?}
238
+
239
+ ##
240
+ # Assert that provided checked_field does not exist
241
+ #
242
+ # @!method assert_no_checked_field
243
+ # @!method refute_checked_field
244
+ # See {Capybara::Node::Matchers#has_no_checked_field?}
245
+
246
+ ##
247
+ # Assert that provided unchecked field exists
248
+ #
249
+ # @!method assert_unchecked_field
250
+ # See {Capybara::Node::Matchers#has_unchecked_field?}
251
+
252
+ ##
253
+ # Assert that provided unchecked field does not exist
254
+ #
255
+ # @!method assert_no_unchecked_field
256
+ # @!method refute_unchecked_field
257
+ # See {Capybara::Node::Matchers#has_no_unchecked_field?}
258
+
259
+ ##
260
+ # Assert that provided select exists
261
+ #
262
+ # @!method assert_select
263
+ # See {Capybara::Node::Matchers#has_select?}
264
+
265
+ ##
266
+ # Assert that provided select does not exist
267
+ #
268
+ # @!method refute_select
269
+ # @!method assert_no_select
270
+ # See {Capybara::Node::Matchers#has_no_select?}
271
+
272
+ ##
273
+ # Assert that provided table exists
274
+ #
275
+ # @!method assert_table
276
+ # See {Capybara::Node::Matchers#has_table?}
277
+
278
+ ##
279
+ # Assert that provided table does not exist
280
+ #
281
+ # @!method refute_table
282
+ # @!method assert_no_table
283
+ # See {Capybara::Node::Matchers#has_no_table?}
284
+
119
285
  %w[xpath css link button field select table].each do |selector_type|
120
286
  define_method "assert_#{selector_type}" do |*args, &optional_filter_block|
121
287
  subject, args = determine_subject(args)
122
288
  locator, options = extract_locator(args)
123
- assert_selector(subject, selector_type.to_sym, locator, options, &optional_filter_block)
289
+ assert_selector(subject, selector_type.to_sym, locator, **options, &optional_filter_block)
124
290
  end
291
+ ruby2_keywords "assert_#{selector_type}" if respond_to?(:ruby2_keywords)
125
292
 
126
293
  define_method "assert_no_#{selector_type}" do |*args, &optional_filter_block|
127
294
  subject, args = determine_subject(args)
128
295
  locator, options = extract_locator(args)
129
- assert_no_selector(subject, selector_type.to_sym, locator, options, &optional_filter_block)
296
+ assert_no_selector(subject, selector_type.to_sym, locator, **options, &optional_filter_block)
130
297
  end
298
+ ruby2_keywords "assert_no_#{selector_type}" if respond_to?(:ruby2_keywords)
131
299
  alias_method "refute_#{selector_type}", "assert_no_#{selector_type}"
132
300
  end
133
301
 
@@ -135,145 +303,66 @@ module Capybara
135
303
  define_method "assert_#{field_type}_field" do |*args, &optional_filter_block|
136
304
  subject, args = determine_subject(args)
137
305
  locator, options = extract_locator(args)
138
- assert_selector(subject, :field, locator, options.merge(field_type.to_sym => true), &optional_filter_block)
306
+ assert_selector(subject, :field, locator, **options.merge(field_type.to_sym => true), &optional_filter_block)
139
307
  end
308
+ ruby2_keywords "assert_#{field_type}_field" if respond_to?(:ruby2_keywords)
140
309
 
141
310
  define_method "assert_no_#{field_type}_field" do |*args, &optional_filter_block|
142
311
  subject, args = determine_subject(args)
143
312
  locator, options = extract_locator(args)
144
- assert_no_selector(subject, :field, locator, options.merge(field_type.to_sym => true), &optional_filter_block)
313
+ assert_no_selector(
314
+ subject,
315
+ :field,
316
+ locator,
317
+ **options.merge(field_type.to_sym => true),
318
+ &optional_filter_block
319
+ )
145
320
  end
321
+ ruby2_keywords "assert_no_#{field_type}_field" if respond_to?(:ruby2_keywords)
146
322
  alias_method "refute_#{field_type}_field", "assert_no_#{field_type}_field"
147
323
  end
148
324
 
325
+ ##
326
+ # Assert that element matches xpath
327
+ #
328
+ # @!method assert_matches_xpath
329
+ # See {Capybara::Node::Matchers#matches_xpath?}
330
+
331
+ ##
332
+ # Assert that element does not match xpath
333
+ #
334
+ # @!method refute_matches_xpath
335
+ # @!method assert_not_matches_xpath
336
+ # See {Capybara::Node::Matchers#not_matches_xpath?}
337
+
338
+ ##
339
+ # Assert that element matches css
340
+ #
341
+ # @!method assert_matches_css
342
+ # See {Capybara::Node::Matchers#matches_css?}
343
+
344
+ ##
345
+ # Assert that element matches css
346
+ #
347
+ # @!method refute_matches_css
348
+ # @!method assert_not_matches_css
349
+ # See {Capybara::Node::Matchers#not_matches_css?}
350
+
149
351
  %w[xpath css].each do |selector_type|
150
352
  define_method "assert_matches_#{selector_type}" do |*args, &optional_filter_block|
151
353
  subject, args = determine_subject(args)
152
354
  assert_matches_selector(subject, selector_type.to_sym, *args, &optional_filter_block)
153
355
  end
356
+ ruby2_keywords "assert_matches_#{selector_type}" if respond_to?(:ruby2_keywords)
154
357
 
155
358
  define_method "assert_not_matches_#{selector_type}" do |*args, &optional_filter_block|
156
359
  subject, args = determine_subject(args)
157
360
  assert_not_matches_selector(subject, selector_type.to_sym, *args, &optional_filter_block)
158
361
  end
362
+ ruby2_keywords "assert_not_matches_#{selector_type}" if respond_to?(:ruby2_keywords)
159
363
  alias_method "refute_matches_#{selector_type}", "assert_not_matches_#{selector_type}"
160
364
  end
161
365
 
162
- ##
163
- # Assertion that there is xpath
164
- #
165
- # @!method assert_xpath
166
- # @see Capybara::Node::Matchers#has_xpath?
167
-
168
- ##
169
- # Assertion that there is no xpath
170
- #
171
- # @!method refute_xpath
172
- # @!method assert_no_xpath
173
- # @see Capybara::Node::Matchers#has_no_xpath?
174
-
175
- ##
176
- # Assertion that there is css
177
- #
178
- # @!method assert_css
179
- # @see Capybara::Node::Matchers#has_css?
180
-
181
- ##
182
- # Assertion that there is no css
183
- #
184
- # @!method refute_css
185
- # @!method assert_no_css
186
- # @see Capybara::Node::Matchers#has_no_css?
187
-
188
- ##
189
- # Assertion that there is link
190
- #
191
- # @!method assert_link
192
- # @see Capybara::Node::Matchers#has_link?
193
-
194
- ##
195
- # Assertion that there is no link
196
- #
197
- # @!method assert_no_link
198
- # @!method refute_link
199
- # @see Capybara::Node::Matchers#has_no_link?
200
-
201
- ##
202
- # Assertion that there is button
203
- #
204
- # @!method assert_button
205
- # @see Capybara::Node::Matchers#has_button?
206
-
207
- ##
208
- # Assertion that there is no button
209
- #
210
- # @!method refute_button
211
- # @!method assert_no_button
212
- # @see Capybara::Node::Matchers#has_no_button?
213
-
214
- ##
215
- # Assertion that there is field
216
- #
217
- # @!method assert_field
218
- # @see Capybara::Node::Matchers#has_field?
219
-
220
- ##
221
- # Assertion that there is no field
222
- #
223
- # @!method refute_field
224
- # @!method assert_no_field
225
- # @see Capybara::Node::Matchers#has_no_field?
226
-
227
- ##
228
- # Assertion that there is checked_field
229
- #
230
- # @!method assert_checked_field
231
- # @see Capybara::Node::Matchers#has_checked_field?
232
-
233
- ##
234
- # Assertion that there is no checked_field
235
- #
236
- # @!method assert_no_checked_field
237
- # @!method refute_checked_field
238
-
239
- ##
240
- # Assertion that there is unchecked_field
241
- #
242
- # @!method assert_unchecked_field
243
- # @see Capybara::Node::Matchers#has_unchecked_field?
244
-
245
- ##
246
- # Assertion that there is no unchecked_field
247
- #
248
- # @!method assert_no_unchecked_field
249
- # @!method refute_unchecked_field
250
-
251
- ##
252
- # Assertion that there is select
253
- #
254
- # @!method assert_select
255
- # @see Capybara::Node::Matchers#has_select?
256
-
257
- ##
258
- # Assertion that there is no select
259
- #
260
- # @!method refute_select
261
- # @!method assert_no_select
262
- # @see Capybara::Node::Matchers#has_no_select?
263
-
264
- ##
265
- # Assertion that there is table
266
- #
267
- # @!method assert_table
268
- # @see Capybara::Node::Matchers#has_table?
269
-
270
- ##
271
- # Assertion that there is no table
272
- #
273
- # @!method refute_table
274
- # @!method assert_no_table
275
- # @see Capybara::Node::Matchers#has_no_table?
276
-
277
366
  private
278
367
 
279
368
  def determine_subject(args)