Sha256: b990221fee0e37d83b1922054d8db88852fa517fca32a20230bae17f9e4a5abc

Contents?: true

Size: 721 Bytes

Versions: 3

Compression:

Stored size: 721 Bytes

Contents

require 'spec_helper'

describe 'has_many' do
  let(:post) { Post.new(name: 'a', body: 'b', comments: comments) }
  let(:comments) do
    [
      Comment.new(text: 'c'),
      Comment.new(text: 'd'),
      Comment.new(text: 'e')
    ]
  end
  let(:serializer) { PostCsverizer.new(post, root: false) }

  it 'appends associated objects csv to multiple copies of this' do
    csv = serializer.to_csv
    records = csv.split("\n")
    expect(records.length).to eq(comments.length)
    records.each.with_index do |record, i|
      next if i == 0
      expect(record).to include(post.name)
      expect(record).to include(post.body)

      comment = comments[i]
      expect(record).to include(comment.text)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csverizer-0.0.7 spec/active_model/has_many_spec.rb
csverizer-0.0.6 spec/active_model/has_many_spec.rb
csverizer-0.0.5 spec/active_model/has_many_spec.rb