Sha256: 3faf79c8ec07bf0b642b2b0110d7b9ddfe65569c846a3867a08e87f3fb9fee3a

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe DispatchRider::NotificationServices::FileSystem::Channel do
  subject { described_class.new(path) }

  let(:path) { File.expand_path("tmp/test/channel") }
  let(:published_message) { File.new(Dir["#{path}/*.ready"].first).read }

  before { FileUtils.mkdir_p(path) }

  after { FileUtils.rm_rf(path) }

  describe "#publish" do
    let(:message) { { subject: "foo", body: "bar" }.to_json }

    it "adds a file to the path folder" do
      expect {
        subject.publish(message: message)
      }.to change { Dir["#{path}/*"].length }.by(1)
    end

    it "writes the message to the file" do
      subject.publish(message: message)

      expect(published_message).to eq(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-2.2.0 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb