Add some more tests, and properly handle errors across the boundary in tests

This commit is contained in:
wycats
2010-11-25 16:09:42 -08:00
parent 4624eddf0b
commit 7d0204bf9f
3 changed files with 35 additions and 8 deletions
+27
View File
@@ -1,5 +1,32 @@
require "v8"
# Monkey patches due to bugs in RubyRacer
class V8::JSError
def initialize(try, to)
@to = to
begin
super(initialize_unsafe(try))
rescue Exception => e
# Original code does not make an Array here
@boundaries = [Boundary.new(:rbframes => e.backtrace)]
@value = e
super("BUG! please report. JSError#initialize failed!: #{e.message}")
end
end
def parse_js_frames(try)
raw = @to.rb(try.StackTrace())
if raw && !raw.empty?
raw.split("\n")[1..-1].tap do |frames|
# Original code uses strip!, and the frames are not guaranteed to be strippable
frames.each {|frame| frame.strip.chomp!(",")}
end
else
[]
end
end
end
RSpec.configure do |config|
config.before(:all) do
@context = V8::Context.new