class ChefSpec::Matchers::LinkToMatcher

Public Class Methods

new(path) click to toggle source
# File lib/chefspec/matchers/link_to_matcher.rb, line 3
def initialize(path)
  @path = path
end

Public Instance Methods

description() click to toggle source
# File lib/chefspec/matchers/link_to_matcher.rb, line 21
def description
  %Q{link to "#{@path}"}
end
failure_message() click to toggle source
# File lib/chefspec/matchers/link_to_matcher.rb, line 25
def failure_message
  if @link.nil?
    %Q{expected "link[#{@path}]" with action :create to be in Chef run}
  else
    %Q{expected "#{@link}" to link to "#{@path}" but was "#{@link.to}"}
  end
end
failure_message_when_negated() click to toggle source
# File lib/chefspec/matchers/link_to_matcher.rb, line 33
def failure_message_when_negated
  %Q{expected "#{@link}" to not link to "#{@path}"}
end
matches?(link) click to toggle source
# File lib/chefspec/matchers/link_to_matcher.rb, line 7
def matches?(link)
  @link = link

  if @link
    ChefSpec::Coverage.cover!(@link)

    @link.is_a?(Chef::Resource::Link) &&
      @link.performed_action?(:create) &&
      @path === @link.to
  else
    false
  end
end