capybara 3.16.2 → 3.17.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.
- checksums.yaml +4 -4
- data/History.md +13 -0
- data/README.md +1 -1
- data/lib/capybara.rb +2 -71
- data/lib/capybara/config.rb +1 -2
- data/lib/capybara/node/actions.rb +5 -5
- data/lib/capybara/node/base.rb +4 -4
- data/lib/capybara/node/element.rb +5 -5
- data/lib/capybara/node/finders.rb +6 -4
- data/lib/capybara/node/simple.rb +3 -2
- data/lib/capybara/queries/selector_query.rb +5 -5
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/servers.rb +38 -0
- data/lib/capybara/result.rb +2 -2
- data/lib/capybara/rspec/matcher_proxies.rb +2 -2
- data/lib/capybara/rspec/matchers/base.rb +2 -2
- data/lib/capybara/selector.rb +55 -32
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/filters/base.rb +1 -1
- data/lib/capybara/selector/selector.rb +1 -0
- data/lib/capybara/selenium/driver.rb +84 -43
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +16 -4
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +23 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +5 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +14 -1
- data/lib/capybara/selenium/extensions/find.rb +48 -37
- data/lib/capybara/selenium/logger_suppressor.rb +29 -0
- data/lib/capybara/selenium/node.rb +22 -8
- data/lib/capybara/selenium/nodes/chrome_node.rb +8 -2
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +3 -3
- data/lib/capybara/session/config.rb +2 -8
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +4 -4
- data/lib/capybara/spec/session/choose_spec.rb +2 -2
- data/lib/capybara/spec/session/click_button_spec.rb +28 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +2 -2
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/node_spec.rb +18 -6
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/result_spec.rb +10 -6
- data/spec/rspec/shared_spec_matchers.rb +8 -4
- data/spec/selector_spec.rb +4 -0
- data/spec/selenium_spec_safari.rb +2 -3
- data/spec/session_spec.rb +7 -0
- data/spec/shared_selenium_session.rb +14 -11
- data/spec/spec_helper.rb +2 -1
- metadata +6 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e077e28912ed7973882a0394db7eb44c493b0546175f81ef6f15c8ad1ee564c1
|
4
|
+
data.tar.gz: 6efae1078877ffe1578dc28d83f6d8df338dc01a162214c5b3aa3bd625c6a426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48d7420e5621c0dafbff830bfa56aba6ccf1d171d9efd0081f30f95f0cc538fa655d6fd5bef5525d13da573f51993f443f89b20af9b2241e4b9194b6ca3d2ae1
|
7
|
+
data.tar.gz: e7470806d56a47cbb6a2b12690816cc0cb569d26032ccae32ad2d832f356d59235f156651a8422ba70259021f9e47a81ad43f4d3e97612891e7e98c6eb1c857e
|
data/History.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Version 3.17.0
|
2
|
+
Release date: 2019-04-18
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
* Initial support for selenium-webdriver 4.0.0.alpha1
|
7
|
+
* :button selector will now also match on `name` attribute
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
* Suppress warnings generated by using selenium-webdriver 3.141.5926
|
12
|
+
* Mask Appium issue with finder visibility optimizations (non-optimal)
|
13
|
+
|
1
14
|
# Version 3.16.2
|
2
15
|
Release date: 2019-04-10
|
3
16
|
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
7
|
[](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
|
8
8
|
|
9
|
-
**Note** You are viewing the README for the 3.
|
9
|
+
**Note** You are viewing the README for the 3.17.x version of Capybara.
|
10
10
|
|
11
11
|
|
12
12
|
Capybara helps you test web applications by simulating how a real user would
|
data/lib/capybara.rb
CHANGED
@@ -466,42 +466,8 @@ module Capybara
|
|
466
466
|
require 'capybara/selenium/driver'
|
467
467
|
end
|
468
468
|
|
469
|
-
|
470
|
-
|
471
|
-
end
|
472
|
-
|
473
|
-
Capybara.register_server :webrick do |app, port, host, **options|
|
474
|
-
require 'rack/handler/webrick'
|
475
|
-
options = { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options)
|
476
|
-
Rack::Handler::WEBrick.run(app, options)
|
477
|
-
end
|
478
|
-
|
479
|
-
Capybara.register_server :puma do |app, port, host, **options|
|
480
|
-
begin
|
481
|
-
require 'rack/handler/puma'
|
482
|
-
rescue LoadError
|
483
|
-
raise LoadError, 'Capybara is unable to load `puma` for its server, please add `puma` to your project or specify a different server via something like `Capybara.server = :webrick`.'
|
484
|
-
else
|
485
|
-
unless Rack::Handler::Puma.respond_to?(:config)
|
486
|
-
raise LoadError, 'Capybara requires `puma` version 3.8.0 or higher, please upgrade `puma` or register and specify your own server block'
|
487
|
-
end
|
488
|
-
end
|
489
|
-
# If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
|
490
|
-
# Therefore construct and run the Server instance ourselves.
|
491
|
-
# Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
|
492
|
-
options = { Host: host, Port: port, Threads: '0:4', workers: 0, daemon: false }.merge(options)
|
493
|
-
conf = Rack::Handler::Puma.config(app, options)
|
494
|
-
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
|
495
|
-
|
496
|
-
events.log 'Capybara starting Puma...'
|
497
|
-
events.log "* Version #{Puma::Const::PUMA_VERSION} , codename: #{Puma::Const::CODE_NAME}"
|
498
|
-
events.log "* Min threads: #{conf.options[:min_threads]}, max threads: #{conf.options[:max_threads]}"
|
499
|
-
|
500
|
-
Puma::Server.new(conf.app, events, conf.options).tap do |s|
|
501
|
-
s.binder.parse conf.options[:binds], s.events
|
502
|
-
s.min_threads, s.max_threads = conf.options[:min_threads], conf.options[:max_threads]
|
503
|
-
end.run.join
|
504
|
-
end
|
469
|
+
require 'capybara/registrations/servers'
|
470
|
+
require 'capybara/registrations/drivers'
|
505
471
|
|
506
472
|
Capybara.configure do |config|
|
507
473
|
config.always_include_port = false
|
@@ -527,38 +493,3 @@ Capybara.configure do |config|
|
|
527
493
|
config.default_normalize_ws = false
|
528
494
|
config.allow_gumbo = false
|
529
495
|
end
|
530
|
-
|
531
|
-
Capybara.register_driver :rack_test do |app|
|
532
|
-
Capybara::RackTest::Driver.new(app)
|
533
|
-
end
|
534
|
-
|
535
|
-
Capybara.register_driver :selenium do |app|
|
536
|
-
Capybara::Selenium::Driver.new(app)
|
537
|
-
end
|
538
|
-
|
539
|
-
Capybara.register_driver :selenium_headless do |app|
|
540
|
-
Capybara::Selenium::Driver.load_selenium
|
541
|
-
browser_options = ::Selenium::WebDriver::Firefox::Options.new
|
542
|
-
browser_options.args << '-headless'
|
543
|
-
Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
|
544
|
-
end
|
545
|
-
|
546
|
-
Capybara.register_driver :selenium_chrome do |app|
|
547
|
-
Capybara::Selenium::Driver.load_selenium
|
548
|
-
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
549
|
-
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
550
|
-
opts.args << '--disable-site-isolation-trials'
|
551
|
-
end
|
552
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
553
|
-
end
|
554
|
-
|
555
|
-
Capybara.register_driver :selenium_chrome_headless do |app|
|
556
|
-
Capybara::Selenium::Driver.load_selenium
|
557
|
-
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
558
|
-
opts.args << '--headless'
|
559
|
-
opts.args << '--disable-gpu' if Gem.win_platform?
|
560
|
-
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
561
|
-
opts.args << '--disable-site-isolation-trials'
|
562
|
-
end
|
563
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
564
|
-
end
|
data/lib/capybara/config.rb
CHANGED
@@ -7,8 +7,7 @@ module Capybara
|
|
7
7
|
class Config
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
OPTIONS = %i[app reuse_server threadsafe
|
11
|
-
default_driver javascript_driver allow_gumbo].freeze
|
10
|
+
OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
|
12
11
|
|
13
12
|
attr_accessor :app
|
14
13
|
attr_reader :reuse_server, :threadsafe
|
@@ -45,7 +45,7 @@ module Capybara
|
|
45
45
|
#
|
46
46
|
# Finds a button on the page and clicks it.
|
47
47
|
# This can be any \<input> element of type submit, reset, image, button or it can be a
|
48
|
-
# \<button> element. All buttons can be found by their id, Capybara.test_id attribute, value, or title. \<button> elements can also be found
|
48
|
+
# \<button> element. All buttons can be found by their id, name, Capybara.test_id attribute, value, or title. \<button> elements can also be found
|
49
49
|
# by their text content, and image \<input> elements by their alt attribute
|
50
50
|
#
|
51
51
|
# @overload click_button([locator], **options)
|
@@ -300,7 +300,7 @@ module Capybara
|
|
300
300
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
301
301
|
begin
|
302
302
|
find(:select, from, options)
|
303
|
-
rescue Capybara::ElementNotFound => select_error
|
303
|
+
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
304
304
|
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
305
305
|
|
306
306
|
begin
|
@@ -356,14 +356,14 @@ module Capybara
|
|
356
356
|
begin
|
357
357
|
el = find(selector, locator, options)
|
358
358
|
el.set(checked)
|
359
|
-
rescue StandardError =>
|
360
|
-
raise unless allow_label_click && catch_error?(
|
359
|
+
rescue StandardError => e
|
360
|
+
raise unless allow_label_click && catch_error?(e)
|
361
361
|
|
362
362
|
begin
|
363
363
|
el ||= find(selector, locator, options.merge(visible: :all))
|
364
364
|
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
365
365
|
rescue StandardError # swallow extra errors - raise original
|
366
|
-
raise
|
366
|
+
raise e
|
367
367
|
end
|
368
368
|
end
|
369
369
|
end
|
data/lib/capybara/node/base.rb
CHANGED
@@ -81,19 +81,19 @@ module Capybara
|
|
81
81
|
timer = Capybara::Helpers.timer(expire_in: seconds)
|
82
82
|
begin
|
83
83
|
yield
|
84
|
-
rescue StandardError =>
|
84
|
+
rescue StandardError => e
|
85
85
|
session.raise_server_error!
|
86
|
-
raise
|
86
|
+
raise e unless catch_error?(e, errors)
|
87
87
|
|
88
88
|
if driver.wait?
|
89
|
-
raise
|
89
|
+
raise e if timer.expired?
|
90
90
|
|
91
91
|
sleep(0.01)
|
92
92
|
reload if session_options.automatic_reload
|
93
93
|
else
|
94
94
|
old_base = @base
|
95
95
|
reload if session_options.automatic_reload
|
96
|
-
raise
|
96
|
+
raise e if old_base == @base
|
97
97
|
end
|
98
98
|
retry
|
99
99
|
ensure
|
@@ -87,11 +87,11 @@ module Capybara
|
|
87
87
|
|
88
88
|
begin
|
89
89
|
synchronize { base.style(styles) }
|
90
|
-
rescue NotImplementedError =>
|
90
|
+
rescue NotImplementedError => e
|
91
91
|
begin
|
92
92
|
evaluate_script(STYLE_SCRIPT, *styles)
|
93
93
|
rescue Capybara::NotSupportedByDriverError
|
94
|
-
raise
|
94
|
+
raise e
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -113,7 +113,7 @@ module Capybara
|
|
113
113
|
#
|
114
114
|
# @return [Capybara::Node::Element] The element
|
115
115
|
def set(value, **options)
|
116
|
-
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if readonly?
|
116
|
+
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if ENV['CAPYBARA_THOROUGH'] && readonly?
|
117
117
|
|
118
118
|
options = session_options.default_set_options.to_h.merge(options)
|
119
119
|
synchronize { base.set(value, options) }
|
@@ -469,8 +469,8 @@ module Capybara
|
|
469
469
|
begin
|
470
470
|
reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
|
471
471
|
@base = reloaded.base if reloaded
|
472
|
-
rescue StandardError =>
|
473
|
-
raise
|
472
|
+
rescue StandardError => e
|
473
|
+
raise e unless catch_error?(e)
|
474
474
|
end
|
475
475
|
end
|
476
476
|
self
|
@@ -154,11 +154,11 @@ module Capybara
|
|
154
154
|
#
|
155
155
|
# Find a button on the page.
|
156
156
|
# This can be any \<input> element of type submit, reset, image, button or it can be a
|
157
|
-
# \<button> element. All buttons can be found by their id, Capbyara.test_id attribute, value, or title. \<button> elements can also be found
|
157
|
+
# \<button> element. All buttons can be found by their id, name, Capbyara.test_id attribute, value, or title. \<button> elements can also be found
|
158
158
|
# by their text content, and image \<input> elements by their alt attribute
|
159
159
|
#
|
160
160
|
# @overload find_button([locator], **options)
|
161
|
-
# @param [String] locator id, Capybara.test_id attribute, value, title, text content, alt of image
|
161
|
+
# @param [String] locator id, name, Capybara.test_id attribute, value, title, text content, alt of image
|
162
162
|
#
|
163
163
|
# @overload find_button(**options)
|
164
164
|
#
|
@@ -169,8 +169,9 @@ module Capybara
|
|
169
169
|
# * false - only finds an enabled button
|
170
170
|
# * :all - finds either an enabled or disabled button
|
171
171
|
# @option options [String, Regexp] id Match buttons with the id provided
|
172
|
-
# @option options [String]
|
173
|
-
# @option options [String]
|
172
|
+
# @option options [String] name Match buttons with the name provided
|
173
|
+
# @option options [String] title Match buttons with the title provided
|
174
|
+
# @option options [String] value Match buttons with the value provided
|
174
175
|
# @option options [String, Array<String>, Regexp] class Match buttons that match the class(es) provided
|
175
176
|
# @return [Capybara::Node::Element] The found element
|
176
177
|
#
|
@@ -241,6 +242,7 @@ module Capybara
|
|
241
242
|
# @option options [Integer] maximum Maximum number of matches that are expected to be found
|
242
243
|
# @option options [Integer] minimum Minimum number of matches that are expected to be found
|
243
244
|
# @option options [Range] between Number of matches found must be within the given range
|
245
|
+
# @option options [false, true, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
244
246
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options)
|
245
247
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options, &filter_block)
|
246
248
|
# @yieldparam element [Capybara::Node::Element] The element being considered for inclusion in the results
|
data/lib/capybara/node/simple.rb
CHANGED
@@ -107,7 +107,7 @@ module Capybara
|
|
107
107
|
!find_xpath(VISIBILITY_XPATH)
|
108
108
|
else
|
109
109
|
# No need for an xpath if only checking the current element
|
110
|
-
!(native.key?('hidden') || (
|
110
|
+
!(native.key?('hidden') || (/display:\s?none/.match? native[:style]) || %w[script head].include?(tag_name))
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -127,7 +127,8 @@ module Capybara
|
|
127
127
|
#
|
128
128
|
# @return [Boolean] Whether the element is disabled
|
129
129
|
def disabled?
|
130
|
-
native.has_attribute?('disabled')
|
130
|
+
native.has_attribute?('disabled') &&
|
131
|
+
%w[button input select textarea optgroup option menuitem fieldset].include?(tag_name)
|
131
132
|
end
|
132
133
|
|
133
134
|
##
|
@@ -83,7 +83,7 @@ module Capybara
|
|
83
83
|
matches_system_filters?(node) &&
|
84
84
|
matches_node_filters?(node, node_filter_errors) &&
|
85
85
|
matches_filter_block?(node)
|
86
|
-
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : [])
|
86
|
+
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # rubocop:disable Naming/RescuedExceptionsVariableName
|
87
87
|
false
|
88
88
|
end
|
89
89
|
|
@@ -368,13 +368,13 @@ module Capybara
|
|
368
368
|
def matches_id_filter?(node)
|
369
369
|
return true unless use_default_id_filter? && options[:id].is_a?(Regexp)
|
370
370
|
|
371
|
-
|
371
|
+
options[:id].match? node[:id]
|
372
372
|
end
|
373
373
|
|
374
374
|
def matches_class_filter?(node)
|
375
375
|
return true unless use_default_class_filter? && options[:class].is_a?(Regexp)
|
376
376
|
|
377
|
-
|
377
|
+
options[:class].match? node[:class]
|
378
378
|
end
|
379
379
|
|
380
380
|
def matches_style_filter?(node)
|
@@ -382,7 +382,7 @@ module Capybara
|
|
382
382
|
when String, nil
|
383
383
|
true
|
384
384
|
when Regexp
|
385
|
-
|
385
|
+
options[:style].match? node[:style]
|
386
386
|
when Hash
|
387
387
|
matches_style?(node, options[:style])
|
388
388
|
end
|
@@ -392,7 +392,7 @@ module Capybara
|
|
392
392
|
@actual_styles = node.initial_cache[:style] || node.style(*styles.keys)
|
393
393
|
styles.all? do |style, value|
|
394
394
|
if value.is_a? Regexp
|
395
|
-
@actual_styles[style.to_s]
|
395
|
+
value.match? @actual_styles[style.to_s]
|
396
396
|
else
|
397
397
|
@actual_styles[style.to_s] == value
|
398
398
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Capybara.register_driver :rack_test do |app|
|
4
|
+
Capybara::RackTest::Driver.new(app)
|
5
|
+
end
|
6
|
+
|
7
|
+
Capybara.register_driver :selenium do |app|
|
8
|
+
Capybara::Selenium::Driver.new(app)
|
9
|
+
end
|
10
|
+
|
11
|
+
Capybara.register_driver :selenium_headless do |app|
|
12
|
+
Capybara::Selenium::Driver.load_selenium
|
13
|
+
browser_options = ::Selenium::WebDriver::Firefox::Options.new
|
14
|
+
browser_options.args << '-headless'
|
15
|
+
Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
|
16
|
+
end
|
17
|
+
|
18
|
+
Capybara.register_driver :selenium_chrome do |app|
|
19
|
+
Capybara::Selenium::Driver.load_selenium
|
20
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
21
|
+
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
22
|
+
opts.args << '--disable-site-isolation-trials'
|
23
|
+
end
|
24
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
25
|
+
end
|
26
|
+
|
27
|
+
Capybara.register_driver :selenium_chrome_headless do |app|
|
28
|
+
Capybara::Selenium::Driver.load_selenium
|
29
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
30
|
+
opts.args << '--headless'
|
31
|
+
opts.args << '--disable-gpu' if Gem.win_platform?
|
32
|
+
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
33
|
+
opts.args << '--disable-site-isolation-trials'
|
34
|
+
end
|
35
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
36
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Capybara.register_server :default do |app, port, _host|
|
4
|
+
Capybara.run_default_server(app, port)
|
5
|
+
end
|
6
|
+
|
7
|
+
Capybara.register_server :webrick do |app, port, host, **options|
|
8
|
+
require 'rack/handler/webrick'
|
9
|
+
options = { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options)
|
10
|
+
Rack::Handler::WEBrick.run(app, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
Capybara.register_server :puma do |app, port, host, **options|
|
14
|
+
begin
|
15
|
+
require 'rack/handler/puma'
|
16
|
+
rescue LoadError
|
17
|
+
raise LoadError, 'Capybara is unable to load `puma` for its server, please add `puma` to your project or specify a different server via something like `Capybara.server = :webrick`.'
|
18
|
+
else
|
19
|
+
unless Rack::Handler::Puma.respond_to?(:config)
|
20
|
+
raise LoadError, 'Capybara requires `puma` version 3.8.0 or higher, please upgrade `puma` or register and specify your own server block'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
|
24
|
+
# Therefore construct and run the Server instance ourselves.
|
25
|
+
# Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
|
26
|
+
options = { Host: host, Port: port, Threads: '0:4', workers: 0, daemon: false }.merge(options)
|
27
|
+
conf = Rack::Handler::Puma.config(app, options)
|
28
|
+
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
|
29
|
+
|
30
|
+
events.log 'Capybara starting Puma...'
|
31
|
+
events.log "* Version #{Puma::Const::PUMA_VERSION} , codename: #{Puma::Const::CODE_NAME}"
|
32
|
+
events.log "* Min threads: #{conf.options[:min_threads]}, max threads: #{conf.options[:max_threads]}"
|
33
|
+
|
34
|
+
Puma::Server.new(conf.app, events, conf.options).tap do |s|
|
35
|
+
s.binder.parse conf.options[:binds], s.events
|
36
|
+
s.min_threads, s.max_threads = conf.options[:min_threads], conf.options[:max_threads]
|
37
|
+
end.run.join
|
38
|
+
end
|
data/lib/capybara/result.rb
CHANGED
@@ -149,10 +149,10 @@ module Capybara
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def lazy_select_elements(&block)
|
152
|
-
# JRuby has an issue with lazy enumerators which
|
152
|
+
# JRuby < 9.2.8.0 has an issue with lazy enumerators which
|
153
153
|
# causes a concurrency issue with network requests here
|
154
154
|
# https://github.com/jruby/jruby/issues/4212
|
155
|
-
if RUBY_PLATFORM == 'java'
|
155
|
+
if (RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0'))
|
156
156
|
@elements.select(&block).to_enum # non-lazy evaluation
|
157
157
|
else
|
158
158
|
@elements.lazy.select(&block)
|