Skip to content

Commit a2750f5

Browse files
committed
Mix-in all method proxy via Object#extend
as described in teamcapybara/capybara#2771
1 parent 3661e67 commit a2750f5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

features/support/env.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55

66
require "bundler"
77
Bundler.setup
8-
# require order matters, capybara needs to be there before aruba for the RSpec shadowing fix to work (see slightly below)
98
require "capybara/cucumber"
109
require "capybara/apparition"
1110
require "aruba/cucumber"
1211
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
1312
require "simplecov"
1413

15-
# Small workaround I found for the RSpec/aruba shadowing problem showcased in https://github.com/PragTob/all_conflict/
16-
# It _seems_ to work for now but it's definitely not ideal. Wish this was fixed in Capybara.
17-
Aruba::Api::Core.include(Capybara::RSpecMatcherProxies)
14+
# Monkey-patching Capybara::DSL if Capybara::DSLRSpecProxyInstaller has no `extended` hook
15+
unless Module.new.extend(RSpec::Matchers).extend(Capybara::DSL).singleton_class.ancestors.include?(Capybara::RSpecMatcherProxies)
16+
Capybara::DSL.extend(Module.new {
17+
def extended(base)
18+
base.extend(::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.is_a?(::RSpec::Matchers)
19+
super
20+
end
21+
})
22+
end
1823

1924
# Rack app for Capybara which returns the latest coverage report from Aruba temp project dir
2025
coverage_dir = File.expand_path("../../tmp/aruba/project/coverage/", __dir__)

0 commit comments

Comments
 (0)