Skip to content

Commit 7ef419f

Browse files
Remove dependency on ruby2_keywords
1 parent 1c4a5c7 commit 7ef419f

3 files changed

Lines changed: 12 additions & 28 deletions

File tree

Gemfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ PATH
44
capybara-lockstep (2.3.0)
55
activesupport (>= 7.0)
66
capybara (>= 3.0)
7-
ruby2_keywords
87

98
GEM
109
remote: https://rubygems.org/

capybara-lockstep.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
3030
# Uncomment to register a new dependency of your gem
3131
spec.add_dependency "capybara", ">= 3.0"
3232
spec.add_dependency "activesupport", ">= 7.0"
33-
spec.add_dependency "ruby2_keywords"
3433

3534
# For more information and examples about making a new gem, checkout our
3635
# guide at: https://bundler.io/guides/creating_gem.html

lib/capybara-lockstep/capybara_ext.rb

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'ruby2_keywords'
2-
31
module Capybara
42
module Lockstep
53
module SynchronizeMacros
@@ -13,43 +11,37 @@ def self.extended(by)
1311

1412
def synchronize_before(meth, lazy:)
1513
@synchronize_before_module.module_eval do
16-
define_method meth do |*args, &block|
14+
define_method meth do |*args, **kwargs, &block|
1715
@synchronize_before_count ||= 0
1816
@synchronize_before_count += 1
1917
Lockstep.auto_synchronize(lazy: lazy, log: "Synchronizing before ##{meth}") if @synchronize_before_count == 1
20-
super(*args, &block)
18+
super(*args, **kwargs, &block)
2119
ensure
2220
@synchronize_before_count -= 1
2321
end
24-
25-
ruby2_keywords meth
2622
end
2723
end
2824

2925
def synchronize_after(meth)
3026
@synchronize_after_module.module_eval do
31-
define_method meth do |*args, &block|
27+
define_method meth do |*args, **kwargs, &block|
3228
@synchronize_after_count ||= 0
3329
@synchronize_after_count += 1
34-
super(*args, &block)
30+
super(*args, **kwargs, &block)
3531
ensure
3632
Lockstep.auto_synchronize(log: "Synchronizing after ##{meth}") if @synchronize_after_count == 1
3733
@synchronize_after_count -= 1
3834
end
39-
40-
ruby2_keywords meth
4135
end
4236
end
4337

4438
def unsynchronize_after(meth)
4539
@unsynchronize_after_module.module_eval do
46-
define_method meth do |*args, &block|
47-
super(*args, &block)
40+
define_method meth do |*args, **kwargs, &block|
41+
super(*args, **kwargs, &block)
4842
ensure
4943
Lockstep.unsynchronize
5044
end
51-
52-
ruby2_keywords meth
5345
end
5446
end
5547
end
@@ -82,7 +74,7 @@ def unsynchronize_after(meth)
8274
module Capybara
8375
module Lockstep
8476
module VisitWithWaiting
85-
def visit(*args, &block)
77+
def visit(*args, **kwargs, &block)
8678
# For some reason, in Capybara proper, visit(nil) navigates to the root route.
8779
# We mimic this behavior for (1) parity and (2) to not crash when we inspect the URL below.
8880
url = args[0].presence || '/'
@@ -104,15 +96,13 @@ def visit(*args, &block)
10496
Lockstep.auto_synchronize(lazy: false, log: "Synchronizing before visiting #{url}")
10597
end
10698

107-
super(*args, &block).tap do
99+
super(*args, **kwargs, &block).tap do
108100
if visiting_real_url
109101
# We haven't yet synchronized the new screen.
110102
Lockstep.unsynchronize
111103
end
112104
end
113105
end
114-
115-
ruby2_keywords :visit
116106
end
117107
end
118108
end
@@ -127,7 +117,7 @@ module SynchronizeAroundScriptMethod
127117

128118
def synchronize_around_script_method(meth)
129119
mod = Module.new do
130-
define_method meth do |script, *args, &block|
120+
define_method meth do |script, *args, **kwargs, &block|
131121
# Synchronization uses execute_script itself, so don't synchronize when
132122
# we're already synchronizing.
133123
if !Lockstep.synchronizing?
@@ -142,16 +132,14 @@ def synchronize_around_script_method(meth)
142132
Lockstep.auto_synchronize(lazy: !script_may_navigate_away, log: "Synchronizing before script: #{script}")
143133
end
144134

145-
super(script, *args, &block)
135+
super(script, *args, **kwargs, &block)
146136
ensure
147137
if !Lockstep.synchronizing?
148138
# We haven't yet synchronized with whatever changes the JavaScript
149139
# did on the frontend.
150140
Lockstep.unsynchronize
151141
end
152142
end
153-
154-
ruby2_keywords meth
155143
end
156144
prepend(mod)
157145
end
@@ -246,16 +234,14 @@ def synchronize_around_script_method(meth)
246234
module Capybara
247235
module Lockstep
248236
module SynchronizeWithCatchUp
249-
def synchronize(*args, &block)
237+
def synchronize(*args, **kwargs, &block)
250238
# This method is called by Capybara before most interactions with
251239
# the browser. It is a different method than Capybara::Lockstep.synchronize!
252240
# We use the { lazy } option to only synchronize when we're out of sync.
253241
Lockstep.auto_synchronize(lazy: true, log: 'Synchronizing before node access')
254242

255-
super(*args, &block)
243+
super(*args, **kwargs, &block)
256244
end
257-
258-
ruby2_keywords :synchronize
259245
end
260246
end
261247
end

0 commit comments

Comments
 (0)