Sha256: 741a9bdff4916afe6c44d5a0467a6eadb8e8dd20b3f8be2d5d0eae685f975862

Contents?: true

Size: 816 Bytes

Versions: 8

Compression:

Stored size: 816 Bytes

Contents

require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/json_encode"

describe LogStash::Filters::JSONEncode do


  describe "encode a field as json" do
    config <<-CONFIG
      filter {
        json_encode {
          source => "hello"
          target => "fancy"
        }
      }
    CONFIG

    hash = { "hello" => { "whoa" => [ 1, 2, 3 ] } }
    sample(hash) do
      insist { subject["fancy"] } == LogStash::Json.dump(hash["hello"])
    end
  end

  describe "encode a field as json and overwrite the original" do
    config <<-CONFIG
      filter {
        json_encode {
          source => "hello"
        }
      }
    CONFIG

    hash = { "hello" => { "whoa" => [ 1, 2, 3 ] } }
    sample(hash) do
      insist { subject["hello"] } == LogStash::Json.dump(hash["hello"])
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-filter-json_encode-2.0.4 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-2.0.2 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-2.0.1 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-0.1.5 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-0.1.4 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-0.1.3 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-0.1.2 spec/filters/json_encode_spec.rb
logstash-filter-json_encode-0.1.1 spec/filters/json_encode_spec.rb