capybara 2.18.0 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -1
  3. data/README.md +12 -12
  4. data/lib/capybara.rb +13 -25
  5. data/lib/capybara/config.rb +11 -57
  6. data/lib/capybara/cucumber.rb +2 -3
  7. data/lib/capybara/driver/base.rb +5 -16
  8. data/lib/capybara/driver/node.rb +5 -4
  9. data/lib/capybara/dsl.rb +1 -0
  10. data/lib/capybara/helpers.rb +16 -28
  11. data/lib/capybara/minitest.rb +139 -138
  12. data/lib/capybara/minitest/spec.rb +15 -14
  13. data/lib/capybara/node/actions.rb +59 -81
  14. data/lib/capybara/node/base.rb +11 -18
  15. data/lib/capybara/node/document.rb +2 -2
  16. data/lib/capybara/node/document_matchers.rb +8 -8
  17. data/lib/capybara/node/element.rb +30 -40
  18. data/lib/capybara/node/finders.rb +62 -70
  19. data/lib/capybara/node/matchers.rb +48 -71
  20. data/lib/capybara/node/simple.rb +11 -17
  21. data/lib/capybara/queries/ancestor_query.rb +4 -6
  22. data/lib/capybara/queries/base_query.rb +18 -17
  23. data/lib/capybara/queries/current_path_query.rb +8 -24
  24. data/lib/capybara/queries/match_query.rb +3 -7
  25. data/lib/capybara/queries/selector_query.rb +92 -95
  26. data/lib/capybara/queries/sibling_query.rb +4 -4
  27. data/lib/capybara/queries/text_query.rb +37 -34
  28. data/lib/capybara/queries/title_query.rb +8 -11
  29. data/lib/capybara/rack_test/browser.rb +15 -18
  30. data/lib/capybara/rack_test/css_handlers.rb +6 -4
  31. data/lib/capybara/rack_test/driver.rb +6 -10
  32. data/lib/capybara/rack_test/form.rb +50 -40
  33. data/lib/capybara/rack_test/node.rb +70 -56
  34. data/lib/capybara/rails.rb +2 -6
  35. data/lib/capybara/result.rb +22 -22
  36. data/lib/capybara/rspec.rb +5 -10
  37. data/lib/capybara/rspec/compound.rb +5 -10
  38. data/lib/capybara/rspec/features.rb +17 -48
  39. data/lib/capybara/rspec/matcher_proxies.rb +31 -15
  40. data/lib/capybara/rspec/matchers.rb +70 -60
  41. data/lib/capybara/selector.rb +129 -117
  42. data/lib/capybara/selector/css.rb +6 -11
  43. data/lib/capybara/selector/filter.rb +1 -17
  44. data/lib/capybara/selector/filter_set.rb +17 -14
  45. data/lib/capybara/selector/filters/base.rb +7 -6
  46. data/lib/capybara/selector/filters/expression_filter.rb +6 -23
  47. data/lib/capybara/selector/filters/node_filter.rb +2 -12
  48. data/lib/capybara/selector/selector.rb +27 -33
  49. data/lib/capybara/selenium/driver.rb +113 -127
  50. data/lib/capybara/selenium/node.rb +148 -113
  51. data/lib/capybara/server.rb +3 -2
  52. data/lib/capybara/session.rb +137 -223
  53. data/lib/capybara/session/config.rb +47 -67
  54. data/lib/capybara/session/matchers.rb +8 -7
  55. data/lib/capybara/spec/public/test.js +26 -4
  56. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
  57. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
  58. data/lib/capybara/spec/session/accept_prompt_spec.rb +1 -0
  59. data/lib/capybara/spec/session/all_spec.rb +31 -18
  60. data/lib/capybara/spec/session/ancestor_spec.rb +2 -4
  61. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
  62. data/lib/capybara/spec/session/assert_current_path.rb +12 -11
  63. data/lib/capybara/spec/session/assert_selector.rb +1 -0
  64. data/lib/capybara/spec/session/assert_text.rb +18 -17
  65. data/lib/capybara/spec/session/assert_title.rb +1 -0
  66. data/lib/capybara/spec/session/attach_file_spec.rb +14 -13
  67. data/lib/capybara/spec/session/body_spec.rb +1 -0
  68. data/lib/capybara/spec/session/check_spec.rb +7 -6
  69. data/lib/capybara/spec/session/choose_spec.rb +5 -4
  70. data/lib/capybara/spec/session/click_button_spec.rb +20 -28
  71. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
  72. data/lib/capybara/spec/session/click_link_spec.rb +8 -7
  73. data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
  74. data/lib/capybara/spec/session/current_url_spec.rb +7 -6
  75. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
  76. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
  77. data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
  78. data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
  79. data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
  80. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +3 -2
  81. data/lib/capybara/spec/session/evaluate_script_spec.rb +4 -3
  82. data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
  83. data/lib/capybara/spec/session/fill_in_spec.rb +6 -5
  84. data/lib/capybara/spec/session/find_button_spec.rb +4 -3
  85. data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
  86. data/lib/capybara/spec/session/find_field_spec.rb +8 -14
  87. data/lib/capybara/spec/session/find_link_spec.rb +6 -5
  88. data/lib/capybara/spec/session/find_spec.rb +37 -31
  89. data/lib/capybara/spec/session/first_spec.rb +60 -33
  90. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
  91. data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
  92. data/lib/capybara/spec/session/go_back_spec.rb +1 -0
  93. data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
  94. data/lib/capybara/spec/session/has_all_selectors_spec.rb +15 -15
  95. data/lib/capybara/spec/session/has_button_spec.rb +2 -1
  96. data/lib/capybara/spec/session/has_css_spec.rb +3 -2
  97. data/lib/capybara/spec/session/has_current_path_spec.rb +12 -28
  98. data/lib/capybara/spec/session/has_field_spec.rb +4 -3
  99. data/lib/capybara/spec/session/has_link_spec.rb +1 -0
  100. data/lib/capybara/spec/session/has_none_selectors_spec.rb +17 -17
  101. data/lib/capybara/spec/session/has_select_spec.rb +30 -29
  102. data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
  103. data/lib/capybara/spec/session/has_table_spec.rb +2 -1
  104. data/lib/capybara/spec/session/has_text_spec.rb +6 -5
  105. data/lib/capybara/spec/session/has_title_spec.rb +1 -0
  106. data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
  107. data/lib/capybara/spec/session/headers.rb +2 -1
  108. data/lib/capybara/spec/session/html_spec.rb +1 -0
  109. data/lib/capybara/spec/session/node_spec.rb +91 -56
  110. data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
  111. data/lib/capybara/spec/session/refresh_spec.rb +4 -2
  112. data/lib/capybara/spec/session/reset_session_spec.rb +1 -0
  113. data/lib/capybara/spec/session/response_code.rb +1 -0
  114. data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
  115. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -11
  116. data/lib/capybara/spec/session/save_page_spec.rb +1 -17
  117. data/lib/capybara/spec/session/save_screenshot_spec.rb +1 -1
  118. data/lib/capybara/spec/session/select_spec.rb +20 -20
  119. data/lib/capybara/spec/session/selectors_spec.rb +2 -2
  120. data/lib/capybara/spec/session/sibling_spec.rb +1 -1
  121. data/lib/capybara/spec/session/text_spec.rb +1 -0
  122. data/lib/capybara/spec/session/title_spec.rb +1 -1
  123. data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
  124. data/lib/capybara/spec/session/unselect_spec.rb +6 -5
  125. data/lib/capybara/spec/session/visit_spec.rb +9 -3
  126. data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
  127. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
  128. data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
  129. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +2 -1
  130. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
  131. data/lib/capybara/spec/session/window/window_spec.rb +12 -12
  132. data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
  133. data/lib/capybara/spec/session/window/within_window_spec.rb +13 -68
  134. data/lib/capybara/spec/session/within_spec.rb +1 -0
  135. data/lib/capybara/spec/spec_helper.rb +26 -18
  136. data/lib/capybara/spec/test_app.rb +8 -9
  137. data/lib/capybara/spec/views/form.erb +1 -0
  138. data/lib/capybara/spec/views/with_html.erb +3 -1
  139. data/lib/capybara/spec/views/within_frames.erb +4 -1
  140. data/lib/capybara/version.rb +2 -1
  141. data/lib/capybara/window.rb +6 -10
  142. data/spec/basic_node_spec.rb +1 -0
  143. data/spec/capybara_spec.rb +9 -32
  144. data/spec/dsl_spec.rb +5 -13
  145. data/spec/filter_set_spec.rb +5 -4
  146. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
  147. data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
  148. data/spec/minitest_spec.rb +4 -3
  149. data/spec/minitest_spec_spec.rb +3 -2
  150. data/spec/per_session_config_spec.rb +9 -8
  151. data/spec/rack_test_spec.rb +21 -20
  152. data/spec/result_spec.rb +17 -16
  153. data/spec/rspec/features_spec.rb +17 -14
  154. data/spec/rspec/scenarios_spec.rb +5 -7
  155. data/spec/rspec/shared_spec_matchers.rb +96 -99
  156. data/spec/rspec/views_spec.rb +2 -1
  157. data/spec/rspec_matchers_spec.rb +19 -2
  158. data/spec/rspec_spec.rb +11 -15
  159. data/spec/selector_spec.rb +5 -6
  160. data/spec/selenium_spec_chrome.rb +7 -4
  161. data/spec/selenium_spec_marionette.rb +26 -12
  162. data/spec/server_spec.rb +33 -33
  163. data/spec/session_spec.rb +2 -1
  164. data/spec/shared_selenium_session.rb +27 -21
  165. data/spec/spec_helper.rb +2 -5
  166. metadata +66 -87
  167. data/lib/capybara/query.rb +0 -7
  168. data/spec/selenium_spec_firefox.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb46b7bc5ae7408ca3870b781d015a84bd84abd0a9c7e3ea2bcdf3d8fff85ce8
4
- data.tar.gz: 1865dc1efa384c3792161a134bc536c56dca3aa0670ca298ad9f3aa12b49830d
3
+ metadata.gz: 21f91a983551012c790ae444974b24f9d0349d79c36706d4a9143523b2827605
4
+ data.tar.gz: 54de192348948696b54e66ff9fc7622311b88fd7d71e842b0737be060bfdc59a
5
5
  SHA512:
6
- metadata.gz: 9bc2cb739af408323d977b7ca829aa0862ef68ab7d1778c5ae67fb127a47a09258c1f5b53f9d7955bcfcd2892c869a136d7a5346b9115a9e55713ea47c95ebb3
7
- data.tar.gz: e8d234ded45305e026b615c60e4eb8597e31fd67b7daefff51d13ab3d79868745e21668a6b45452366ac5a552b38e8c01dc669e73dbe45a9b38ecf8363b54e83
6
+ metadata.gz: 62ab87128fa70c43cfa688d55c9ae208095b632999cbd44969971cfcbefed37b4719e8c8e2c0350e13dd69a2e35ec5799d1f7f105cd717cfa277b091b42041db
7
+ data.tar.gz: 3c013b9add97330680def4a948246360ccf0bbc520e8b8573b0bdee4dfcbde751d7f9626268fe682aa613975d4ad126e776cba7075a50259769e120bec09b61d
data/History.md CHANGED
@@ -1,4 +1,27 @@
1
- #Version 2.18.0
1
+ # Version 3.0.0.rc1
2
+ Release date: 2018-03-02
3
+
4
+ ### Added
5
+ * Support for libraries wrapping Capybara elements and providing a `#to_capybara_node` method
6
+
7
+ ### Changed
8
+
9
+ * `first` now raises ElementNotFound, by default, instead of returning nil, when no matches are found - Issue #1507
10
+ * 'all' now waits for at least one matching element by default. Pass `wait: false` if you want the previous
11
+ behavior where an empty result would be returned immediately if no matching elements exist yet.
12
+ * ArgumentError raised if extra parameters passed to selector queries
13
+
14
+ ### Removed
15
+
16
+ * Ruby < 2.2.2 support
17
+ * `Capybara.exact_options` no longer exists. Just use `exact:true` on relevant actions/finders if necessary.
18
+ * All previously deprecated methods removed
19
+ * RSpec 2.x support
20
+ * selenium-webdriver 2.x support
21
+ * Nokogiri < 1.8 support
22
+ * `field_labeled` alaias for `find_field`
23
+
24
+ # Version 2.18.0
2
25
  Release date: 2018-02-12
3
26
 
4
27
  ### Fixed
@@ -10,6 +33,7 @@ Release date: 2018-02-12
10
33
 
11
34
  * Headless chrome modal JS injection that is no longer needed for Chrome 64+/chromedriver 2.35+
12
35
 
36
+
13
37
  # Version 2.17.0
14
38
  Release date: 2018-01-02
15
39
 
@@ -253,6 +277,7 @@ Release date: 2016-10-05
253
277
  Release date: 2016-09-29
254
278
 
255
279
  ### Fixed
280
+
256
281
  * :label built-in selector finds nested label/control by control id if the label has no 'for' attribute [Thomas Walpole]
257
282
  * Warning issued if an unknown selector type is specified [Thomas Walpole]
258
283
 
data/README.md CHANGED
@@ -5,6 +5,10 @@
5
5
  [![Code Climate](https://codeclimate.com/github/teamcapybara/capybara.svg)](https://codeclimate.com/github/teamcapybara/capybara)
6
6
  [![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)
7
7
 
8
+ **Note** You are viewing the README for the development version of Capybara. If you are using the current release version
9
+ you can find the README at https://github.com/teamcapybara/capybara/blob/2.17_stable/README.md
10
+
11
+
8
12
  Capybara helps you test web applications by simulating how a real user would
9
13
  interact with your app. It is agnostic about the driver running your tests and
10
14
  comes with Rack::Test and Selenium support built in. WebKit is supported
@@ -71,24 +75,19 @@ GitHub): http://groups.google.com/group/ruby-capybara
71
75
 
72
76
  ## <a name="setup"></a>Setup
73
77
 
74
- Capybara requires Ruby 1.9.3 or later. To install, add this line to your
78
+ Capybara requires Ruby 2.2.0 or later. To install, add this line to your
75
79
  `Gemfile` and run `bundle install`:
76
80
 
77
81
  ```ruby
78
82
  gem 'capybara'
79
83
  ```
80
84
 
81
- **Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0
82
-
83
85
  If the application that you are testing is a Rails app, add this line to your test helper file:
84
86
 
85
87
  ```ruby
86
88
  require 'capybara/rails'
87
89
  ```
88
90
 
89
- **Note:** In Rails 4.0/4.1 the default test environment (`config/environments/test.rb`) is [not threadsafe](https://github.com/rails/rails/issues/15089).
90
- If you experience random errors about missing constants, add `config.allow_concurrency = false` to `config/environments/test.rb`.
91
-
92
91
  If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:
93
92
 
94
93
  ```ruby
@@ -140,18 +139,18 @@ There are also explicit tags for each registered driver set up for you (`@seleni
140
139
 
141
140
  ## <a name="using-capybara-with-rspec"></a>Using Capybara with RSpec
142
141
 
143
- Load RSpec 2+ support by adding the following line (typically to your
142
+ Load RSpec 3.x support by adding the following line (typically to your
144
143
  `spec_helper.rb` file):
145
144
 
146
145
  ```ruby
147
146
  require 'capybara/rspec'
148
147
  ```
149
148
 
150
- If you are using Rails, put your Capybara specs in `spec/features` (only works
149
+ If you are using Rails, put your Capybara specs in `spec/features` or `spec/system` (only works
151
150
  if [you have it configured in
152
151
  RSpec](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled))
153
152
  and if you have your Capybara specs in a different directory, then tag the
154
- example groups with `:type => :feature`.
153
+ example groups with `:type => :feature` or `:type => :system` depending on which type of test you're writing.
155
154
 
156
155
  If you are not using Rails, tag all the example groups in which you want to use
157
156
  Capybara with `:type => :feature`.
@@ -223,7 +222,7 @@ end
223
222
  `background` is an alias for `before`, `scenario` for `it`, and
224
223
  `given`/`given!` aliases for `let`/`let!`, respectively.
225
224
 
226
- Finally, Capybara matchers are supported in view specs:
225
+ Finally, Capybara matchers are also supported in view specs:
227
226
 
228
227
  ```ruby
229
228
  RSpec.describe "todos/show.html.erb", type: :view do
@@ -742,7 +741,7 @@ Capybara 1.x, set `Capybara.match` to `:prefer_exact`.
742
741
 
743
742
  ## <a name="transactions-and-database-setup"></a>Transactions and database setup
744
743
 
745
- **Note:** Rails 5.1+ now "safely" shares the database connection between the app and test threads. Therefore,
744
+ **Note:** Rails 5.1+ "safely" shares the database connection between the app and test threads. Therefore,
746
745
  if using Rails 5.1+ you SHOULD be able to ignore this section.
747
746
 
748
747
  Some Capybara drivers need to run against an actual HTTP server. Capybara takes
@@ -1082,7 +1081,8 @@ To set up a development environment, simply do:
1082
1081
 
1083
1082
  ```bash
1084
1083
  bundle install
1085
- bundle exec rake # run the test suite
1084
+ bundle exec rake # run the test suite with Firefox - requires `geckodriver` to be installed
1085
+ bundle exec rake spec_chrome # run the test suite with Chrome - require `chromedriver` to be installed
1086
1086
  ```
1087
1087
 
1088
1088
  See
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'timeout'
3
4
  require 'nokogiri'
4
5
  require 'xpath'
@@ -21,7 +22,6 @@ module Capybara
21
22
  class WindowError < CapybaraError; end
22
23
  class ReadOnlyElementError < CapybaraError; end
23
24
 
24
-
25
25
  class << self
26
26
  extend Forwardable
27
27
 
@@ -51,8 +51,6 @@ module Capybara
51
51
  # See {Capybara.configure}
52
52
  # @!method always_include_port
53
53
  # See {Capybara.configure}
54
- # @!method wait_on_first_by_default
55
- # See {Capybara.configure}
56
54
  SessionConfig::OPTIONS.each do |method|
57
55
  def_delegators :config, method, "#{method}="
58
56
  end
@@ -79,7 +77,6 @@ module Capybara
79
77
  # [ignore_hidden_elements = Boolean] Whether to ignore hidden elements on the page (Default: true)
80
78
  # [automatic_reload = Boolean] Whether to automatically reload elements as Capybara is waiting (Default: true)
81
79
  # [save_path = String] Where to put pages saved through save_(page|screenshot), save_and_open_(page|screenshot) (Default: Dir.pwd)
82
- # [wait_on_first_by_default = Boolean] Whether Node#first defaults to Capybara waiting behavior for at least 1 element to match (Default: false)
83
80
  # [automatic_label_click = Boolean] Whether Node#choose, Node#check, Node#uncheck will attempt to click the associated label element if the checkbox/radio button are non-visible (Default: false)
84
81
  # [enable_aria_label = Boolean] Whether fields, links, and buttons will match against aria-label attribute (Default: false)
85
82
  # [reuse_server = Boolean] Reuse the server thread between multiple sessions using the same app object (Default: true)
@@ -94,7 +91,7 @@ module Capybara
94
91
  # [javascript_driver = Symbol] The name of a driver to use for JavaScript enabled tests. (Default: :selenium)
95
92
  #
96
93
  def configure
97
- yield ConfigureDeprecator.new(config)
94
+ yield config
98
95
  end
99
96
 
100
97
  ##
@@ -128,7 +125,6 @@ module Capybara
128
125
  # @yieldparam [<Rack>] app The rack application that this server will contain.
129
126
  # @yieldparam port The port number the server should listen on
130
127
  # @yieldparam host The host/ip to bind to
131
- # @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
132
128
  #
133
129
  def register_server(name, &block)
134
130
  servers[name.to_sym] = block
@@ -192,8 +188,6 @@ module Capybara
192
188
  @servers ||= {}
193
189
  end
194
190
 
195
- ##
196
- #
197
191
  # Wraps the given string, which should contain an HTML document or fragment
198
192
  # in a {Capybara::Node::Simple} which exposes all {Capybara::Node::Matchers},
199
193
  # {Capybara::Node::Finders} and {Capybara::Node::DocumentMatchers}. This allows you to query
@@ -238,7 +232,7 @@ module Capybara
238
232
  # @param [Integer] port The port to run the application on
239
233
  #
240
234
  def run_default_server(app, port)
241
- servers[:webrick].call(app, port, server_host)
235
+ servers[:puma].call(app, port, server_host)
242
236
  end
243
237
 
244
238
  ##
@@ -310,7 +304,7 @@ module Capybara
310
304
  # as cookies.
311
305
  #
312
306
  def reset_sessions!
313
- #reset in reverse so sessions that started servers are reset last
307
+ # reset in reverse so sessions that started servers are reset last
314
308
  session_pool.reverse_each { |_mode, session| session.reset! }
315
309
  end
316
310
  alias_method :reset!, :reset_sessions!
@@ -364,10 +358,10 @@ module Capybara
364
358
  # @param [String] html The raw html
365
359
  # @return [Nokogiri::HTML::Document] HTML document
366
360
  #
367
- def HTML(html)
361
+ def HTML(html) # rubocop:disable Naming/MethodName
368
362
  Nokogiri::HTML(html).tap do |document|
369
363
  document.xpath('//textarea').each do |textarea|
370
- textarea['_capybara_raw_value'] = textarea.content.sub(/\A\n/,'')
364
+ textarea['_capybara_raw_value'] = textarea.content.sub(/\A\n/, '')
371
365
  end
372
366
  end
373
367
  end
@@ -376,12 +370,8 @@ module Capybara
376
370
  config.session_options
377
371
  end
378
372
 
379
- def included(base)
380
- base.send(:include, Capybara::DSL)
381
- warn "`include Capybara` is deprecated. Please use `include Capybara::DSL` instead."
382
- end
383
-
384
373
  private
374
+
385
375
  def config
386
376
  @config ||= Capybara::Config.new
387
377
  end
@@ -415,7 +405,6 @@ module Capybara
415
405
  require 'capybara/queries/match_query'
416
406
  require 'capybara/queries/ancestor_query'
417
407
  require 'capybara/queries/sibling_query'
418
- require 'capybara/query'
419
408
 
420
409
  require 'capybara/node/finders'
421
410
  require 'capybara/node/matchers'
@@ -443,14 +432,14 @@ Capybara.register_server :default do |app, port, _host|
443
432
  Capybara.run_default_server(app, port)
444
433
  end
445
434
 
446
- Capybara.register_server :webrick do |app, port, host, options={}|
435
+ Capybara.register_server :webrick do |app, port, host, **options|
447
436
  require 'rack/handler/webrick'
448
- Rack::Handler::WEBrick.run(app, {Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0)}.merge(options))
437
+ Rack::Handler::WEBrick.run(app, { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options))
449
438
  end
450
439
 
451
- Capybara.register_server :puma do |app, port, host, options={}|
440
+ Capybara.register_server :puma do |app, port, host, **options|
452
441
  require 'rack/handler/puma'
453
- Rack::Handler::Puma.run(app, {Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false}.merge(options))
442
+ Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
454
443
  end
455
444
 
456
445
  Capybara.configure do |config|
@@ -468,7 +457,6 @@ Capybara.configure do |config|
468
457
  config.raise_server_errors = true
469
458
  config.server_errors = [StandardError]
470
459
  config.visible_text_only = false
471
- config.wait_on_first_by_default = false
472
460
  config.automatic_label_click = false
473
461
  config.enable_aria_label = false
474
462
  config.reuse_server = true
@@ -483,11 +471,11 @@ Capybara.register_driver :selenium do |app|
483
471
  end
484
472
 
485
473
  Capybara.register_driver :selenium_chrome do |app|
486
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
474
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
487
475
  end
488
476
 
489
477
  Capybara.register_driver :selenium_chrome_headless do |app|
490
- browser_options = ::Selenium::WebDriver::Chrome::Options.new()
478
+ browser_options = ::Selenium::WebDriver::Chrome::Options.new
491
479
  browser_options.args << '--headless'
492
480
  browser_options.args << '--disable-gpu'
493
481
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'forwardable'
3
4
  require 'capybara/session/config'
4
5
 
@@ -6,7 +7,7 @@ module Capybara
6
7
  class Config
7
8
  extend Forwardable
8
9
 
9
- OPTIONS = [:app, :reuse_server, :threadsafe, :default_wait_time, :server, :default_driver, :javascript_driver]
10
+ OPTIONS = %i[app reuse_server threadsafe default_wait_time server default_driver javascript_driver].freeze
10
11
 
11
12
  attr_accessor :app
12
13
  attr_reader :reuse_server, :threadsafe
@@ -21,9 +22,7 @@ module Capybara
21
22
  @session_options = Capybara::SessionConfig.new
22
23
  end
23
24
 
24
- def reuse_server=(bool)
25
- @reuse_server = bool
26
- end
25
+ attr_writer :reuse_server
27
26
 
28
27
  def threadsafe=(bool)
29
28
  warn "Capybara.threadsafe == true is a BETA feature and may change in future minor versions" if bool
@@ -35,16 +34,9 @@ module Capybara
35
34
  #
36
35
  # Return the proc that Capybara will call to run the Rack application.
37
36
  # The block returned receives a rack app, port, and host/ip and should run a Rack handler
38
- # By default, Capybara will try to run webrick.
37
+ # By default, Capybara will try to use puma.
39
38
  #
40
- def server(&block)
41
- if block_given?
42
- warn "DEPRECATED: Passing a block to Capybara::server is deprecated, please use Capybara::register_server instead"
43
- @server = block
44
- else
45
- @server
46
- end
47
- end
39
+ attr_reader :server
48
40
 
49
41
  ##
50
42
  #
@@ -62,14 +54,10 @@ module Capybara
62
54
  #
63
55
  def server=(name)
64
56
  name, options = *name if name.is_a? Array
65
- @server = if name.respond_to? :call
66
- name
57
+ @server = if options
58
+ proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, options) }
67
59
  else
68
- if options
69
- Proc.new { |app, port, host| Capybara.servers[name.to_sym].call(app,port,host,options) }
70
- else
71
- Capybara.servers[name.to_sym]
72
- end
60
+ Capybara.servers[name.to_sym]
73
61
  end
74
62
  end
75
63
 
@@ -89,44 +77,10 @@ module Capybara
89
77
  @javascript_driver || :selenium
90
78
  end
91
79
 
92
- # @deprecated Use default_max_wait_time instead
93
- def default_wait_time
94
- deprecate('default_wait_time', 'default_max_wait_time', true)
95
- default_max_wait_time
96
- end
97
-
98
- # @deprecated Use default_max_wait_time= instead
99
- def default_wait_time=(t)
100
- deprecate('default_wait_time=', 'default_max_wait_time=')
101
- self.default_max_wait_time = t
102
- end
103
-
104
- def deprecate(method, alternate_method, once=false)
80
+ def deprecate(method, alternate_method, once = false)
105
81
  @deprecation_notified ||= {}
106
82
  warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead" unless once and @deprecation_notified[method]
107
- @deprecation_notified[method]=true
108
- end
109
- end
110
-
111
- # @api private
112
- class ConfigureDeprecator
113
- def initialize(config)
114
- @config = config
115
- end
116
-
117
- def method_missing(m, *args, &block)
118
- if @config.respond_to?(m)
119
- @config.public_send(m, *args, &block)
120
- elsif Capybara.respond_to?(m)
121
- warn "Calling #{m} from Capybara.configure is deprecated - please call it on Capybara directly ( Capybara.#{m}(...) )"
122
- Capybara.public_send(m, *args, &block)
123
- else
124
- super
125
- end
126
- end
127
-
128
- def respond_to_missing?(m, include_private = false)
129
- @config.respond_to?(m) || Capybara.respond_to?(m) || super
83
+ @deprecation_notified[method] = true
130
84
  end
131
85
  end
132
- end
86
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'capybara/dsl'
3
4
  require 'capybara/rspec/matchers'
4
5
  require 'capybara/rspec/matcher_proxies'
@@ -21,8 +22,6 @@ end
21
22
  Before do |scenario|
22
23
  scenario.source_tag_names.each do |tag|
23
24
  driver_name = tag.sub(/^@/, '').to_sym
24
- if Capybara.drivers.has_key?(driver_name)
25
- Capybara.current_driver = driver_name
26
- end
25
+ Capybara.current_driver = driver_name if Capybara.drivers.key?(driver_name)
27
26
  end
28
27
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Capybara::Driver::Base
3
4
  attr_writer :session
4
5
 
@@ -46,7 +47,7 @@ class Capybara::Driver::Base
46
47
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#evaluate_script_asnyc'
47
48
  end
48
49
 
49
- def save_screenshot(path, options={})
50
+ def save_screenshot(path, **options)
50
51
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#save_screenshot'
51
52
  end
52
53
 
@@ -98,15 +99,10 @@ class Capybara::Driver::Base
98
99
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#switch_to_window'
99
100
  end
100
101
 
101
- def within_window(locator)
102
- raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#within_window'
103
- end
104
-
105
102
  def no_such_window_error
106
103
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#no_such_window_error'
107
104
  end
108
105
 
109
-
110
106
  ##
111
107
  #
112
108
  # Execute the block, and then accept the modal opened.
@@ -117,7 +113,7 @@ class Capybara::Driver::Base
117
113
  # @return [String] the message shown in the modal
118
114
  # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
119
115
  #
120
- def accept_modal(type, options={}, &blk)
116
+ def accept_modal(type, **options, &blk)
121
117
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#accept_modal'
122
118
  end
123
119
 
@@ -130,7 +126,7 @@ class Capybara::Driver::Base
130
126
  # @return [String] the message shown in the modal
131
127
  # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
132
128
  #
133
- def dismiss_modal(type, options={}, &blk)
129
+ def dismiss_modal(type, **options, &blk)
134
130
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#dismiss_modal'
135
131
  end
136
132
 
@@ -142,8 +138,7 @@ class Capybara::Driver::Base
142
138
  false
143
139
  end
144
140
 
145
- def reset!
146
- end
141
+ def reset!; end
147
142
 
148
143
  def needs_server?
149
144
  false
@@ -152,10 +147,4 @@ class Capybara::Driver::Base
152
147
  def session_options
153
148
  (@session && @session.config) || Capybara.session_options
154
149
  end
155
-
156
- # @deprecated This method is being removed
157
- def browser_initialized?
158
- warn "DEPRECATED: #browser_initialized? is deprecated and will be removed in the next version of Capybara"
159
- true
160
- end
161
150
  end