Sha256: 3c3a0f8c91bcae6cb46118d9e7f456a673196c0541c21e3e84f89958a120200c
Contents?: true
Size: 1018 Bytes
Versions: 1
Compression:
Stored size: 1018 Bytes
Contents
require 'spec_helper' describe 'ArraySerializer' do let(:comments) { [comment_1, comment_2] } let(:comment_1) { Comment.new(text: 'a') } let(:comment_2) { Comment.new(text: 'b') } let(:post) { Post.new(name: 'c', body: 'd') } it 'renders csv using specified serializer' do array_serializer = ActiveModel::CsvArraySerializer.new( comments, each_serializer: CommentCsvrizer ) csv = array_serializer.to_csv expect(csv).to include(comment_1.text) expect(csv).to include(comment_2.text) end it 'renders csv without specified serializer' do array_serializer = ActiveModel::CsvArraySerializer.new(comments) csv = array_serializer.to_csv expect(csv).to include(comment_1.text) expect(csv).to include(comment_2.text) end it 'raises an exception when expected serializer not found' do comments << Object.new array_serializer = ActiveModel::CsvArraySerializer.new(comments) expect{ array_serializer.to_csv }.to raise_error(NameError) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csverizer-0.0.4 | spec/active_model/array_serializer_spec.rb |