test_json_compare.rb 657 字节
Newer Older
J
Justin Collins 已提交
1 2 3 4 5 6 7 8
class JSONCompareTests < Test::Unit::TestCase
  include BrakemanTester::DiffHelper

  def setup
    @path = File.expand_path "#{TEST_PATH}/apps/rails3.2"
    @json_path = File.join @path, "report.json"
    File.delete @json_path if File.exist? @json_path
    Brakeman.run :app_path => @path, :output_files => [@json_path]
9
    @report = MultiJson.load File.read(@json_path)
J
Justin Collins 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  end

  def update_json
    File.open @json_path, "w" do |f|
      f.puts @report.to_json
    end
  end

  def diff
    @diff = Brakeman.compare :app_path => @path, :previous_results_json => @json_path
  end

  def test_sanity
    diff

    assert_fixed 0
    assert_new 0
  end
end