Sha256: 388c2d8bf73cc42287163c69ee1fce76a9ac07fd9e7b41bfd81c785141a4f5c4

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 Bytes

Contents

%x{
  var BridgeClassProto = function() {
    this.foo = 200;
  };

  BridgeClassProto.prototype = {
    bar: 300,
    baz: 400
  };
}

class BridgeClassSpec < `BridgeClassProto`
  def get_foo
    `this.foo`
  end

  def say_it
    "hello world"
  end
end

describe "Bridging native prototypes to a class" do
  it "should have a superclass of Object" do
    BridgeClassSpec.superclass.should == Object
  end

  it "should report instances as kind of bridged class" do
    obj = `new BridgeClassProto()`
    obj.should be_kind_of(BridgeClassSpec)
  end

  it "should have defined instance methods present on prototype" do
    obj = `new BridgeClassProto()`
    obj.get_foo.should == 200
    obj.say_it.should == "hello world"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-0.3.20 test/opal/class/bridge_class_spec.rb
opal-0.3.19 test/opal/class/bridge_class_spec.rb