Sha256: e6de52ee1b500c2c3b1c2d2b8288b1125fc373c94e7760f5b6284ee6b34f3d13

Contents?: true

Size: 936 Bytes

Versions: 25

Compression:

Stored size: 936 Bytes

Contents

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

class Parent; end
class Child < Parent; end

describe BeAncestorOfMatcher do
  it "matches when actual is an ancestor of expected" do
    BeAncestorOfMatcher.new(Child).matches?(Parent).should == true
  end

  it "does not match when actual is not an ancestor of expected" do
    BeAncestorOfMatcher.new(Parent).matches?(Child).should == false
  end

  it "provides a useful failure message" do
    matcher = BeAncestorOfMatcher.new(Parent)
    matcher.matches?(Child)
    matcher.failure_message.should == ["Expected Child", "to be an ancestor of Parent"]
  end

  it "provides a useful negative failure message" do
    matcher = BeAncestorOfMatcher.new(Child)
    matcher.matches?(Parent)
    matcher.negative_failure_message.should == ["Expected Parent", "not to be an ancestor of Child"]
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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