Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add failing test for nested children with 0 children

  • Loading branch information...
commit 30ff46b4a6cde39bb3106822de476dd68805b88d 1 parent 133e4f1
@nragaz nragaz authored
Showing with 34 additions and 0 deletions.
  1. +3 −0  Gemfile
  2. +20 −0 Gemfile.lock
  3. +11 −0 test/jbuilder_test.rb
View
3  Gemfile
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+
+gemspec
View
20 Gemfile.lock
@@ -0,0 +1,20 @@
+PATH
+ remote: .
+ specs:
+ jbuilder (0.3)
+ activesupport (>= 3.0.0)
+ blankslate (>= 2.1.2.4)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ blankslate (2.1.2.4)
+ multi_json (1.0.4)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ jbuilder!
View
11 test/jbuilder_test.rb
@@ -111,6 +111,17 @@ def initialize(name, age)
end
end
+ test "nesting multiple children from array when empty" do
+ comments = []
+
+ json = Jbuilder.encode do |json|
+ json.comments comments, :content
+ end
+
+ JSON.parse(json).tap do |parsed|
+ assert_equal [], parsed["comments"]
+ end
+ end
test "nesting multiple children from array with inline loop" do
comments = [ Struct.new(:content, :id).new("hello", 1), Struct.new(:content, :id).new("world", 2) ]
Please sign in to comment.
Something went wrong with that request. Please try again.