Sha256: 9d9515d614b360974ce1fd001877cf98604c92f8a1e5f1a3fe2f26b797051cd7
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
module RSpec module Matchers module BuiltIn class Equal < BaseMatcher def match(expected, actual) actual.equal? expected end def failure_message if expected_is_a_literal_singleton? simple_failure_message else detailed_failure_message end end def failure_message_when_negated return <<-MESSAGE expected not #{inspect_object(actual)} got #{inspect_object(expected)} Compared using equal?, which compares object identity. MESSAGE end def diffable? !expected_is_a_literal_singleton? end private LITERAL_SINGLETONS = [true, false, nil] def expected_is_a_literal_singleton? LITERAL_SINGLETONS.include?(expected) end def simple_failure_message "\nexpected #{expected.inspect}\n got #{inspect_object(actual)}\n" end def detailed_failure_message return <<-MESSAGE expected #{inspect_object(expected)} got #{inspect_object(actual)} Compared using equal?, which compares object identity, but expected and actual are not the same object. Use `expect(actual).to eq(expected)` if you don't care about object identity in this example. MESSAGE end def inspect_object(o) "#<#{o.class}:#{o.object_id}> => #{o.inspect}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-expectations-3.0.0.beta2 | lib/rspec/matchers/built_in/equal.rb |