Sha256: 324c9df02d041e9861d60d0432bdd4a654656c4153fb7605e2e3847c4783633b

Contents?: true

Size: 714 Bytes

Versions: 14

Compression:

Stored size: 714 Bytes

Contents

require 'spec_helper'

describe DispatchRider::NotificationServices::FileSystem::Channel do
  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) }

  subject { described_class.new(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)
      }.to change { Dir["#{path}/*"].length }.by(1)
    end

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.6 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.5 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.4 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.3 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.2 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.1 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.8.0 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.7.2 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.7.1 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.7.0 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.6.2 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.6.1 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb
dispatch-rider-1.6.0 spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb