Sha256: b15bba021703f13b235c46fc973ad897cc86ace8d74e28142aece8f1daf6b2bf

Contents?: true

Size: 1.31 KB

Versions: 65

Compression:

Stored size: 1.31 KB

Contents

require "#{File.dirname(__FILE__)}/../spec_helper.rb"

include V8

describe C::Context do

  before {@lock = C::Locker.new}
  after {@lock.delete}

  it "should not have a current context if no context is open" do
    C::Context::GetEntered().should be_nil
  end

  it "can javascript properties on the global scope via ruby when the default scope is a ruby object" do
    V8::Context.new(:with => Object.new) do |cxt|
      cxt['foo'] = 'bar'
      cxt.eval('foo').should eql('bar')
    end
  end

  it "can get the current javascript execution stack" do
    V8::Context.new do |cxt|
      trace = nil
      cxt['getTrace'] = lambda do
        trace = V8::Context.stack
      end
      cxt.eval(<<-JS, 'trace.js')
      function one() {
        return two();
      }

      function two() {
        return three();
      }

      function three() {
        return getTrace()
      }
      one();
JS
      trace.length.should be(4)
      trace.to_a[0].tap do |frame|
        frame.line_number.should == 10
        frame.column.should == 16
        frame.script_name.should == 'trace.js'
        frame.function_name.should == 'three'
        frame.should_not be_eval
        frame.should_not be_constructor
      end
    end
  end

  it "has an empty stack if there is no enterned context" do
    V8::Context.stack.should be_empty
  end
end

Version data entries

65 entries across 65 versions & 5 rubygems

Version Path
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.8 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
therubyracer-freebsd-0.10.1 spec/ext/cxt_spec.rb
classiccms-0.3.7 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.6 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.5 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.4 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.3 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.2 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
classiccms-0.3.1 vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb
therubyracer-0.10.1 spec/ext/cxt_spec.rb
therubyracer-0.10.0 spec/ext/cxt_spec.rb
therubyracer-0.9.10 spec/ext/cxt_spec.rb
therubyracer-0.9.9 spec/ext/cxt_spec.rb
therubyracer-0.9.8 spec/ext/cxt_spec.rb
therubyracer-0.10.0beta1 spec/ext/cxt_spec.rb
therubyracer-0.9.7 spec/ext/cxt_spec.rb