Class: RSpec::PathMatchers::Matchers::NoEntryMatcher Private
- Inherits:
-
Object
- Object
- RSpec::PathMatchers::Matchers::NoEntryMatcher
- Defined in:
- lib/rspec/path_matchers/matchers/no_entry_matcher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Asserts that a directory entry of a specific entry_type does NOT exist. This is a simple, internal matcher-like object.
Instance Attribute Summary collapse
- #base_path ⇒ Object readonly private
- #entry_name ⇒ Object readonly private
- #entry_type ⇒ Object readonly private
- #path ⇒ Object readonly private
Instance Method Summary collapse
-
#collect_validation_errors(_errors) ⇒ Object
private
Called by DirectoryMatcher but is not needed for this simple matcher.
-
#description ⇒ Object
private
Provides a human-readable description for use in test output.
-
#execute_match(base_path) ⇒ Object
private
The core logic.
-
#failure_message ⇒ Object
private
The failure message if
execute_match
returnsfalse
. -
#failures ⇒ Array<String>
private
Returns the failure message in an array as expected by the DirectoryMatcher.
-
#initialize(entry_name, matcher_name:, entry_type:) ⇒ NoEntryMatcher
constructor
private
Initializes the matcher with the entry name and type.
Constructor Details
#initialize(entry_name, matcher_name:, entry_type:) ⇒ NoEntryMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the matcher with the entry name and type
21 22 23 24 25 26 27 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 21 def initialize(entry_name, matcher_name:, entry_type:) @entry_name = entry_name @matcher_name = matcher_name @entry_type = entry_type @base_path = nil @path = nil end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 11 def base_path @base_path end |
#entry_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 11 def entry_name @entry_name end |
#entry_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 11 def entry_type @entry_type end |
#path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 11 def path @path end |
Instance Method Details
#collect_validation_errors(_errors) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Called by DirectoryMatcher but is not needed for this simple matcher
60 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 60 def collect_validation_errors(_errors); end |
#description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Provides a human-readable description for use in test output.
55 56 57 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 55 def description "not have #{entry_type} #{entry_name.inspect}" end |
#execute_match(base_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The core logic. Returns true
if the expectation is met (the entry is absent).
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 30 def execute_match(base_path) # rubocop:disable Naming/PredicateMethod @base_path = base_path @path = File.join(base_path, entry_name) case entry_type when :file then !File.file?(path) when :directory then !File.directory?(path) else !File.symlink?(path) end end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The failure message if execute_match
returns false
.
42 43 44 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 42 def "expected #{entry_type} '#{entry_name}' not to be found at '#{base_path}', but it exists" end |
#failures ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the failure message in an array as expected by the DirectoryMatcher
50 51 52 |
# File 'lib/rspec/path_matchers/matchers/no_entry_matcher.rb', line 50 def failures [RSpec::PathMatchers::Failure.new('.', )] end |