Sha256: b54180320cb53fdd9d60ba42e255aba11d3e53f863208f6e0f0344aaeadae7a4

Contents?: true

Size: 1.44 KB

Versions: 32

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'
module Spec
  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

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 spec/spec/matchers/equal_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/spec/spec/matchers/equal_spec.rb
rspec-1.3.2 spec/spec/matchers/equal_spec.rb
rspec-1.3.1 spec/spec/matchers/equal_spec.rb
rspec-1.3.1.rc spec/spec/matchers/equal_spec.rb
rspec-1.3.0 spec/spec/matchers/equal_spec.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/spec/spec/matchers/equal_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/spec/spec/matchers/equal_spec.rb
media-path-0.1.2 vendor/rspec/spec/spec/matchers/equal_spec.rb
simple-templater-0.0.1.3 vendor/rspec/spec/spec/matchers/equal_spec.rb
pupu-0.0.2.pre vendor/rspec/spec/spec/matchers/equal_spec.rb
media-path-0.1.1.pre vendor/rspec/spec/spec/matchers/equal_spec.rb
simple-templater-0.0.1.2 vendor/rspec/spec/spec/matchers/equal_spec.rb
media-path-0.1.1 vendor/rspec/spec/spec/matchers/equal_spec.rb
simple-templater-0.0.1.1 vendor/rspec/spec/spec/matchers/equal_spec.rb
pupu-0.0.2 vendor/rspec/spec/spec/matchers/equal_spec.rb