Sha256: 7ad4db4b3eb0f465b36e7cfdfe582359bc23fb91ea80f610f360154d766c2714

Contents?: true

Size: 1.32 KB

Versions: 25

Compression:

Stored size: 1.32 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers/include'

describe IncludeMatcher do
  it "matches when actual includes expected" do
    IncludeMatcher.new(2).matches?([1,2,3]).should == true
    IncludeMatcher.new("b").matches?("abc").should == true
  end

  it "does not match when actual does not include expected" do
    IncludeMatcher.new(4).matches?([1,2,3]).should == false
    IncludeMatcher.new("d").matches?("abc").should == false
  end

  it "matches when actual includes all expected" do
    IncludeMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
    IncludeMatcher.new("a", "b", "c").matches?("abc").should == true
  end

  it "does not match when actual does not include all expected" do
    IncludeMatcher.new(3, 2, 4).matches?([1,2,3]).should == false
    IncludeMatcher.new("a", "b", "c", "d").matches?("abc").should == false
  end

  it "provides a useful failure message" do
    matcher = IncludeMatcher.new(5, 2)
    matcher.matches?([1,2,3])
    matcher.failure_message.should == ["Expected [1, 2, 3]", "to include 5"]
  end

  it "provides a useful negative failure message" do
    matcher = IncludeMatcher.new(1, 2, 3)
    matcher.matches?([1,2,3])
    matcher.negative_failure_message.should == ["Expected [1, 2, 3]", "not to include 3"]
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
mspec-1.5.17 spec/matchers/include_spec.rb
mspec-1.5.16 spec/matchers/include_spec.rb
mspec-1.5.15 spec/matchers/include_spec.rb
mspec-1.5.14 spec/matchers/include_spec.rb
mspec-1.5.13 spec/matchers/include_spec.rb
mspec-1.0.0 spec/matchers/include_spec.rb
mspec-1.1.0 spec/matchers/include_spec.rb
mspec-1.5.2 spec/matchers/include_spec.rb
mspec-1.2.0 spec/matchers/include_spec.rb
mspec-1.3.0 spec/matchers/include_spec.rb
mspec-1.5.11 spec/matchers/include_spec.rb
mspec-1.5.12 spec/matchers/include_spec.rb
mspec-1.5.10 spec/matchers/include_spec.rb
mspec-1.4.0 spec/matchers/include_spec.rb
mspec-1.3.1 spec/matchers/include_spec.rb
mspec-1.5.0 spec/matchers/include_spec.rb
mspec-1.1.1 spec/matchers/include_spec.rb
mspec-1.5.1 spec/matchers/include_spec.rb
mspec-1.5.3 spec/matchers/include_spec.rb
mspec-1.5.4 spec/matchers/include_spec.rb