1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'mspec/expectations/expectations'
3 require 'mspec/matchers/eql'
6 it "matches when actual is eql? to expected" do
7 EqlMatcher.new(1).matches?(1).should == true
8 EqlMatcher.new(1.5).matches?(1.5).should == true
9 EqlMatcher.new("red").matches?("red").should == true
10 EqlMatcher.new(:blue).matches?(:blue).should == true
11 EqlMatcher.new(Object).matches?(Object).should == true
14 EqlMatcher.new(o).matches?(o).should == true
17 it "does not match when actual is not eql? to expected" do
18 EqlMatcher.new(1).matches?(1.0).should == false
19 EqlMatcher.new(Hash).matches?(Object).should == false
22 it "provides a useful failure message" do
23 matcher = EqlMatcher.new("red")
24 matcher.matches?("red")
25 matcher.failure_message.should == ["Expected \"red\"\n", "to have same value and type as \"red\"\n"]
28 it "provides a useful negative failure message" do
29 matcher = EqlMatcher.new(1)
31 matcher.negative_failure_message.should == ["Expected 1.0\n", "not to have same value or type as 1\n"]