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