|
93 | 93 | end |
94 | 94 | end |
95 | 95 |
|
96 | | - # xit "unwraps ruby objects returned by embedded ruby code to maintain referential integrity" do |
97 | | - # Object.new.tap do |o| |
98 | | - # @cxt['get'] = lambda {o} |
99 | | - # @cxt.eval('get()').should be(o) |
100 | | - # end |
101 | | - # end |
| 96 | + it "unwraps ruby objects returned by embedded ruby code to maintain referential integrity" do |
| 97 | + Object.new.tap do |o| |
| 98 | + @cxt['get'] = lambda {o} |
| 99 | + @cxt.eval('get()').should be(o) |
| 100 | + end |
| 101 | + end |
102 | 102 |
|
103 | 103 | it "always returns the same ruby object for a single javascript object" do |
104 | 104 | obj = @cxt.eval('obj = {}') |
|
133 | 133 | # end |
134 | 134 | end |
135 | 135 |
|
136 | | -# describe "Calling Ruby Code From Within Javascript", :compat => '0.1.0' do |
| 136 | + describe "Calling Ruby Code From Within Javascript" do |
137 | 137 |
|
138 | | -# before(:each) do |
| 138 | + before(:each) do |
139 | 139 | # @class = Class.new |
140 | 140 | # @instance = @class.new |
141 | | -# @cxt = V8::Context.new |
| 141 | + @cxt = V8::Context.new |
142 | 142 | # @cxt['o'] = @instance |
143 | | -# end |
| 143 | + end |
144 | 144 |
|
145 | | -# xit "can embed a closure into a context and call it" do |
146 | | -# @cxt["say"] = lambda { |*args| args[-2] * args[-1] } |
147 | | -# @cxt.eval("say('Hello', 2)").should == "HelloHello" |
148 | | -# end |
| 145 | + it "can embed a closure into a context and call it" do |
| 146 | + @cxt["say"] = lambda { |*args| args[-2] * args[-1] } |
| 147 | + @cxt.eval("say('Hello', 2)").should == "HelloHello" |
| 148 | + end |
149 | 149 |
|
150 | | -# xit "recognizes the same closure embedded into the same context as the same function object" do |
151 | | -# @cxt['say'] = @cxt['declare'] = lambda { |*args| args } |
152 | | -# @cxt.eval('say == declare').should be(true) |
153 | | -# @cxt.eval('say === declare').should be(true) |
154 | | -# end |
| 150 | + it "recognizes the same closure embedded into the same context as the same function object" do |
| 151 | + @cxt['say'] = @cxt['declare'] = lambda { |*args| args } |
| 152 | + @cxt.eval('say == declare').should be(true) |
| 153 | + @cxt.eval('say === declare').should be(true) |
| 154 | + end |
155 | 155 |
|
156 | 156 | # xit "translates ruby Array to Javascript Array" do |
157 | 157 | # class_eval do |
|
275 | 275 | # @cxt.eval('typeof(RObject)').should == 'function' |
276 | 276 | # end |
277 | 277 |
|
278 | | -# xit "truncates lambda arguments passed in to match the arity of the function", :compat => '0.4.2' do |
279 | | -# @cxt['testing'] = lambda { |arg| arg } |
280 | | -# lambda { |
281 | | -# @cxt.eval('testing(1,2,3)') |
282 | | -# }.should_not raise_error |
| 278 | + it "truncates lambda arguments passed in to match the arity of the function", :compat => '0.4.2' do |
| 279 | + @cxt['testing'] = lambda { |arg| arg } |
| 280 | + lambda { |
| 281 | + @cxt.eval('testing(1,2,3)') |
| 282 | + }.should_not raise_error |
283 | 283 |
|
284 | | -# @cxt['testing'] = lambda { } |
285 | | -# lambda { |
286 | | -# @cxt.eval('testing(1,2,3)') |
287 | | -# }.should_not raise_error |
288 | | -# end |
| 284 | + @cxt['testing'] = lambda { } |
| 285 | + lambda { |
| 286 | + @cxt.eval('testing(1,2,3)') |
| 287 | + }.should_not raise_error |
| 288 | + end |
289 | 289 |
|
290 | 290 | # xit "truncates method arguments passed in to match the arity of the function", :compat => '0.4.3' do |
291 | 291 | # @instance.instance_eval do |
|
652 | 652 | # @class.class_eval &body |
653 | 653 | # end |
654 | 654 |
|
655 | | -# end |
| 655 | + end |
656 | 656 |
|
657 | 657 | describe "Calling JavaScript Code From Within Ruby" do |
658 | 658 |
|
|
0 commit comments