Sha256: b4cf8404a8a5bbc706a2639ab283aff844ff7213a029263fc1101d47f9666417

Contents?: true

Size: 564 Bytes

Versions: 6

Compression:

Stored size: 564 Bytes

Contents

# backtick_javascript: true

require 'native'

describe "Class#native_alias" do
  it "exposes a method to javascript without the '$' prefix" do
    klass = Class.new {
      def a
        2
      end

      native_alias :a, :a
    }
    instance = klass.new
    `instance.a()`.should == 2
  end

  it "raises if the aliased method isn't defined" do
    Class.new do
      lambda {
        native_alias :a, :not_a_method
      }.should raise_error(
        NameError,
        %r{undefined method `not_a_method' for class `#<Class:0x\w+>'}
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/opal/stdlib/native/native_alias_spec.rb
opal-1.8.2 spec/opal/stdlib/native/native_alias_spec.rb
opal-1.8.1 spec/opal/stdlib/native/native_alias_spec.rb
opal-1.8.0 spec/opal/stdlib/native/native_alias_spec.rb
opal-1.8.0.beta1 spec/opal/stdlib/native/native_alias_spec.rb
opal-1.8.0.alpha1 spec/opal/stdlib/native/native_alias_spec.rb