Permalink
Browse files

Add specs for error_to_js

  • Loading branch information...
1 parent 458a10b commit 8713fb71bd5dee28945927bd9275a897c07c687d @netzpirat netzpirat committed Apr 23, 2012
Showing with 10 additions and 3 deletions.
  1. +1 −3 lib/guard/coffeescript/runner.rb
  2. +9 −0 spec/guard/coffeescript/runner_spec.rb
@@ -62,9 +62,7 @@ def compile_files(files, watchers, options)
error_message = file + ': ' + e.message.to_s
if options[:error_to_js]
- js_error_message = %q(#{error_message})
- js_error_message = "var message = \"#{error_message} \";"
- js_error_message += "throw message;"
+ js_error_message = "throw \"#{ error_message }\";"
changed_files << write_javascript_file(js_error_message, file, directory, options)
end
@@ -141,6 +141,15 @@
runner.run(['a.coffee'], [watcher], { :output => 'javascripts', :noop => true })
end
end
+
+ context 'with the :error_to_js option' do
+ it 'write the error message as javascript file' do
+ runner.should_receive(:compile).and_raise ::CoffeeScript::CompilationError.new("Parse error on line 2: Unexpected 'UNARY'")
+ runner.should_receive(:write_javascript_file).once.with("throw \"a.coffee: Parse error on line 2: Unexpected 'UNARY'\";", 'a.coffee', 'javascripts', kind_of(Hash))
+ runner.run(['a.coffee'], [watcher], { :output => 'javascripts', :error_to_js => true })
+ end
+
+ end
end
context 'without compilation errors' do

0 comments on commit 8713fb7

Please sign in to comment.