Created
July 22, 2014 17:58
-
-
Save xnzac/a42e16e4f38270c28f2e to your computer and use it in GitHub Desktop.
RSpec2 custom matcher for DiffMatcher gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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