diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tc_mauve_configuration_builder.rb | 54 | ||||
-rw-r--r-- | test/tc_mauve_configuration_builders_people_list.rb | 72 | ||||
-rw-r--r-- | test/tc_mauve_configuration_builders_person.rb | 27 |
3 files changed, 100 insertions, 53 deletions
diff --git a/test/tc_mauve_configuration_builder.rb b/test/tc_mauve_configuration_builder.rb index faa0bfa..1288b5d 100644 --- a/test/tc_mauve_configuration_builder.rb +++ b/test/tc_mauve_configuration_builder.rb @@ -3,7 +3,7 @@ $:.unshift "../lib/" require 'th_mauve' require 'mauve/configuration_builder' -class TcMauveConfigurationBuildersPeopleAndSourceLists < Mauve::UnitTest +class TcMauveConfigurationBuilder < Mauve::UnitTest def setup setup_logger @@ -13,58 +13,6 @@ class TcMauveConfigurationBuildersPeopleAndSourceLists < Mauve::UnitTest teardown_logger end - def test_people_list - config =<<EOF -people_list "team sky", %w( - geraint - edvald - bradley - rigoberto - ben -) - -people_list "garmin-cervelo", %w( - thor - ryder - tyler - julian -) - -EOF - x = nil - assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } - assert_equal(2, x.people_lists.keys.length) - assert_equal(["team sky","garmin-cervelo"].sort,x.people_lists.keys.sort) - assert_equal(%w(geraint edvald bradley rigoberto ben), x.people_lists["team sky"].list) - - end - - def test_duplicate_people_list - - config=<<EOF - -people_list "htc-highroad", - ["mark c", "mark r", "Lars"] - -people_list "htc-highroad", - %w(Bernie Danny Lars) - -EOF - x = nil - # - # This should generate two warnings: - # * duplicate list - # * Lars already being on a list - # - assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } - - assert_match(/Lars/, logger_pop()) - assert_match(/Duplicate/, logger_pop()) - - assert_equal(1, x.people_lists.keys.length) - assert_equal(["mark c","mark r","Lars","Bernie","Danny"].sort, x.people_lists["htc-highroad"].list.sort) - end - def test_source_list config =<<EOF source_list "sources", %w( diff --git a/test/tc_mauve_configuration_builders_people_list.rb b/test/tc_mauve_configuration_builders_people_list.rb new file mode 100644 index 0000000..61494d8 --- /dev/null +++ b/test/tc_mauve_configuration_builders_people_list.rb @@ -0,0 +1,72 @@ +$:.unshift "../lib/" + +require 'th_mauve' +require 'mauve/configuration_builder' +require 'mauve/configuration_builders/people_list' + +class TcMauveConfigurationBuildersPeopleList < Mauve::UnitTest + + def setup + setup_logger + end + + def teardown + teardown_logger + end + + def test_people_list + config =<<EOF +people_list "team sky", %w( + geraint + edvald + bradley + rigoberto + ben +) + +people_list("garmin-cervelo", %w( + thor + ryder + tyler + julian +)) { + every 20.minutes + during { working_hours? } +} + +EOF + x = nil + assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } + assert_equal(2, x.people_lists.keys.length) + assert_equal(["team sky","garmin-cervelo"].sort,x.people_lists.keys.sort) + assert_equal(%w(geraint edvald bradley rigoberto ben), x.people_lists["team sky"].list) + + end + + def test_duplicate_people_list + + config=<<EOF + +people_list "htc-highroad", + ["mark c", "mark r", "Lars"] + +people_list "htc-highroad", + %w(Bernie Danny Lars) + +EOF + x = nil + # + # This should generate two warnings: + # * duplicate list + # * Lars already being on a list + # + assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } + + assert_match(/Lars/, logger_pop()) + assert_match(/Duplicate/, logger_pop()) + + assert_equal(1, x.people_lists.keys.length) + assert_equal(["mark c","mark r","Lars","Bernie","Danny"].sort, x.people_lists["htc-highroad"].list.sort) + end + +end diff --git a/test/tc_mauve_configuration_builders_person.rb b/test/tc_mauve_configuration_builders_person.rb index 61a6202..391d796 100644 --- a/test/tc_mauve_configuration_builders_person.rb +++ b/test/tc_mauve_configuration_builders_person.rb @@ -2,10 +2,37 @@ $:.unshift "../lib/" require 'th_mauve' require 'mauve/configuration_builders/person' +require 'pp' class TcMauveConfigurationBuildersPerson < Mauve::UnitTest def test_load + config=<<EOF +person("test1") { + all { "this should email on every level" } + during { "this is the during block" } + every 300 + email "test1@example.com" + sms "01234567890" + xmpp "test1@chat.example.com" + password "topsekrit" +} +EOF + + x = nil + assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } + assert_equal(1, x.people.length) + assert_equal(%w(test1), x.people.keys) + assert_equal(300, x.people["test1"].every) + assert_equal("test1@example.com", x.people["test1"].email) + assert_equal("01234567890", x.people["test1"].sms) + assert_equal("test1@chat.example.com", x.people["test1"].xmpp) + assert_equal("topsekrit", x.people["test1"].password) + + assert_equal("this is the during block", x.people["test1"].during.call) + assert_equal("this should email on every level", x.people["test1"].urgent.call) + assert_equal("this should email on every level", x.people["test1"].normal.call) + assert_equal("this should email on every level", x.people["test1"].low.call) end |