Sha256: 2091ab9e16c9b004cde642ca43ade340edf13a2d35ee4d5bd3cdfe30b4c3393b

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

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

17 entries across 17 versions & 1 rubygems

Version Path
logstash-core-1.5.4.snapshot2-java spec/util_spec.rb
logstash-core-1.5.4.snapshot1-java spec/util_spec.rb
logstash-core-1.5.3-java spec/util_spec.rb
logstash-core-1.5.3.snapshot2-java spec/util_spec.rb
logstash-core-1.5.3.snapshot1-java spec/util_spec.rb
logstash-core-1.5.2.2-java spec/util_spec.rb
logstash-core-1.5.2.1-java spec/util_spec.rb
logstash-core-1.5.2-java spec/util_spec.rb
logstash-core-1.5.2.snapshot2-java spec/util_spec.rb
logstash-core-1.5.2.snapshot1-java spec/util_spec.rb
logstash-core-1.5.1-java spec/util_spec.rb
logstash-core-1.5.1.snapshot1-java spec/util_spec.rb
logstash-core-1.5.0-java spec/util_spec.rb
logstash-core-1.5.0.snapshot1-java spec/util_spec.rb
logstash-core-1.5.0.rc4-java spec/util_spec.rb
logstash-core-1.5.0.rc4.snapshot2-java spec/util_spec.rb
logstash-core-1.5.0.rc4.snapshot1-java spec/util_spec.rb