Sha256: 43999183987df7cecbabde20e6cef152cea2a8d6808301d49eaf3f0f214f2154

Contents?: true

Size: 1.49 KB

Versions: 61

Compression:

Stored size: 1.49 KB

Contents

module RSpec
  module Matchers
    module BuiltIn
      # @api private
      #
      # Used _internally_ as a base class for matchers that ship with
      # rspec-expectations.
      #
      # ### Warning:
      #
      # This class is for internal use, and subject to change without notice.  We
      # strongly recommend that you do not base your custom matchers on this
      # class. If/when this changes, we will announce it and remove this warning.
      module BaseMatcher
        include RSpec::Matchers::Pretty

        attr_reader :actual, :expected, :rescued_exception

        def initialize(expected=nil)
          @expected = expected
        end

        def matches?(actual)
          @actual = actual
        end

        def match_unless_raises(*exceptions)
          exceptions.unshift Exception if exceptions.empty?
          begin
            yield
          rescue *exceptions => @rescued_exception
            return false
          end
          true
        end

        def failure_message_for_should
          "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"
        end

        def failure_message_for_should_not
          "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"
        end

        def description
          expected ? "#{name_to_sentence} #{expected.inspect}" : name_to_sentence
        end

        def diffable?
          false
        end

        def ==(other)
          matches?(other)
        end
      end
    end
  end
end

Version data entries

61 entries across 56 versions & 5 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.8 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.7 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.6 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.5 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.4 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.3 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.2 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.1 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.6.0 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.5.17 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.5.16 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb
classiccms-0.5.15 vendor/bundle/gems/rspec-expectations-2.10.0/lib/rspec/matchers/built_in/base_matcher.rb