Assert with serializer class

This commit is contained in:
Tema Bolshakov
2014-08-20 12:34:34 +04:00
parent 865ab64025
commit c5d9d97f26
2 changed files with 41 additions and 28 deletions

View File

@@ -15,6 +15,11 @@ module ActionController
tests MyController
def test_supports_specifying_serializers_with_a_serializer_class
get :render_using_serializer
assert_serializer ProfileSerializer
end
def test_supports_specifying_serializers_with_a_regexp
get :render_using_serializer
assert_serializer %r{\AProfile.+\Z}
@@ -43,12 +48,13 @@ module ActionController
assert_match 'expecting <"PostSerializer"> but rendering with <["ProfileSerializer"]>', e.message
end
def test_raises_argument_error_when_asserting_with_invalid_object
get :render_using_serializer
e = assert_raise ArgumentError do
assert_serializer OpenStruct.new
assert_serializer Hash
end
assert_match 'assert_serializer only accepts a String, Symbol, Regexp, or nil', e.message
assert_match 'assert_serializer only accepts a String, Symbol, Regexp, ActiveModel::Serializer, or nil', e.message
end
end
end