Class: ChefSpec::Matchers::StateAttrsMatcher
- Inherits:
-
Object
- Object
- ChefSpec::Matchers::StateAttrsMatcher
- Defined in:
- lib/chefspec/matchers/state_attrs_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(state_attrs) ⇒ StateAttrsMatcher
constructor
Create a new state_attrs matcher.
- #matches?(resource) ⇒ Boolean
Constructor Details
#initialize(state_attrs) ⇒ StateAttrsMatcher
Create a new state_attrs matcher.
8 9 10 |
# File 'lib/chefspec/matchers/state_attrs_matcher.rb', line 8 def initialize(state_attrs) @expected_attrs = state_attrs.map(&:to_sym) end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'lib/chefspec/matchers/state_attrs_matcher.rb', line 17 def description %Q{have state attributes #{@expected_attrs.inspect}} end |
#failure_message ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chefspec/matchers/state_attrs_matcher.rb', line 21 def if @resource "expected #{state_attrs.inspect} to equal #{@expected_attrs.inspect}" else "expected _something_ to have state attributes, but the " \ "_something_ you gave me was nil!" \ "\n" \ "Ensure the resource exists before making assertions:" \ "\n\n" \ " expect(resource).to be" \ "\n " end end |
#failure_message_when_negated ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chefspec/matchers/state_attrs_matcher.rb', line 35 def if @resource "expected #{state_attrs.inspect} to not equal " \ "#{@expected_attrs.inspect}" else "expected _something_ to not have state attributes, but the " \ "_something_ you gave me was nil!" \ "\n" \ "Ensure the resource exists before making assertions:" \ "\n\n" \ " expect(resource).to be" \ "\n " end end |
#matches?(resource) ⇒ Boolean
12 13 14 15 |
# File 'lib/chefspec/matchers/state_attrs_matcher.rb', line 12 def matches?(resource) @resource = resource @resource && matches_state_attrs? end |