Sha256: 5935ffae086311cb31db8d6ecd5c3efa19b0023f3a6f45fcc01d8a74f699c590

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

require 'spec_helper'
require 'stringio'
require 'csv'

RSpec.describe SolidusFeeds do
  before { described_class.reset_config! }

  let(:io) { StringIO.new }
  let(:string_io_publisher) { ->(&block) { block.call(io) } }
  let(:csv_generator) {
    ->(io) {
      csv = CSV.new(io)
      csv << ["some", "data"]
      csv << ["another", "line"]
    }
  }

  it 'allows to register, generate, and publish feeds' do
    described_class.configure do |config|
      config.register :foo do |feed|
        feed.publisher = string_io_publisher
        feed.generator = csv_generator
      end
    end

    described_class.config.find(:foo).publish
    expect(io.string).to eq("some,data\nanother,line\n")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_feeds-0.1.0 spec/solidus_feeds_spec.rb