1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'mspec/expectations/expectations'
3 require 'mspec/matchers/be_ancestor_of'
6 class Child < Parent; end
8 describe BeAncestorOfMatcher do
9 it "matches when actual is an ancestor of expected" do
10 BeAncestorOfMatcher.new(Child).matches?(Parent).should == true
13 it "does not match when actual is not an ancestor of expected" do
14 BeAncestorOfMatcher.new(Parent).matches?(Child).should == false
17 it "provides a useful failure message" do
18 matcher = BeAncestorOfMatcher.new(Parent)
19 matcher.matches?(Child)
20 matcher.failure_message.should == ["Expected Child", "to be an ancestor of Parent"]
23 it "provides a useful negative failure message" do
24 matcher = BeAncestorOfMatcher.new(Child)
25 matcher.matches?(Parent)
26 matcher.negative_failure_message.should == ["Expected Parent", "not to be an ancestor of Child"]