diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-15 10:56:10 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-15 10:56:10 +0200 |
| commit | 5c2865998aec2db34c42ee092952ec37ebd3cf16 (patch) | |
| tree | 3f167bb65c03fc8cb3b046b3573979f86a782c56 | |
| parent | 713a2081a9a3265d1e5218c1f88a293cd3b32a1c (diff) | |
better
| -rw-r--r-- | lib/dslkeywords/notify.rb | 4 | ||||
| -rw-r--r-- | lib/dslkeywords/resource.rb | 4 | ||||
| -rw-r--r-- | test/lib/dslkeywords/dependency_test.rb | 13 |
3 files changed, 7 insertions, 14 deletions
diff --git a/lib/dslkeywords/notify.rb b/lib/dslkeywords/notify.rb index c7d50d9..602d216 100644 --- a/lib/dslkeywords/notify.rb +++ b/lib/dslkeywords/notify.rb @@ -20,10 +20,10 @@ module RCM # Add notify keyword to the DSL class DSL - def notify(message, &block) + def notify(message = nil, &block) return unless @conds_met - n = Notify.new(message) + n = Notify.new(message.nil? ? '' : message) n.message(n.instance_eval(&block)) if block self << n n diff --git a/lib/dslkeywords/resource.rb b/lib/dslkeywords/resource.rb index 884dec9..c9098d4 100644 --- a/lib/dslkeywords/resource.rb +++ b/lib/dslkeywords/resource.rb @@ -19,10 +19,10 @@ module RCM def [](other) = "#{@name}['#{other}']" end - class NoSuchResource < StandardError; end + class NoSuchResourceType < StandardError; end def method_missing(method_name) - raise NoSuchResource, "No such resource: #{method_name}" unless @valid_resources.include?(method_name) + raise NoSuchResourceType, "No such resource type: #{method_name}" unless @valid_resources.include?(method_name) SyntaxSugar.new(method_name) end diff --git a/test/lib/dslkeywords/dependency_test.rb b/test/lib/dslkeywords/dependency_test.rb index 3e23282..324a756 100644 --- a/test/lib/dslkeywords/dependency_test.rb +++ b/test/lib/dslkeywords/dependency_test.rb @@ -21,17 +21,10 @@ class RCMDependencyTest < Minitest::Test end def test_depends_on_invalid_resource - correct_exception_thrown = false - - configure_from_scratch do - notify 'foo' do - depends_on invalid['baz'] - :foo_message + assert_raises(RCM::ResourceDependencies::NoSuchResourceType) do + configure_from_scratch do + notify { depends_on invalid['baz'] } end - rescue RCM::ResourceDependencies::NoSuchResource - correct_exception_thrown = true end - - assert correct_exception_thrown end end |
