Skip to content

Commit

Permalink
Add tests for new vs. old JSON output
Browse files Browse the repository at this point in the history
should also help with any hash key changes
in the future
  • Loading branch information
presidentbeef committed Mar 5, 2013
1 parent 1de83e9 commit 82c9d18
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/tests/test_differ.rb
Expand Up @@ -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

0 comments on commit 82c9d18

Please sign in to comment.