diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index aa3f546..ac8b5df 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -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) diff --git a/test/fixtures/json_data.json b/test/fixtures/json_data.json new file mode 100644 index 0000000..75bfbfe --- /dev/null +++ b/test/fixtures/json_data.json @@ -0,0 +1,4 @@ +{ + "var1": "something", + "var2": "trailing comma", +} diff --git a/test/runner_test.rb b/test/runner_test.rb index a8f7861..3bc8ce8 100644 --- a/test/runner_test.rb +++ b/test/runner_test.rb @@ -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) diff --git a/test/test_helper.rb b/test/test_helper.rb index 9b733a5..63b38a8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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: