diff --git a/test/test_filters.rb b/test/test_filters.rb index f12fc171..ed14f9e1 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -148,13 +148,24 @@ class TestFilters < Test::Unit::TestCase assert_equal "[{\"name\":\"Jack\"},{\"name\":\"Smith\"}]", @filter.jsonify([{:name => 'Jack'}, {:name => 'Smith'}]) end - should "call #to_liquid " do - class AThing < Struct.new(:name) - def to_liquid - { "name" => name, :v => 1 } - end + class M < Struct.new(:message) + def to_liquid + [message] end - assert_equal "[{\"name\":\"Jeremiah\",\"v\":1},{\"name\":\"Smathers\",\"v\":1}]", @filter.jsonify([AThing.new("Jeremiah"), AThing.new("Smathers")]) + end + class T < Struct.new(:name) + def to_liquid + { "name" => name, :v => 1, :thing => M.new({:kay => "jewelers"}) } + end + end + + should "call #to_liquid " do + assert_equal "[{\"name\":\"Jeremiah\",\"v\":1},{\"name\":\"Smathers\",\"v\":1}]", @filter.jsonify([T.new("Jeremiah"), T.new("Smathers")]) + end + + should "handle hashes with all sorts of weird keys and values" do + my_hash = { "posts" => Array.new(5) { |i| T.new(i) } } + assert_equal "{}", @filter.jsonify(my_hash) end end