Sha256: 30d49400f3ba111fb095b8aaef90fe9312b73c1f931960805a177d898e212211

Contents?: true

Size: 892 Bytes

Versions: 9

Compression:

Stored size: 892 Bytes

Contents

require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'

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

9 entries across 9 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/matchers/be_ancestor_of_spec.rb
mspec-1.9.0 spec/matchers/be_ancestor_of_spec.rb
mspec-1.8.0 spec/matchers/be_ancestor_of_spec.rb
mspec-1.7.0 spec/matchers/be_ancestor_of_spec.rb
mspec-1.6.0 spec/matchers/be_ancestor_of_spec.rb
mspec-1.5.21 spec/matchers/be_ancestor_of_spec.rb
mspec-1.5.20 spec/matchers/be_ancestor_of_spec.rb
mspec-1.5.19 spec/matchers/be_ancestor_of_spec.rb
mspec-1.5.18 spec/matchers/be_ancestor_of_spec.rb