Sha256: 6b8e34bdcac56e571c5eae8784e019d8ced67bf175a94d27d25aa73d9fe466b3

Contents?: true

Size: 804 Bytes

Versions: 4

Compression:

Stored size: 804 Bytes

Contents

require File.expand_path('../spec_helper', __FILE__)

describe Native::Object do
	before do
		@object = `{
			a: 42,

			b: function () {
				return 42;
			},

			c: function () {
				return { a: 23 };
			},

			d: function (a, h) {
				return h({a: a});
			}
		}`

		@test = Kernel.Native(@object)
	end

	it 'wraps an object properly' do
		`#{@test.to_native} == #{@object}`.should be_true
	end

	it 'makes an accessor properly' do
		@test.a.should == 42
		@test.a = 23
		@test.a.should == 23
		`#@object.a`.should == 23
	end

	it 'calls a function as a method when present' do
		@test.b.should == 42
	end

	it 'calls a function as a method when present and returns a Native' do
		@test.c.a.should == 23
	end

	it 'calls handlers with proper wrapping' do
		@test.d(23) { |o| o.a }.should == 23
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-native-0.0.4.2 spec/object_spec.rb
opal-native-0.0.4.1 spec/object_spec.rb
opal-native-0.0.4 spec/object_spec.rb
opal-native-0.0.3 spec/object_spec.rb