Sha256: 1fb3b4dbf69985ed552a4f2cd03bcee7cefc0378d9f543c98ff48846ef202335

Contents?: true

Size: 1.51 KB

Versions: 10

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'
module RSpec
  module Matchers
    describe "equal" do
      it_behaves_like "an RSpec matcher", :valid_value => :a, :invalid_value => :b do
        let(:matcher) { equal(:a) }
      end

      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 eq(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

10 entries across 10 versions & 5 rubygems

Version Path
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/equal_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/equal_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/spec/rspec/matchers/equal_spec.rb
remq-0.0.4 vendor/bundle/gems/rspec-expectations-2.12.1/spec/rspec/matchers/equal_spec.rb
remq-0.0.3 vendor/bundle/gems/rspec-expectations-2.12.1/spec/rspec/matchers/equal_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.12.1 spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.12.0 spec/rspec/matchers/equal_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/spec/rspec/matchers/equal_spec.rb
rspec-expectations-2.11.3 spec/rspec/matchers/equal_spec.rb