Sha256: 5de95d0624e1d8b4c58e0d40f04361e1e94c87e4ad0f06b804fbfb0e6f0ea735

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

require "logstash/codecs/plain"
require "logstash/event"
require "insist"

describe LogStash::Codecs::Plain do
  context "#decode" do
    it "should return a valid event" do
      subject.decode("Testing decoding.") do |event|
        insist { event.is_a? LogStash::Event }
      end
    end
  end

  context "#encode" do
    it "should return a plain text encoding" do
      event = LogStash::Event.new
      event["message"] = "Hello World."
      subject.on_event do |data|
        insist { data } == event.to_s
      end
      subject.encode(event)
    end

    it "should respect the format setting" do
      format = "%{[hello]} %{[something][fancy]}"
      codec = LogStash::Codecs::Plain.new("format" => format)
      event = LogStash::Event.new("hello" => "world", "something" => { "fancy" => 123 })
      codec.on_event do |data|
        insist { data } == event.sprintf(format)
      end
      codec.encode(event)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-lib-1.3.2 spec/codecs/plain.rb