Skip to content

Commit

Permalink
Mix-in all method proxy via Object#extend
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Aug 30, 2024
1 parent 3661e67 commit e3eb394
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@

require "bundler"
Bundler.setup
# require order matters, capybara needs to be there before aruba for the RSpec shadowing fix to work (see slightly below)
require "capybara/cucumber"
require "capybara/apparition"
require "aruba/cucumber"
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
require "simplecov"

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

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

0 comments on commit e3eb394

Please sign in to comment.