Permalink
Browse files

fix test for custom serializer, add test for :each_serializer

  • Loading branch information...
1 parent 0832e42 commit 84c7cfa988b9c65d6d05f7aa3ed817ed96c625d2 @teeparham teeparham committed Jul 15, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 test/serialization_test.rb
View
@@ -136,8 +136,14 @@ def render_json_with_serializer_api_but_without_serializer
render :json => JsonSerializable.new(true)
end
+ # To specify a custom serializer for an object, use :serializer.
def render_json_with_custom_serializer
- render :json => [], :serializer => CustomSerializer
+ render :json => Object.new, :serializer => CustomSerializer
+ end
+
+ # To specify a custom serializer for each item in the Array, use :each_serializer.
+ def render_json_array_with_custom_serializer
+ render :json => [Object.new], :each_serializer => CustomSerializer
end
def render_json_with_links
@@ -263,6 +269,11 @@ def test_render_json_with_custom_serializer
assert_match '{"hello":true}', @response.body
end
+ def test_render_json_array_with_custom_serializer
+ get :render_json_array_with_custom_serializer
+ assert_match '{"test":[{"hello":true}]}', @response.body
+ end
+
def test_render_json_with_links
get :render_json_with_links
assert_match '{"link":"http://www.nextangle.com/hypermedia"}', @response.body

0 comments on commit 84c7cfa

Please sign in to comment.