Sha256: 00a871f5f17a255c27a8d358e912ee792d87591a6db8f4b3fd2ce4964984857f

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'
module RSpec
  module Matchers
    describe "equal" do
      
      def inspect_object(o)
        "#<#{o.class}:#{o.object_id}> => #{o.inspect}"
      end
      
      it "should match when actual.equal?(expected)" do
        1.should equal(1)
      end

      it "should not match when !actual.equal?(expected)" do
        1.should_not equal("1")
      end
      
      it "should describe itself" do
        matcher = equal(1)
        matcher.matches?(1)
        matcher.description.should == "equal 1"
      end
      
      it "should provide message on #failure_message" do
        expected, actual = "1", "1"
        matcher = equal(expected)
        matcher.matches?(actual)
        
        matcher.failure_message_for_should.should == <<-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
'actual.should == expected' if you don't care about
object identity in this example.

MESSAGE
      end
      
      it "should provide message on #negative_failure_message" do
        expected = actual = "1"
        matcher = equal(expected)
        matcher.matches?(actual)
        matcher.failure_message_for_should_not.should == <<-MESSAGE

expected not #{inspect_object(expected)}
         got #{inspect_object(actual)}

Compared using equal?, which compares object identity.

MESSAGE
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.19 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.18 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.17 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.16 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.15 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.14 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.13 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.12 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.11 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.10 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.0.beta.9 spec/rspec/matchers/equal_spec.rb