Sha256: 7cc43cd5e73a21412f2d657a2420feaf4b906b82a3fc6bc4eff5a22e6091ad5d

Contents?: true

Size: 1.42 KB

Versions: 176

Compression:

Stored size: 1.42 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 "matches when actual.equal?(expected)" do
        1.should equal(1)
      end

      it "does not match when !actual.equal?(expected)" do
        "1".should_not equal("1")
      end
      
      it "describes itself" do
        matcher = equal(1)
        matcher.matches?(1)
        matcher.description.should == "equal 1"
      end
      
      it "provides 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 "provides 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

176 entries across 77 versions & 9 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/equal_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/equal_spec.rb