Sha256: 1d70778dc40e22ec12933930d80da4d0598146608e853f9e60ab8ab5b68ed7b5

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

require 'v8'

def run_v8_gc
  V8::C::V8::LowMemoryNotification()
  while !V8::C::V8::IdleNotification() do
  end
end

def rputs(msg)
  puts "<pre>#{ERB::Util.h(msg)}</pre>"
  $stdout.flush
end

module V8ContextHelpers
  module GroupMethods
    def requires_v8_context
      around(:each) do |example|
        bootstrap_v8_context(&example)
      end
    end
  end

  def bootstrap_v8_context
    V8::C::Locker() do
      V8::C::HandleScope() do
        @cxt = V8::C::Context::New()
        begin
          @cxt.Enter()
          yield
        ensure
          @cxt.Exit()
        end
      end
    end
  end
end

RSpec.configure do |c|
  c.include V8ContextHelpers
  c.extend V8ContextHelpers::GroupMethods
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
therubyracer-xcode-0.12.3 spec/spec_helper.rb
therubyracer-xcode-0.12.2 spec/spec_helper.rb