2017-03-28 17:41:49 +00:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 20:23:54 +00:00
|
|
|
|
2017-03-28 17:41:49 +00:00
|
|
|
module Capybara
|
|
|
|
module RSpecMatcherProxies
|
2018-02-14 04:56:49 +00:00
|
|
|
def all(*args, &block)
|
2017-03-28 17:41:49 +00:00
|
|
|
if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
|
|
|
|
::RSpec::Matchers::BuiltIn::All.new(*args)
|
|
|
|
else
|
2018-02-14 04:56:49 +00:00
|
|
|
find_all(*args, &block)
|
2017-03-28 17:41:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within(*args)
|
|
|
|
if block_given?
|
|
|
|
within_element(*args, &Proc.new)
|
|
|
|
else
|
|
|
|
be_within(*args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-03 18:07:17 +00:00
|
|
|
module DSLRSpecProxyInstaller
|
|
|
|
module ClassMethods
|
2017-05-28 15:54:55 +00:00
|
|
|
def included(base)
|
2017-06-03 18:07:17 +00:00
|
|
|
if defined?(::RSpec::Matchers)
|
|
|
|
base.include(::Capybara::RSpecMatcherProxies) if base.include?(::RSpec::Matchers)
|
2017-05-28 15:54:55 +00:00
|
|
|
end
|
2017-06-03 18:07:17 +00:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
2017-05-28 15:54:55 +00:00
|
|
|
|
2017-06-03 18:07:17 +00:00
|
|
|
def self.prepended(base)
|
|
|
|
class <<base
|
|
|
|
prepend ClassMethods
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module RSpecMatcherProxyInstaller
|
|
|
|
module ClassMethods
|
|
|
|
def included(base)
|
|
|
|
base.include(::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
|
2017-05-28 15:54:55 +00:00
|
|
|
super
|
|
|
|
end
|
2017-03-28 17:41:49 +00:00
|
|
|
end
|
2017-06-03 18:07:17 +00:00
|
|
|
|
|
|
|
def self.prepended(base)
|
|
|
|
class <<base
|
|
|
|
prepend ClassMethods
|
|
|
|
end
|
|
|
|
end
|
2017-03-28 17:41:49 +00:00
|
|
|
end
|
2017-06-03 18:07:17 +00:00
|
|
|
|
|
|
|
DSL.prepend ::Capybara::DSLRSpecProxyInstaller
|
2017-03-28 17:41:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if defined?(::RSpec::Matchers)
|
2017-06-03 18:07:17 +00:00
|
|
|
module ::RSpec::Matchers
|
|
|
|
prepend ::Capybara::RSpecMatcherProxyInstaller
|
2017-03-28 17:41:49 +00:00
|
|
|
end
|
|
|
|
end
|