-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get control of driver/server registrations
- Loading branch information
Showing
5 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module Capybara | ||
# @api private | ||
class RegistrationContainer | ||
def names | ||
@registered.keys | ||
end | ||
|
||
def [](name) | ||
@registered[name] | ||
end | ||
|
||
def []=(name, value) | ||
warn 'DEPRECATED: Directly setting drivers/servers is deprecated, please use Capybara.register_driver/register_server instead' | ||
@registered[name] = value | ||
end | ||
|
||
def method_missing(method_name, *args, **options, &block) | ||
if @registered.respond_to?(method_name) | ||
warn "DEPRECATED: Calling '#{method_name}' on the drivers/servers container is deprecated without replacement" | ||
# RUBY 2.6 will send an empty hash rather than nothing with **options so fix that | ||
return @registered.public_send(method_name, *args, &block) if options.empty? | ||
|
||
return @registered.public_send(method_name, *args, **options, &block) | ||
end | ||
super | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
@registered.respond_to?(method_name) || super | ||
end | ||
|
||
private | ||
|
||
def initialize | ||
@registered = {} | ||
end | ||
|
||
def register(name, block) | ||
@registered[name] = block | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters