Sha256: 41411c857e2cbd2bc4dcd035ff223e5291feb3f171d500331ab0b6f38bf0dc13

Contents?: true

Size: 633 Bytes

Versions: 9

Compression:

Stored size: 633 Bytes

Contents

RSpec::Matchers.define :be_different_array_from do |x|
  match do |actual|
    perform_match(actual, expected_as_array)
    @extra + @missing != []
  end

  def perform_match(actual, expected)
    @extra = actual - expected
    @missing = expected - actual
  end

  failure_message_for_should do |actual|
    "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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activefacts-1.6.0 spec/helpers/array_matcher.rb
activefacts-1.5.3 spec/helpers/array_matcher.rb
activefacts-1.5.2 spec/helpers/array_matcher.rb
activefacts-1.5.1 spec/helpers/array_matcher.rb
activefacts-1.5.0 spec/helpers/array_matcher.rb
activefacts-1.3.0 spec/helpers/array_matcher.rb
activefacts-1.2.1 spec/helpers/array_matcher.rb
activefacts-1.2.0 spec/helpers/array_matcher.rb
activefacts-1.1.0 spec/helpers/array_matcher.rb