File: test_table_arrays.rb

package info (click to toggle)
ruby-toml 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 296 kB
  • sloc: ruby: 666; sh: 7; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 756 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
require 'multi_json'
require 'toml'
require 'minitest/autorun'

class TestParserTableArrays < Minitest::Test
  def setup
    doc = '
[[fruit]]
  name = "apple"

  [fruit.physical]
    color = "red"
    shape = "round"

  [[fruit.variety]]
    name = "red delicious"

  [[fruit.variety]]
    name = "granny smith"

[[fruit]]
  name = "banana"

  [[fruit.variety]]
    name = "plantain"
    '
    @doc = TOML.load(doc)
    #require 'pp'
    #PP.pp @doc
  end

  def test_doc
    assert_equal @doc, {
      "fruit"=>
        [{"name"=>"apple",
          "physical"=>{"color"=>"red", "shape"=>"round"},
          "variety"=>[{"name"=>"red delicious"}, {"name"=>"granny smith"}]},
         {"name"=>"banana", "variety"=>[{"name"=>"plantain"}]}]
    }
  end
end