Sha256: ac6a9768d3183d8c4dca7e451110b3fa80cee09a40f71c905f8f6a91c463dc11

Contents?: true

Size: 829 Bytes

Versions: 34

Compression:

Stored size: 829 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 ExplicitScoper;end
module Autoscope
  def instance_eval(*args, &block)
    return super unless low_level_c_spec? && !explicitly_defines_scope?
    V8::C::Locker() do
      V8::C::HandleScope() do
        @cxt = V8::C::Context::New()
        begin
          @cxt.Enter()
          super(*args, &block)
        ensure
          @cxt.Exit()
        end
      end
    end
  end

  def low_level_c_spec?
    return false unless described_class
    described_class.name =~ /^V8::C::/
  end

  def explicitly_defines_scope?
    is_a?(ExplicitScoper)
  end
end

RSpec.configure do |c|
  c.before(:each) do
    extend Autoscope
  end
end

Version data entries

34 entries across 34 versions & 7 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/therubyracer-0.12.2/spec/spec_helper.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/therubyracer-0.11.4/spec/spec_helper.rb
therubyracer-tmpfork-0.12.2 spec/spec_helper.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/therubyracer-0.12.2/spec/spec_helper.rb
therubyracer-0.12.2 spec/spec_helper.rb
therubyracer-0.12.1 spec/spec_helper.rb
therubyracer-discourse-0.12.0 spec/spec_helper.rb
therubyracer-0.12.0 spec/spec_helper.rb
therubyracer-0.11.4 spec/spec_helper.rb
therubyracer-0.11.3 spec/spec_helper.rb
therubyracer-0.11.2 spec/spec_helper.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.0/spec/spec_helper.rb
therubyracer-0.11.1 spec/spec_helper.rb
therubyracer-0.11.1beta1 spec/spec_helper.rb
therubyracer-0.11.0 spec/spec_helper.rb
therubyracer-0.11.0beta8-x86-freebsd-9 spec/spec_helper.rb
therubyracer-0.11.0beta8-x86_64-linux spec/spec_helper.rb
therubyracer-0.11.0beta8-x86-linux spec/spec_helper.rb
therubyracer-0.11.0beta8 spec/spec_helper.rb
therubyracer-0.11.0beta7-x86_64-linux spec/spec_helper.rb