Sha256: 3bd3e8b959afd5a73002a108401087f277df5192de18a3665bba8b4f5778c630

Contents?: true

Size: 1.91 KB

Versions: 10

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

require './lib/fusuma/plugin/events/event'
require_relative './dummy_buffer'

module Fusuma
  module Plugin
    module Buffers
      RSpec.describe DummyBuffer do
        before do
          @buffer = DummyBuffer.new
        end

        describe '#type' do
          subject { @buffer.type }
          it { is_expected.to eq 'dummy' }
        end

        describe '#buffer' do
          it 'should buffer event' do
            event = Events::Event.new(tag: 'dummy', record: 'dummy record')
            expect(@buffer.buffer(event)).to eq [event]
            expect(@buffer.events).to eq [event]
          end

          it 'should NOT buffer event' do
            event = Events::Event.new(tag: 'SHOULD NOT BUFFER', record: 'dummy record')
            @buffer.buffer(event)
            expect(@buffer.events).to eq []
          end
        end

        describe '#source' do
          subject { @buffer.source }

          it { is_expected.to eq DummyBuffer::DEFAULT_SOURCE }

          context 'with config' do
            around do |example|
              @source = 'custom_event'

              ConfigHelper.load_config_yml = <<~CONFIG
                plugin:
                 buffers:
                   dummy_buffer:
                     source: #{@source}
              CONFIG

              example.run

              Config.custom_path = nil
            end

            it { is_expected.to eq @source }
          end
        end

        describe '#config_params' do
          around do |example|
            ConfigHelper.load_config_yml = <<~CONFIG
              plugin:
               buffers:
                 dummy_buffer:
                   dummy: dummy
            CONFIG

            example.run

            Config.custom_path = nil
          end

          subject { @buffer.config_params }
          it { is_expected.to eq(dummy: 'dummy') }
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fusuma-2.4.1 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.4.0 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.3.0 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.2.0 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.1.0 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.0.5 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.0.4 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.0.3 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.0.2 spec/lib/plugin/buffers/buffer_spec.rb
fusuma-2.0.1 spec/lib/plugin/buffers/buffer_spec.rb