Sha256: ed257a030c26b264675550957adc2f0d96659fc18c4ac2817b11dd4f116ae4f0

Contents?: true

Size: 1.25 KB

Versions: 63

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
require 'spec_helper'

require "logstash/util"

describe LogStash::Util do

  context "stringify_keys" do
    it "should convert hash symbol keys to strings" do
      expect(LogStash::Util.stringify_symbols({:a => 1, "b" => 2})).to eq({"a" => 1, "b" => 2})
    end

    it "should keep non symbolic hash keys as is" do
      expect(LogStash::Util.stringify_symbols({1 => 1, 2.0 => 2})).to eq({1 => 1, 2.0 => 2})
    end

    it "should convert inner hash keys to strings" do
      expect(LogStash::Util.stringify_symbols({:a => 1, "b" => {:c => 3}})).to eq({"a" => 1, "b" => {"c" => 3}})
      expect(LogStash::Util.stringify_symbols([:a, 1, "b", {:c => 3}])).to eq(["a", 1, "b", {"c" => 3}])
    end

    it "should convert hash symbol values to strings" do
      expect(LogStash::Util.stringify_symbols({:a => :a, "b" => :b})).to eq({"a" => "a", "b" => "b"})
    end

    it "should convert array symbol values to strings" do
      expect(LogStash::Util.stringify_symbols([1, :a])).to eq([1, "a"])
    end

    it "should convert innner array symbol values to strings" do
      expect(LogStash::Util.stringify_symbols({:a => [1, :b]})).to eq({"a" => [1, "b"]})
      expect(LogStash::Util.stringify_symbols([:a, [1, :b]])).to eq(["a", [1, "b"]])
    end
  end
end

Version data entries

63 entries across 60 versions & 5 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/spec/logstash/util_spec.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/spec/logstash/util_spec.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/util_spec.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/util_spec.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/logstash-core-2.4.1-java/spec/logstash/util_spec.rb
logstash-core-2.4.1-java spec/logstash/util_spec.rb
logstash-core-2.4.0-java spec/logstash/util_spec.rb
logstash-core-2.4.0.snapshot4-java spec/logstash/util_spec.rb
logstash-core-2.4.0.snapshot3-java spec/logstash/util_spec.rb
logstash-core-2.4.0.snapshot2-java spec/logstash/util_spec.rb
logstash-core-2.4.0.snapshot1-java spec/logstash/util_spec.rb
logstash-core-2.3.4-java spec/logstash/util_spec.rb
logstash-core-2.3.4.snapshot1-java spec/logstash/util_spec.rb
logstash-core-2.3.3-java spec/logstash/util_spec.rb
logstash-core-2.3.3.snapshot2-java spec/logstash/util_spec.rb
logstash-core-2.3.3.snapshot1-java spec/logstash/util_spec.rb
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/logstash-core-1.5.4-java/spec/util_spec.rb
logstash-core-2.3.2-java spec/logstash/util_spec.rb
logstash-core-2.3.2.snapshot1-java spec/logstash/util_spec.rb
logstash-core-2.2.4-java spec/logstash/util_spec.rb