diff options
-rw-r--r-- | lib/Config/Parser/yaml.pm6 | 1 | ||||
-rw-r--r-- | t/01-read.t (renamed from t/read.t) | 2 | ||||
-rw-r--r-- | t/02-merge.t | 22 | ||||
-rw-r--r-- | t/files/config.yaml (renamed from t/test.yaml) | 0 | ||||
-rw-r--r-- | t/files/merge.yaml | 2 |
5 files changed, 26 insertions, 1 deletions
diff --git a/lib/Config/Parser/yaml.pm6 b/lib/Config/Parser/yaml.pm6 index c0c194e..366368f 100644 --- a/lib/Config/Parser/yaml.pm6 +++ b/lib/Config/Parser/yaml.pm6 @@ -9,6 +9,7 @@ class Config::Parser::yaml is Config::Parser { method read(Str $path --> Hash) { + say $path; load-yaml(slurp $path); } } @@ -10,7 +10,7 @@ plan 5; my $config = Config.new(); -ok $config.read("t/test.yaml"), "Read a YAML file"; +ok $config.read("t/files/config.yaml"), "Read a YAML file"; ok $config.get("a") eq "a", "Get simple key"; ok $config.get("b.c") eq "c", "Get nested key"; diff --git a/t/02-merge.t b/t/02-merge.t new file mode 100644 index 0000000..cf9aa6a --- /dev/null +++ b/t/02-merge.t @@ -0,0 +1,22 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +use Config; + +plan 3; + +my $config = Config.new(); + +ok $config.read("t/files/config.yaml"), "Read initial config"; +ok $config.read("t/files/merge.yaml"), "Read merge config"; + +is-deeply $config.get(), { + a => "a", + b => { + c => "c", + d => "d" + } +}, "Ensure configurations are merged"; diff --git a/t/test.yaml b/t/files/config.yaml index 2b93ee8..2b93ee8 100644 --- a/t/test.yaml +++ b/t/files/config.yaml diff --git a/t/files/merge.yaml b/t/files/merge.yaml new file mode 100644 index 0000000..64ce87b --- /dev/null +++ b/t/files/merge.yaml @@ -0,0 +1,2 @@ +b: + d: "d" |