Sha256: 1eae919595644f76d6e3adfa3d44d38665064aec6abb056622d504739a85392d

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

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

describe EqlMatcher do
  it "matches when actual is eql? to expected" do
    EqlMatcher.new(1).matches?(1).should == true
    EqlMatcher.new(1.5).matches?(1.5).should == true
    EqlMatcher.new("red").matches?("red").should == true
    EqlMatcher.new(:blue).matches?(:blue).should == true
    EqlMatcher.new(Object).matches?(Object).should == true

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

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

  it "provides a useful failure message" do
    matcher = EqlMatcher.new("red")
    matcher.matches?("red")
    matcher.failure_message.should == ["Expected \"red\"\n", "to have same value and type as \"red\"\n"]
  end

  it "provides a useful negative failure message" do
    matcher = EqlMatcher.new(1)
    matcher.matches?(1.0)
    matcher.negative_failure_message.should == ["Expected 1.0\n", "not to have same value or type as 1\n"]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/matchers/eql_spec.rb
mspec-1.9.0 spec/matchers/eql_spec.rb
mspec-1.8.0 spec/matchers/eql_spec.rb
mspec-1.7.0 spec/matchers/eql_spec.rb
mspec-1.6.0 spec/matchers/eql_spec.rb
mspec-1.5.21 spec/matchers/eql_spec.rb
mspec-1.5.20 spec/matchers/eql_spec.rb
mspec-1.5.19 spec/matchers/eql_spec.rb
mspec-1.5.18 spec/matchers/eql_spec.rb