Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for new vs. old JSON output

should also help with any hash key changes
in the future
  • Loading branch information...
commit 82c9d183528b86ae68b31344a138b5f815efb6b6 1 parent 1de83e9
@presidentbeef authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 test/tests/test_differ.rb
View
34 test/tests/test_differ.rb
@@ -81,4 +81,38 @@ def test_line_number_change_only
assert_new 0
assert_fixed 0
end
+
+ def test_new_vs_old_warning_keys_same_warnings
+ new_keys = [:warning_code, :fingerprint, :render_path]
+
+ new = @warnings
+ old = @warnings.map do |warning|
+ warning.to_hash.reject do |k, v|
+ new_keys.include? k
+ end
+ end
+
+ diff new, old
+ assert_fixed 0
+ assert_new 0
+ end
+
+ def test_new_vs_old_warning_keys_changed_warning
+ new_keys = [:warning_code, :fingerprint, :render_path]
+
+ new = @warnings
+ old = @warnings.map do |warning|
+ warning.to_hash.reject do |k, v|
+ new_keys.include? k
+ end
+ end
+
+ changed = new.pop.to_hash
+ changed[:message] += "message has changed!"
+ new << changed #check for new warning with different message
+
+ diff new, old
+ assert_fixed 1
+ assert_new 1
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.