Sha256: 83a8b8bfc2c56f8800ce2bb55e887725867df974ce103b808ddfa30d131a879d

Contents?: true

Size: 1.93 KB

Versions: 19

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

module Capybara
  module RSpecMatcherProxies
    def all(*args, **kwargs, &block)
      if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
        ::RSpec::Matchers::BuiltIn::All.new(*args)
      else
        find_all(*args, **kwargs, &block)
      end
    end

    def within(*args, **kwargs, &block)
      if block
        within_element(*args, **kwargs, &block)
      else
        be_within(*args)
      end
    end
  end
end

if RUBY_ENGINE == 'jruby'
  # :nocov:
  module Capybara::DSL
    class <<self
      remove_method :included

      def included(base)
        warn 'including Capybara::DSL in the global scope is not recommended!' if base == Object
        if defined?(::RSpec::Matchers) && base.include?(::RSpec::Matchers)
          base.send(:include, ::Capybara::RSpecMatcherProxies)
        end
        super
      end
    end
  end

  if defined?(::RSpec::Matchers)
    module ::RSpec::Matchers
      def self.included(base)
        base.send(:include, ::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
        super
      end
    end
  end
  # :nocov:
else
  module Capybara::DSLRSpecProxyInstaller
    module ClassMethods
      def included(base)
        base.include(::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.include?(::RSpec::Matchers)
        super
      end
    end

    def self.prepended(base)
      class <<base
        prepend ClassMethods
      end
    end
  end

  module Capybara::RSpecMatcherProxyInstaller
    module ClassMethods
      def included(base)
        base.include(::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
        super
      end
    end

    def self.prepended(base)
      class <<base
        prepend ClassMethods
      end
    end
  end

  Capybara::DSL.prepend ::Capybara::DSLRSpecProxyInstaller

  ::RSpec::Matchers.prepend ::Capybara::RSpecMatcherProxyInstaller if defined?(::RSpec::Matchers)
end

Version data entries

19 entries across 10 versions & 2 rubygems

Version Path
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/capybara-3.34.0/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.34.0/lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/rspec/matcher_proxies.rb
capybara-3.35.3 lib/capybara/rspec/matcher_proxies.rb
capybara-3.35.2 lib/capybara/rspec/matcher_proxies.rb
capybara-3.35.1 lib/capybara/rspec/matcher_proxies.rb
capybara-3.35.0 lib/capybara/rspec/matcher_proxies.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/rspec/matcher_proxies.rb
capybara-3.34.0 lib/capybara/rspec/matcher_proxies.rb