blob: d3df551c84d8cb38f6b6b8a1afa74f6dfb6424f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
require 'spec_helper'
require 'oxidized/source/http'
describe Oxidized::HTTP do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.setup_logger
end
describe "#string_navigate" do
h1 = {}
h1["inventory"] = [{ "ip" => "10.10.10.10" }]
h1["jotain"] = { "2" => "jotain" }
it "should be able to navigate multilevel-hash" do
http = Oxidized::HTTP.new
http.class.must_equal Oxidized::HTTP
http.send(:string_navigate, h1, "jotain.2").must_equal "jotain"
end
it "should be able to navigate multilevel-hash" do
Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.2").must_equal "jotain"
end
it "should be able to navigate hash/array combination" do
Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[0].ip").must_equal "10.10.10.10"
end
it "should return nil on non-existing string key" do
Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.3").must_equal nil
end
it "should return nil on non-existing array index" do
Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[3]").must_equal nil
end
end
end
|