Class: Railscheck::Test::SyntaxCheckXml

Inherits:
Railscheck::TestCase show all
Defined in:
lib/test/tc_xml.rb

Instance Method Summary collapse

Methods inherited from Railscheck::TestCase

#default_test

Instance Method Details

#test_all_xml_can_parseObject

Test that every xml file in the project can parse (except vendor plugins/rails).



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/test/tc_xml.rb', line 9

def test_all_xml_can_parse
  (Dir["#{RAILS_ROOT}/**/*.xml"]-Dir["#{RAILS_ROOT}/vendor/**/*.*"]-version_control_excludes).each do |fname|
    #puts "CHECKING FILE "+fname
    File.open(fname) do |file|
      assert_nothing_raised("Could not parse file \"#{fname}\".") do
        begin 
          doc = REXML::Document.new(file)
        rescue Exception => ex
           raise SyntaxError.new("Syntax error(s) in #{fname} at line #{ex.line}")
        end
      end
    end
  end
end