Class: TestServantConfigDb
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestServantConfigDb
- Defined in:
- lib/belphanior/servant/test/tc_servant_config_db.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_initialization ⇒ Object
- #test_readonly ⇒ Object
- #test_serialization ⇒ Object
- #test_set ⇒ Object
Instance Method Details
#setup ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# 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 ⇒ Object
17 18 19 20 |
# 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 ⇒ Object
33 34 35 36 37 38 39 |
# 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 ⇒ Object
21 22 23 24 25 26 |
# 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 ⇒ Object
27 28 29 30 31 32 |
# 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 |