Created
March 1, 2016 21:36
-
-
Save jbnv/0f8ac9531fff4671334c to your computer and use it in GitHub Desktop.
A function that goes in Ruby unit tests to check an array of hashes by property. Supply a list of symbols to check.
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
def compare_arrays_of_hashes(expected_array,actual_array,symbols) | |
expected_array.each_with_index do |expected,index| | |
actual = actual_array[index] | |
symbols.each do |symbol| | |
assert_equal expected[symbol],actual[symbol],"#{symbol} of element #{index} doesn't match" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment