Commit 6709fd8f8313df82d8a4452776f4449d2df66aae
Committed by
Rodrigo Souto
1 parent
8b39ad22
Exists in
master
and in
21 other branches
Add test helper to compare hashes
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
test/test_helper.rb
| ... | ... | @@ -270,6 +270,19 @@ module NoosferoTestHelper |
| 270 | 270 | '' |
| 271 | 271 | end |
| 272 | 272 | |
| 273 | + # make a string from ordered hash to simplify tests | |
| 274 | + def h2s(value) | |
| 275 | + case value | |
| 276 | + when Hash, HashWithIndifferentAccess | |
| 277 | + '{'+ value.stringify_keys.to_a.sort{|a,b|a[0]<=>b[0]}.map{ |k,v| k+':'+h2s(v) }.join(',') +'}' | |
| 278 | + when Array | |
| 279 | + '['+ value.map{|i|h2s(i)}.join(',') +']' | |
| 280 | + when NilClass | |
| 281 | + '<nil>' | |
| 282 | + else value.to_s | |
| 283 | + end | |
| 284 | + end | |
| 285 | + | |
| 273 | 286 | end |
| 274 | 287 | |
| 275 | 288 | class ActionController::IntegrationTest | ... | ... |