jslint on json data

This commit is contained in:
Nick Gauthier 2010-05-28 10:42:17 -04:00
parent c7d7be6ed2
commit a69ae2e4ab
4 changed files with 17 additions and 3 deletions

View File

@ -35,11 +35,11 @@ module Hydra #:nodoc:
trace "Running file: #{file}"
output = ""
if file =~ /_spec.rb$/
if file =~ /_spec.rb$/i
output = run_rspec_file(file)
elsif file =~ /.feature$/
elsif file =~ /.feature$/i
output = run_cucumber_file(file)
elsif file =~ /.js$/
elsif file =~ /.js$/i or file =~ /.json$/i
output = run_javascript_file(file)
else
output = run_test_unit_file(file)

4
test/fixtures/json_data.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"var1": "something",
"var2": "trailing comma",
}

View File

@ -43,6 +43,12 @@ class RunnerTest < Test::Unit::TestCase
assert results =~ /Missing semicolon/
end
should "run a json data file and find errors" do
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
results = runner.run_file(json_file)
assert results =~ /trailing comma/
end
should "run two rspec tests" do
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
runner.run_file(rspec_file)

View File

@ -46,6 +46,10 @@ class Test::Unit::TestCase
def javascript_file
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'js_file.js'))
end
def json_file
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'json_data.json'))
end
end
module Hydra #:nodoc: