Sha256: 0764136fbe1a24cc2d60680ef81390c1d0e4027b5423c9c645233015dc0775dd

Contents?: true

Size: 1.23 KB

Versions: 5219

Compression:

Stored size: 1.23 KB

Contents

module RSpec
  module Expectations
    class << self
      # @private
      class Differ
        # @private
        OBJECT_PREPARER = lambda do |object|
          RSpec::Matchers::Composable.surface_descriptions_in(object)
        end
      end

      # @private
      def differ
        RSpec::Support::Differ.new(
          :object_preparer => Differ::OBJECT_PREPARER,
          :color => RSpec::Matchers.configuration.color?
        )
      end

      # Raises an RSpec::Expectations::ExpectationNotMetError with message.
      # @param [String] message
      # @param [Object] expected
      # @param [Object] actual
      #
      # Adds a diff to the failure message when `expected` and `actual` are
      # both present.
      def fail_with(message, expected=nil, actual=nil)
        unless message
          raise ArgumentError, "Failure message is nil. Does your matcher define the " \
                               "appropriate failure_message[_when_negated] method to return a string?"
        end

        message = ::RSpec::Matchers::ExpectedsForMultipleDiffs.from(expected).message_with_diff(message, differ, actual)

        RSpec::Support.notify_failure(RSpec::Expectations::ExpectationNotMetError.new message)
      end
    end
  end
end

Version data entries

5,219 entries across 5,144 versions & 94 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
mux_ruby-3.18.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.10.1/lib/rspec/expectations/fail_with.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.10.1/lib/rspec/expectations/fail_with.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.10.1/lib/rspec/expectations/fail_with.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
mux_ruby-3.15.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
mux_ruby-3.14.0 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.11.0/lib/rspec/expectations/fail_with.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb
cybrid_api_id_ruby-0.113.118 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/expectations/fail_with.rb