Skip to content

Instantly share code, notes, and snippets.

@xnzac
Created July 22, 2014 17:58
Show Gist options
  • Save xnzac/a42e16e4f38270c28f2e to your computer and use it in GitHub Desktop.
Save xnzac/a42e16e4f38270c28f2e to your computer and use it in GitHub Desktop.
RSpec2 custom matcher for DiffMatcher gem
require 'diff_matcher'
RSpec::Matchers.define :be_hash_matching do |expected|
match do |actual|
opts = {:color_enabled=>RSpec::configuration.color_enabled?}
@difference = DiffMatcher::Difference.new(expected, actual, opts)
@difference.matching?
end
failure_message_for_should do |actual|
@difference.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment