Class: ChefSpec::Matchers::SubscribesMatcher
- Inherits:
-
Object
- Object
- ChefSpec::Matchers::SubscribesMatcher
- Includes:
- Normalize
- Defined in:
- lib/chefspec/matchers/subscribes_matcher.rb
Instance Method Summary collapse
- #before ⇒ Object
- #delayed ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #immediately ⇒ Object
-
#initialize(signature) ⇒ SubscribesMatcher
constructor
A new instance of SubscribesMatcher.
- #matches?(resource) ⇒ Boolean
- #on(action) ⇒ Object
Methods included from Normalize
Constructor Details
#initialize(signature) ⇒ SubscribesMatcher
Returns a new instance of SubscribesMatcher.
5 6 7 8 9 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 5 def initialize(signature) signature.match(/^([^\[]*)\[(.*)\]$/) @expected_resource_type = $1 @expected_resource_name = $2 end |
Instance Method Details
#before ⇒ Object
55 56 57 58 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 55 def before @before = true self end |
#delayed ⇒ Object
50 51 52 53 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 50 def delayed @delayed = true self end |
#description ⇒ Object
60 61 62 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 60 def description @instance.description end |
#failure_message ⇒ Object
64 65 66 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 64 def @instance. end |
#failure_message_when_negated ⇒ Object
68 69 70 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 68 def @instance. end |
#immediately ⇒ Object
45 46 47 48 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 45 def immediately @immediately = true self end |
#matches?(resource) ⇒ Boolean
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 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 11 def matches?(resource) @instance = ChefSpec::Matchers::NotificationsMatcher.new(resource.to_s) if @action @instance.to(@action) end if @immediately @instance.immediately end if @delayed @instance.delayed end if @before @instance.before end if resource runner = resource.run_context.node.runner expected = runner.find_resource(@expected_resource_type, @expected_resource_name) @instance.matches?(expected) else @instance.matches?(nil) end end |
#on(action) ⇒ Object
40 41 42 43 |
# File 'lib/chefspec/matchers/subscribes_matcher.rb', line 40 def on(action) @action = action self end |