Sha256: de83e1f1f16c4aa5003bfebda0799e76fb5e0b007f6b30f20cecc53f1f895b48
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe 'has_one' do let(:post) { Post.new(name: 'a', body: 'b', author: author) } let(:author) { Author.new(name: 'd') } let(:category) { Category.new(name: 'e') } let(:post_serializer) { PostCsvrizer.new(post) } let(:author_serializer) { AuthorCsvrizer.new(author) } it 'appends the associated objects csv data to this' do csv = post_serializer.to_csv expect(csv).to include(post.name) expect(csv).to include(post.body) expect(csv).to include(author.name) end it 'appends all associated objects csv data to this' do post.category = category csv = post_serializer.to_csv expect(csv).to include(post.name) expect(csv).to include(post.body) expect(csv).to include(author.name) expect(csv).to include(category.name) end it 'appends associated objects associations' do author.category = category csv = post_serializer.to_csv expect(csv).to include(post.name) expect(csv).to include(post.body) expect(csv).to include(author.name) expect(csv).to include(category.name) end it 'returns this csv data if no associated object' do author = nil csv = post_serializer.to_csv expect(csv).to include(post.name) expect(csv).to include(post.body) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csverizer-0.0.4 | spec/active_model/has_one_spec.rb |