Sha256: 53de2c860fce95d35bf9c90c05837fdb715f8fccac93688b92944cb9b4fca0bf
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require_relative 'helper' class DumperTest < Test::Unit::TestCase def test_dump_empty dumped = TOML.dump({}) assert_equal('', dumped.toml_str) end def test_dump_types dumped = TOML.dump(string: %q(TOML "dump")) assert_equal("string = \"TOML \\\"dump\\\"\"\n", dumped.toml_str) dumped = TOML.dump(float: -13.24) assert_equal("float = -13.24\n", dumped.toml_str) dumped = TOML.dump(int: 1234) assert_equal("int = 1234\n", dumped.toml_str) dumped = TOML.dump(true: true) assert_equal("true = true\n", dumped.toml_str) dumped = TOML.dump(false: false) assert_equal("false = false\n", dumped.toml_str) dumped = TOML.dump(array: [1,2,3]) assert_equal("array = [1, 2, 3]\n", dumped.toml_str) dumped = TOML.dump(array: [[1,2], ["weird", "one"]]) assert_equal("array = [[1, 2], [\"weird\", \"one\"]]\n", dumped.toml_str) dumped = TOML.dump(datetime: Time.utc(1986,8,28,15,15)) assert_equal("datetime = 1986-08-28T15:15:00Z\n", dumped.toml_str) end def test_dump_nested_attributes hash = {nested: {hash: { deep: true}}} dumped = TOML.dump(hash) assert_equal("[nested.hash]\ndeep = true\n", dumped.toml_str) hash[:nested].merge!(other: 12) dumped = TOML.dump(hash) assert_equal("[nested]\nother = 12\n[nested.hash]\ndeep = true\n", dumped.toml_str) hash[:nested].merge!(nest: {again: 'it never ends'}) dumped = TOML.dump(hash) toml = "[nested]\n" + "other = 12\n" + "[nested.hash]\n" + "deep = true\n" + "[nested.nest]\n" + "again = \"it never ends\"\n" assert_equal(toml, dumped.toml_str) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
toml-rb-0.1.2 | test/dumper_test.rb |