Sha256: cae1e64ac316482a1e0e881986c643abfdf3dd5f9089c251c708defbad6c4700

Contents?: true

Size: 1.87 KB

Versions: 42

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

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

    def within(*args)
      if block_given?
        within_element(*args, &Proc.new)
      else
        be_within(*args)
      end
    end
  end
end

if RUBY_ENGINE == 'jruby'
  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
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

42 entries across 42 versions & 3 rubygems

Version Path
isomorfeus-puppetmaster-0.5.7 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.6 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.5 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.4 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.3 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.2 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.1 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.5.0 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.4.1 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.4.0 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.5 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.4 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.3 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.2 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.1 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.3.0 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.2.9 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.2.8 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.2.7 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb
isomorfeus-puppetmaster-0.2.6 lib/isomorfeus/puppetmaster/rspec/matcher_proxies.rb