class ChefSpec::Matchers::StateAttrsMatcher

def description

def description
  %Q{have state attributes #{@expected_attrs.inspect}}
end

def failure_message

def failure_message
  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

def failure_message_when_negated

def failure_message_when_negated
  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

def initialize(state_attrs)

Parameters:
  • state_attrs (Array) --
def initialize(state_attrs)
  @expected_attrs = state_attrs.map(&:to_sym)
end

def matches?(resource)

def matches?(resource)
  @resource = resource
  @resource && matches_state_attrs?
end

def matches_state_attrs?

Returns:
  • (true, false) -
def matches_state_attrs?
  @expected_attrs == state_attrs
end

def state_attrs

Returns:
  • (Array) -
def state_attrs
  @resource.class.state_attrs.map(&:to_sym)
end