Sha256: e36c1ee04dc70404bdadb4b3e4b8598ed86b9204818c3411957dd5a639a96f3b

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

module RSpec
  module Matchers
    # Provides the necessary plumbing to wrap a matcher with a decorator.
    #
    # @api private
    class MatcherDelegator
      attr_reader :base_matcher

      def initialize(base_matcher)
        @base_matcher = base_matcher
      end

      def method_missing(*args, &block)
        base_matcher.__send__(*args, &block)
      end

      if ::RUBY_VERSION.to_f > 1.8
        def respond_to_missing?(name, include_all=false)
          super || base_matcher.respond_to?(name, include_all)
        end
      else
        def respond_to?(name, include_all=false)
          super || base_matcher.respond_to?(name, include_all)
        end
      end

      # So `===` is delegated via `method_missing`.
      undef ===
      undef ==
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-expectations-3.0.0.beta2 lib/rspec/matchers/matcher_delegator.rb