Created
May 9, 2012 19:49
-
-
Save nicksieger/2648327 to your computer and use it in GitHub Desktop.
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
RSpec::Matchers.define :have_jsonish_contents do |expected| | |
def matches_at_this_level?(exp, act) | |
if exp.respond_to?(:to_a) && act.respond_to?(:to_a) | |
exp_arr = exp.to_a | |
act_arr = act.to_a | |
return false if exp_arr.length != act_arr.length | |
exp_arr.each_with_index do |elem,i| | |
return false unless matches_at_this_level?(elem, act_arr[i]) | |
end | |
return true | |
else | |
return exp == act | |
end | |
end | |
match do |actual| | |
matches_at_this_level?(expected, actual) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment