Sha256: 8fae2a0a73cfac47331fdfec85265090b0390162fce6d8dcb4f1286db9fbe22b

Contents?: true

Size: 875 Bytes

Versions: 6

Compression:

Stored size: 875 Bytes

Contents

module RSpec
  module Matchers
    # Provides the necessary plumbing to wrap a matcher with a decorator.
    # @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

      def initialize_copy(other)
        @base_matcher = @base_matcher.clone
        super
      end

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rspec-expectations-3.0.4 lib/rspec/matchers/matcher_delegator.rb
rspec-expectations-3.0.3 lib/rspec/matchers/matcher_delegator.rb
rspec-expectations-3.0.2 lib/rspec/matchers/matcher_delegator.rb
whos_dated_who-0.1.0 vendor/bundle/gems/rspec-expectations-3.0.1/lib/rspec/matchers/matcher_delegator.rb
whos_dated_who-0.0.1 vendor/bundle/gems/rspec-expectations-3.0.1/lib/rspec/matchers/matcher_delegator.rb
rspec-expectations-3.0.1 lib/rspec/matchers/matcher_delegator.rb