Created
September 11, 2012 17:42
-
-
Save cbartlett/3700171 to your computer and use it in GitHub Desktop.
Better hash match
This file contains 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
# I want to have better messaging, diffs, etc. here | |
RSpec::Matchers.define :include_hash do |expected| | |
match do |actual| | |
binding.pry | |
!expected.map {|k,v| actual[k] == v }.include?(false) | |
end | |
failure_message_for_should do |actual| | |
"expected that #{actual} would include all the key/values of #{expected}" | |
end | |
failure_message_for_should_not do |actual| | |
"expected that #{actual} would not include all the key/values of #{expected}" | |
end | |
description do | |
"include all the key/values of #{expected}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment