Sha256: afd77efd7eb5f212f7b530ca817cd68b5fb3f938da21ad0215caf15148a1f947

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
require_relative "../spec_helper"
require "cinch"

describe LogStash::Outputs::Irc do

  let(:host) { "localhost" }
  let(:port) { rand(2048)+1024 }

  let(:channels) { ["#logstash", "#elastic"] }

  it "should register without errors" do
    plugin = LogStash::Plugin.lookup("output", "irc").new("host" => host, "port" => port, "channels" => channels)
    expect { plugin.register }.to_not raise_error
  end

  describe "#send" do

    subject { LogStash::Outputs::Irc.new("host" => host, "port" => port, "channels" => channels ) }

    let(:properties) { { "message" => "This is a message!"} }
    let(:event)      { LogStash::Event.new(properties) }
    let(:channel)    { double("channel") }

    let(:bot)     { Cinch::Bot.new }

    before(:each) do
      allow(channel).to receive(:msg)
      subject.inject_bot(bot).register
      expect(subject.bot).to receive(:channels).and_return([channel])
    end

    it "sends the generated event to the irc" do
      expect(channel).to receive(:msg).with("This is a message!")
      subject.receive(event)
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
logstash-output-irc-3.0.6 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.5 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.4 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.3 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.2 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.1 spec/outputs/irc_spec.rb
logstash-output-irc-3.0.0 spec/outputs/irc_spec.rb
logstash-output-irc-2.0.4 spec/outputs/irc_spec.rb
logstash-output-irc-2.0.2 spec/outputs/irc_spec.rb
logstash-output-irc-2.0.1 spec/outputs/irc_spec.rb
logstash-output-irc-2.0.0 spec/outputs/irc_spec.rb