Sha256: 7a33ab9845f3faa11061a5a4f7d15bb43880cbf166092ab23ac2ccc4e1034d44

Contents?: true

Size: 1.42 KB

Versions: 45

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

45 entries across 45 versions & 6 rubygems

Version Path
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.3.0 spec/rspec/matchers/equal_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.2.0 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.1.0 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.0.1 spec/rspec/matchers/equal_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.1.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb
gemrage-0.1.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/equal_spec.rb