Class: ChefSpec::Matchers::DoNothingMatcher
- Inherits:
-
Object
- Object
- ChefSpec::Matchers::DoNothingMatcher
- Defined in:
- lib/chefspec/matchers/do_nothing_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #matches?(resource) ⇒ Boolean
Instance Method Details
#description ⇒ Object
16 17 18 |
# File 'lib/chefspec/matchers/do_nothing_matcher.rb', line 16 def description "do nothing" end |
#failure_message ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chefspec/matchers/do_nothing_matcher.rb', line 20 def if @resource = %{expected #{@resource} to do nothing, but the following } << %{actions were performed:} << %{\n\n} @resource.performed_actions.each do |action| << %{ :#{action}} end else = %{expected _something_ to do nothing, but the _something_ } << %{you gave me was nil! If you are running a test like:} << %{\n\n} << %{ expect(_something_).to do_nothing} << %{\n\n} << %{make sure that `_something_` exists, because I got nil!} end end |
#failure_message_when_negated ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chefspec/matchers/do_nothing_matcher.rb', line 40 def if @resource = %{expected #{@resource} to do something, but no actions } << %{were performed.} else = %{expected _something_ to do something, but no actions } << %{were performed.} end end |
#matches?(resource) ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/chefspec/matchers/do_nothing_matcher.rb', line 3 def matches?(resource) @resource = resource if @resource ChefSpec::Coverage.cover!(@resource) actions = @resource.performed_actions actions.empty? || actions == [:nothing] else false end end |