Class: Railscheck::Test::SyntaxCheckRuby

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

Instance Method Summary collapse

Methods inherited from Railscheck::TestCase

#default_test

Instance Method Details

#parse(code, fname) ⇒ Object



16
17
18
19
20
# File 'lib/test/tc_syntax_check_ruby.rb', line 16

def parse(code, fname)
  eval("BEGIN {return ''}\n#{code}", nil, fname, 0)
  rescue SyntaxError => ex
  ex.message
end

#test_all_ruby_can_parseObject

Test that every ruby file in the project can parse (except vendor plugins/rails) incl. rake and rjs varints.



7
8
9
10
11
12
13
14
# File 'lib/test/tc_syntax_check_ruby.rb', line 7

def test_all_ruby_can_parse  
  (Dir["#{RAILS_ROOT}/**/*.rb", "#{RAILS_ROOT}/**/*.rake", "#{RAILS_ROOT}/**/*.rjs"]-Dir["#{RAILS_ROOT}/vendor/**/*.*"]-version_control_excludes).each do |fname|
    #puts "CHECKING FILE "+fname
    ruby_code = get_file_as_string(fname)
    first_error = parse(ruby_code, fname)
    assert_equal '', first_error, first_error
  end
end