String#unpack overhaul. NO extra methods littered through Fixnum/Integer/String....
[rbx.git] / mspec / spec / matchers / include_spec.rb
blobcd68520d56a632fb367f78573794b9e8872a0d60
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
9   end
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
14   end
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
19   end
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
24   end
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"]
30   end
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"]
36   end
37 end