Class: ChefSpec::Matchers::RenderFileMatcher
- Inherits:
-
Object
- Object
- ChefSpec::Matchers::RenderFileMatcher
- Defined in:
- lib/chefspec/matchers/render_file_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(path) ⇒ RenderFileMatcher
constructor
A new instance of RenderFileMatcher.
- #matches?(runner) ⇒ Boolean
- #with_content(expected_content) ⇒ Object
Constructor Details
#initialize(path) ⇒ RenderFileMatcher
Returns a new instance of RenderFileMatcher.
3 4 5 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 3 def initialize(path) @path = path end |
Instance Method Details
#description ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 17 def description = %Q{render file "#{@path}"} if @expected_content if @expected_content.to_s.include?("\n") << " with content <suppressed>" else << " with content #{@expected_content.inspect}" end end end |
#failure_message_for_should ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 29 def = %Q{expected Chef run to render "#{@path}"} if @expected_content << " with:" << "\n\n" << @expected_content.to_s << "\n\n" << "but got:" << "\n\n" << @actual_content.to_s << "\n " end end |
#failure_message_for_should_not ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 44 def = %Q{expected file "#{@path}"} if @expected_content << " with:" << "\n\n" << @expected_content.to_s << "\n\n" end << " to not be in Chef run" end |
#matches?(runner) ⇒ Boolean
7 8 9 10 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 7 def matches?(runner) @runner = runner resource && has_create_action? && matches_content? end |
#with_content(expected_content) ⇒ Object
12 13 14 15 |
# File 'lib/chefspec/matchers/render_file_matcher.rb', line 12 def with_content(expected_content) @expected_content = expected_content self end |