1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'mspec/expectations/expectations'
3 require 'mspec/matchers/include'
5 describe IncludeMatcher do
6 it "matches when actual includes expected" do
7 IncludeMatcher.new(2).matches?([1,2,3]).should == true
8 IncludeMatcher.new("b").matches?("abc").should == true
11 it "does not match when actual does not include expected" do
12 IncludeMatcher.new(4).matches?([1,2,3]).should == false
13 IncludeMatcher.new("d").matches?("abc").should == false
16 it "matches when actual includes all expected" do
17 IncludeMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
18 IncludeMatcher.new("a", "b", "c").matches?("abc").should == true
21 it "does not match when actual does not include all expected" do
22 IncludeMatcher.new(3, 2, 4).matches?([1,2,3]).should == false
23 IncludeMatcher.new("a", "b", "c", "d").matches?("abc").should == false
26 it "provides a useful failure message" do
27 matcher = IncludeMatcher.new(5, 2)
28 matcher.matches?([1,2,3])
29 matcher.failure_message.should == ["Expected [1, 2, 3]", "to include 5"]
32 it "provides a useful negative failure message" do
33 matcher = IncludeMatcher.new(1, 2, 3)
34 matcher.matches?([1,2,3])
35 matcher.negative_failure_message.should == ["Expected [1, 2, 3]", "not to include 3"]