Sha256: e1c5d888c4645a6c46a2d8592f5a9ff0fc2987ec7b8ef6f3b27c466ef5616cb9

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'

describe EqualMatcher do
  it "matches when actual is equal? to expected" do
    EqualMatcher.new(1).matches?(1).should == true
    EqualMatcher.new(:blue).matches?(:blue).should == true
    EqualMatcher.new(Object).matches?(Object).should == true

    o = Object.new
    EqualMatcher.new(o).matches?(o).should == true
  end

  it "does not match when actual is not a equal? to expected" do
    EqualMatcher.new(1).matches?(1.0).should == false
    EqualMatcher.new("blue").matches?("blue").should == false
    EqualMatcher.new(Hash).matches?(Object).should == false
  end

  it "provides a useful failure message" do
    matcher = EqualMatcher.new("red")
    matcher.matches?("red")
    matcher.failure_message.should == ["Expected \"red\"\n", "to be identical to \"red\"\n"]
  end

  it "provides a useful negative failure message" do
    matcher = EqualMatcher.new(1)
    matcher.matches?(1)
    matcher.negative_failure_message.should == ["Expected 1\n", "not to be identical to 1\n"]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/matchers/equal_spec.rb
mspec-1.9.0 spec/matchers/equal_spec.rb
mspec-1.8.0 spec/matchers/equal_spec.rb
mspec-1.7.0 spec/matchers/equal_spec.rb
mspec-1.6.0 spec/matchers/equal_spec.rb
mspec-1.5.21 spec/matchers/equal_spec.rb