Sha256: 0da864a5c43ec6c77bee8ff64a88c377cc92406581f0ce08953c2615e433a4b1
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module RSpec module Matchers class ArrayMatcher < Matcher def initialize expected super(:be_different_array_from, expected) do |*_expected| match_for_should do |actual| perform_match(actual, _expected[0]) @extra + @missing != [] end match_for_should_not do |actual| perform_match(actual, _expected[0]) @extra + @missing == [] end def perform_match(actual, expected) @extra = actual - expected @missing = expected - actual end def failure_message_for_should "expected a difference in the two lists, but got none" end failure_message_for_should_not do |actual| "expected no difference, but result #{ [ (@missing.empty? ? nil : 'lacks '+@missing.sort.inspect), (@extra.empty? ? nil : 'has extra '+@extra.sort.inspect) ].compact * ' and ' }" end end end end def be_different_array_from(expected) ArrayMatcher.new(expected) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activefacts-0.8.10 | spec/helpers/array_matcher.rb |