Sha256: 94dd85e80f1f2e290578fb34a77fa5d8422c09ff15487fbc42cd5e6eb64f192d
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' describe "Tomato bound objects" do subject { Tomato.new } class ::TestObject attr_accessor :i def initialize; @i = 1; end def ==(other) other.kind_of?(TestObject) end end it "should map attribute getters to corresponding Ruby methods" do subject.bind_object(TestObject, "TO") subject.run('var v = new TO(); v.i;').should == 1 end it "should map attribute setters to corresponding Ruby methods" do subject.bind_object(TestObject, "TO") result = subject.run('var v = new TO(); v.i = 5; v;') result.i.should == 5 end it "should be bind-able with an explicit chain" do subject.bind_object(TestObject, "TO") proc { subject.run("new TO();") }.should_not raise_error end it "should be instantiatable" do subject.bind_object(TestObject) subject.run("new TestObject();").should == TestObject.new end it "should not lose sub-objects" do subject.bind_object("hello", "TestObject.string") subject.bind_object(TestObject) subject.run("TestObject.string.inspect()").should == '"hello"' end it "should allow sub-bindings" do subject.bind_object(TestObject) subject.bind_object("hello", "TestObject.string") subject.run("TestObject.string.inspect()").should == '"hello"' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tomato-0.0.1.prealpha2 | spec/lib/bound_class_spec.rb |