Sha256: f30290849f3c0c7acb0d01a36006bdecff0cc561a631213217002489c7ffffe5

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

require 'pathname'

module DiffMatcher
  class DifferFrom
    def initialize(expected)
      case expected
      when Pathname
        @matcher = FileMatcher::BeDifferentFile.new(expected)
      when Array
        @matcher = ArrayMatcher::BeDifferentArray.new(expected)
      when String
        @matcher = FileMatcher::BeDifferentFile.new(expected)
      else
        raise "DiffMatcher doesn't know how to match a #{expected.class}"
      end
    end

    def matches?(actual)
      @matcher.matches?(actual)
    end

    def failure_message
      @matcher.failure_message
    end

    def negative_failure_message
      @matcher.negative_failure_message
    end
  end

  def differ_from(expected)
    DifferFrom.new(expected)
  end
end

Spec::Runner.configure do |config|
  config.include(DiffMatcher)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activefacts-0.8.9 spec/helpers/diff_matcher.rb
activefacts-0.8.8 spec/helpers/diff_matcher.rb