class TestServantConfigDb

Public Instance Methods

setup() click to toggle source
# File lib/belphanior/servant/test/tc_servant_config_db.rb, line 7
  def setup
    @config = ServantConfigDb.new(
<<EOF
  {
    "ip":"127.0.0.1",
    "port": "80"
  }
EOF
    )
  end
test_initialization() click to toggle source
# File lib/belphanior/servant/test/tc_servant_config_db.rb, line 17
def test_initialization
  assert_equal(@config.get("ip"),"127.0.0.1")
  assert_equal(@config.get("port"), "80")
end
test_readonly() click to toggle source
# File lib/belphanior/servant/test/tc_servant_config_db.rb, line 33
def test_readonly
  @config.set_readonly("ip")
  assert(@config.is_readonly("ip"), true)
  assert_raises(ServantConfigException) {
    @config.set("ip","127.0.0.10")
  }
end
test_serialization() click to toggle source
# File lib/belphanior/servant/test/tc_servant_config_db.rb, line 21
def test_serialization
  out = JSON.parse(@config.to_json)
  assert_equal(out.length, 2)
  assert_equal(out["ip"],"127.0.0.1")
  assert_equal(out["port"], "80")
end
test_set() click to toggle source
# File lib/belphanior/servant/test/tc_servant_config_db.rb, line 27
def test_set
  @config.set("bar","hi")
  assert_equal(@config.get("bar"),"hi")
  @config.set("number_of_pigs",3)
  assert_equal(@config.get("number_of_pigs"),"3")
end