spec/serializer_spec.rb in jsonapi-serializers-0.6.2 vs spec/serializer_spec.rb in jsonapi-serializers-0.6.3
- old
+ new
@@ -845,6 +845,26 @@
}
}
})
end
end
+
+ describe 'include validation' do
+ it 'raises an exception when join character is invalid' do
+ expect do
+ JSONAPI::Serializer.serialize(create(:post), include: 'long_comments');
+ end.to raise_error(JSONAPI::Serializer::InvalidIncludeError)
+
+ expect do
+ JSONAPI::Serializer.serialize(create(:post), include: 'long-comments');
+ end.not_to raise_error
+
+ expect do
+ JSONAPI::Serializer.serialize(create(:underscore_test), include: 'tagged-posts');
+ end.to raise_error(JSONAPI::Serializer::InvalidIncludeError)
+
+ expect do
+ JSONAPI::Serializer.serialize(create(:underscore_test), include: 'tagged_posts');
+ end.not_to raise_error
+ end
+ end
end