Sha256: add27cddcb01b99917c52b7a3dbaec8260499fe72a3b9003e372d0502859840a

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require './lib/fusuma/plugin/inputs/input'

module Fusuma
  module Plugin
    module Inputs
      RSpec.describe Input do
        let(:input) { described_class.new }

        describe '#io' do
          subject { input.io { 'dummy' } }
          it { expect { subject }.to raise_error(NotImplementedError) }
        end

        describe '#create_event' do
          subject { input.create_event }
          it { is_expected.to be_a Events::Event }

          it { expect(input.tag).to eq 'input' }
        end

        describe '.select' do
          subject { Input.select([DummyInput.new]) }

          it { is_expected.to be_a Events::Event }
        end
      end

      class DummyInput < Input
        def io
          @io ||= begin
            r, w = IO.pipe
            w.puts 'hoge'
            w.close
            r
          end
        end
      end

      RSpec.describe DummyInput do
        let(:dummy_input) { described_class.new }

        around do |example|
          ConfigHelper.load_config_yml = <<~CONFIG
            plugin:
             inputs:
               dummy_input:
                 dummy: dummy
          CONFIG

          example.run

          Config.custom_path = nil
        end

        describe '#io' do
          subject { dummy_input.io }
          it { is_expected.to be_a IO }
        end

        describe '#config_params' do
          subject { dummy_input.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/inputs/input_spec.rb
fusuma-2.4.0 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.3.0 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.2.0 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.1.0 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.0.5 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.0.4 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.0.3 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.0.2 spec/lib/plugin/inputs/input_spec.rb
fusuma-2.0.1 spec/lib/plugin/inputs/input_spec.rb