Sha256: 33bac571791aa7566a83cfe801aa03cda0a46c56c9eae96aa9a648244a16f0fe

Contents?: true

Size: 938 Bytes

Versions: 17

Compression:

Stored size: 938 Bytes

Contents

module RSpec
  module Matchers
    module BuiltIn
      # @api private
      # Provides the implementation for `match`.
      # Not intended to be instantiated directly.
      class Match < BaseMatcher
        # @api private
        # @return [String]
        def description
          "match #{surface_descriptions_in(expected).inspect}"
        end

        # @api private
        # @return [Boolean]
        def diffable?
          true
        end

      private

        def match(expected, actual)
          return true if values_match?(expected, actual)
          return false unless can_safely_call_match?(expected, actual)
          actual.match(expected)
        end

        def can_safely_call_match?(expected, actual)
          return false unless actual.respond_to?(:match)

          !(RSpec::Matchers.is_a_matcher?(expected) &&
            (String === actual || Regexp === actual))
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 9 rubygems

Version Path
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
sublimetheme-1.0.1 path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
sublimetheme-1.0.0 path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
geminfo-0.1.0 path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/rspec-expectations-3.3.0/lib/rspec/matchers/built_in/match.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/rspec-expectations-3.3.0/lib/rspec/matchers/built_in/match.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb
rspec-expectations-3.3.1 lib/rspec/matchers/built_in/match.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-expectations-3.3.0/lib/rspec/matchers/built_in/match.rb
rspec-expectations-3.3.0 lib/rspec/matchers/built_in/match.rb