Class: RSpec::RubyContentMatchers::HaveContent
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::HaveContent
- Defined in:
- lib/code_spec/matchers/have_content.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize ⇒ HaveContent
constructor
A new instance of HaveContent.
- #matches?(file_path) {|file.read| ... } ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize ⇒ HaveContent
Returns a new instance of HaveContent.
5 6 |
# File 'lib/code_spec/matchers/have_content.rb', line 5 def initialize end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
3 4 5 |
# File 'lib/code_spec/matchers/have_content.rb', line 3 def file_path @file_path end |
Instance Method Details
#failure_message ⇒ Object
16 17 18 |
# File 'lib/code_spec/matchers/have_content.rb', line 16 def display "Expected the file #{file_path} to have content" end |
#matches?(file_path) {|file.read| ... } ⇒ Boolean
8 9 10 11 12 13 14 |
# File 'lib/code_spec/matchers/have_content.rb', line 8 def matches?(file_path, &block) self.file_path = file_path return nil if File.blank? file_path file = File.new(file_path) yield file.read if block true end |
#negative_failure_message ⇒ Object
20 21 22 |
# File 'lib/code_spec/matchers/have_content.rb', line 20 def display "Did not expect the file #{file_path} to have content" end |