Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add array iteration test.

  • Loading branch information...
commit 08ba26e9295d69c09ecc0ed76c1346b98e52a066 1 parent f1d47fe
@cowboyd cowboyd authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 jsapi_spec.rb
View
9 jsapi_spec.rb
@@ -81,6 +81,15 @@
end
end
+ it "can iterate over arrays" do
+ @cxt['a'] = @cxt.eval('[{num: 1},{num:2},{num:3},{num: 4}]')
+ a = @cxt['a']
+ a.inject(0) do |sum, item|
+ sum + item['num']
+ end.should == 10
+
+ end
+
it "converts ruby hashes to javascript objects" do
@cxt['h'] = {:foo => 'bar', :baz => 'bang', :bar => {'hello' => 'world'}}
@cxt['h']['foo'].should == 'bar'
Please sign in to comment.
Something went wrong with that request. Please try again.