1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/spec/c_spec_helper.rb

35 lines
605 B
Ruby
Raw Normal View History

require 'v8/weak'
2015-07-16 21:55:31 -05:00
require 'v8/c/maybe'
require 'v8/init'
module V8ContextHelpers
module GroupMethods
def requires_v8_context
around(:each) do |example|
bootstrap_v8_context(&example)
end
end
end
def bootstrap_v8_context
@isolate = V8::C::Isolate.New
2015-03-21 20:27:06 +00:00
V8::C::HandleScope(@isolate) do
2015-04-04 18:23:23 +00:00
@ctx = V8::C::Context::New(@isolate)
begin
2015-04-04 18:23:23 +00:00
@ctx.Enter
yield
ensure
2015-04-04 18:23:23 +00:00
@ctx.Exit
2015-03-21 20:27:06 +00:00
end
end
ensure
@isolate.Dispose()
end
end
RSpec.configure do |c|
c.include V8ContextHelpers
c.extend V8ContextHelpers::GroupMethods
end