Sha256: 49b7d5d55986f1124e4574d4ad9ac5d6771872aab9a09354e14551f2b1b6bbac
Contents?: true
Size: 922 Bytes
Versions: 11
Compression:
Stored size: 922 Bytes
Contents
# frozen_string_literal: true require "spec_helper" require "csv" describe Decidim::Exporters::CSV do let(:serializer) do Class.new do def initialize(resource) @resource = resource end def serialize { id: @resource.id, serialized_name: @resource.name, other_ids: @resource.ids } end end end let(:collection) do [ OpenStruct.new(id: 1, name: { ca: "foocat", es: "fooes" }, ids: [1, 2, 3]), OpenStruct.new(id: 2, name: { ca: "barcat", es: "bares" }, ids: [1, 2, 3]) ] end subject { described_class.new(collection, serializer) } describe "export" do it "exports the collection using the right serializer" do exported = subject.export.read data = CSV.parse(exported, headers: true, col_sep: ";").map(&:to_h) expect(data[0]["serialized_name/ca"]).to eq("foocat") end end end
Version data entries
11 entries across 11 versions & 1 rubygems