Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.