Sha256: fb452e693194ec0ce654bce1429b63092b92dba6238e1891065c7fb7ee5805a6

Contents?: true

Size: 1.09 KB

Versions: 111

Compression:

Stored size: 1.09 KB

Contents

module RSpec
  module Expectations
    class << self
      # @private
      def differ
        RSpec::Support::Differ.new(
          :object_preparer => lambda { |object| RSpec::Matchers::Composable.surface_descriptions_in(object) },
          :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

111 entries across 103 versions & 29 rubygems

Version Path
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb