Skip to content

Instantly share code, notes, and snippets.

@cowboyd
Created June 3, 2010 11:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowboyd/423788 to your computer and use it in GitHub Desktop.
Save cowboyd/423788 to your computer and use it in GitHub Desktop.
require 'v8/jasmine'
require 'time'
require 'erb'
module JasmineMate
def self.start
start = Time.now
begin
cxt = V8::Jasmine::Context.new
env = cxt['jasmine'].getEnv()
env.addReporter(Reporter.new)
cxt.eval($stdin, ENV['TM_SELECTED_FILE'])
env.execute()
finish = Time.now
puts "finished in #{finish - start} seconds"
rescue V8::JavascriptError => e
$stderr.puts e.javascript_stacktrace
rescue Exception => e
$stderr.puts e.message
end
end
class Reporter
def reportRunnerResults(runner)
results = runner.results()
say "#{results.totalCount} examples, #{results.failedCount} failures."
end
def reportSpecResults(spec)
say((spec.results.passed ? "." : "F"), false)
end
def log(str)
# say str
end
def say(msg, newline = true)
escaped = ERB::Util.h(msg)
puts(newline ? "<div>#{escaped}</div>" : escaped)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment