Sha256: 31cd5e20d51991c24949db1a5f01724134921660d6b161c2bf23d985d92ebd27

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

module RSpec
  module Matchers
    describe "eq" do
      it "is diffable" do
        eq(1).should be_diffable
      end

      it "matches when actual == expected" do
        1.should eq(1)
      end
      
      it "does not match when actual != expected" do
        1.should_not eq(2)
      end

      it "compares by sending == to actual (not expected)" do
        called = false
        actual = Class.new do
          define_method :== do |other|
            called = true
          end
        end.new

        actual.should eq :anything # to trigger the matches? method
        called.should be_true
      end

      it "describes itself" do
        matcher = eq(1)
        matcher.matches?(1)
        matcher.description.should eq "eq 1"
      end
      
      it "provides message, expected and actual on #failure_message" do
        matcher = eq("1")
        matcher.matches?(1)
        matcher.failure_message_for_should.should eq "\nexpected: \"1\"\n     got: 1\n\n(compared using ==)\n"
      end
      
      it "provides message, expected and actual on #negative_failure_message" do
        matcher = eq(1)
        matcher.matches?(1)
        matcher.failure_message_for_should_not.should eq "\nexpected: value != 1\n     got: 1\n\n(compared using ==)\n"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
gem_repackager-0.1.0 support/gems/rspec-expectations-2.11.2/spec/rspec/matchers/eq_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/rspec-expectations-2.11.2/spec/rspec/matchers/eq_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/rspec-expectations-2.11.2/spec/rspec/matchers/eq_spec.rb
rspec-expectations-2.11.2 spec/rspec/matchers/eq_spec.rb
rspec-expectations-2.11.1 spec/rspec/matchers/eq_spec.rb
rspec-expectations-2.11.0 spec/rspec/matchers/eq_spec.rb