Class: ChefSpec::Matchers::LinkToMatcher
- Inherits:
-
Object
- Object
- ChefSpec::Matchers::LinkToMatcher
- Defined in:
- lib/chefspec/matchers/link_to_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(path) ⇒ LinkToMatcher
constructor
A new instance of LinkToMatcher.
- #matches?(link) ⇒ Boolean
Constructor Details
#initialize(path) ⇒ LinkToMatcher
Returns a new instance of LinkToMatcher.
3 4 5 |
# File 'lib/chefspec/matchers/link_to_matcher.rb', line 3 def initialize(path) @path = path end |
Instance Method Details
#description ⇒ Object
21 22 23 |
# File 'lib/chefspec/matchers/link_to_matcher.rb', line 21 def description %Q{link to "#{@path}"} end |
#failure_message ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/chefspec/matchers/link_to_matcher.rb', line 25 def 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 ⇒ Object
33 34 35 |
# File 'lib/chefspec/matchers/link_to_matcher.rb', line 33 def %Q{expected "#{@link}" to not link to "#{@path}"} end |
#matches?(link) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 |