From 1d655bef7e0e19b252667df0e1f3fb732d2ea529 Mon Sep 17 00:00:00 2001 From: Justin Collins Date: Mon, 23 Jul 2012 17:29:04 -0700 Subject: [PATCH] Add a couple tests for annotations --- test/tests/test_annotations.rb | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/tests/test_annotations.rb diff --git a/test/tests/test_annotations.rb b/test/tests/test_annotations.rb new file mode 100644 index 00000000..a518e14a --- /dev/null +++ b/test/tests/test_annotations.rb @@ -0,0 +1,41 @@ +require 'tempfile' + +class AnnotationTests < Test::Unit::TestCase + TEST_APP = "#{TEST_PATH}/apps/rails2" + + def with_temp_file name + annotation_file = Tempfile.new name + annotation_file.close + + yield annotation_file + + annotation_file.unlink + end + + def test_annotations_with_format + with_temp_file 'annotation' do |file| + + original_report = Brakeman.run(:app_path => TEST_APP, + :output_format => :annotations, + :output_files => [file.path]) + + ignored_report = Brakeman.run(:app_path => TEST_APP, + :annotations_file => file.path) + + assert_equal 0, ignored_report.checks.all_warnings.length + end + end + + def test_annotations_with_file + with_temp_file ['annotation', '.annotations'] do |file| + + original_report = Brakeman.run(:app_path => TEST_APP, + :output_files => [file.path]) + + ignored_report = Brakeman.run(:app_path => TEST_APP, + :annotations_file => file.path) + + assert_equal 0, ignored_report.checks.all_warnings.length + end + end +end -- GitLab