Sha256: 136f9a6e9f06b302163bdf2cb530694caaeffa4e010f30fcd3bc59d6737d7435

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 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) { PostCsvrizer.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

1 entries across 1 versions & 1 rubygems

Version Path
csverizer-0.0.4 spec/active_model/has_many_spec.rb