Skip to content

Commit

Permalink
add failing test for nested children with 0 children
Browse files Browse the repository at this point in the history
  • Loading branch information
nragaz committed Dec 10, 2011
1 parent 133e4f1 commit 30ff46b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
@@ -0,0 +1,3 @@
source "http://rubygems.org"

gemspec
20 changes: 20 additions & 0 deletions 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!
11 changes: 11 additions & 0 deletions test/jbuilder_test.rb
Expand Up @@ -111,6 +111,17 @@ def initialize(name, age)
end end
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 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) ] comments = [ Struct.new(:content, :id).new("hello", 1), Struct.new(:content, :id).new("world", 2) ]
Expand Down

0 comments on commit 30ff46b

Please sign in to comment.