Sha256: 4f9d3ba0b1fea379c57b0b4597727e7f810329785782ab92a463dcd862910a42

Contents?: true

Size: 688 Bytes

Versions: 2

Compression:

Stored size: 688 Bytes

Contents

class ArraySubclassSpec < Array
  def add_val(val)
    `this.push(val)`
    self
  end

  def foo
    :bar
  end
end

describe "Array subclasses" do
  it "should have their defined methods present on instances" do
    ArraySubclassSpec.new.foo.should == :bar
  end

  it "should correctly keep their length" do
    arr = ArraySubclassSpec.new
    arr.add_val :foo
    arr.length.should == 1
  end

  it "should have the correct class" do
    ArraySubclassSpec.new.class.should == ArraySubclassSpec
    Array.new.class.should == Array
  end

  it "is just an instance of the bridged constructor" do
    arr = ArraySubclassSpec.new
    `(arr.constructor === Array)`.should == true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-0.3.20 test/opal/array/subclassing_spec.rb
opal-0.3.19 test/opal/array/subclassing_spec.rb