Module: RSpec::PathMatchers
- Defined in:
- lib/rspec/path_matchers.rb,
lib/rspec/path_matchers/options.rb,
lib/rspec/path_matchers/version.rb,
lib/rspec/path_matchers/refinements.rb,
lib/rspec/path_matchers/options/base.rb,
lib/rspec/path_matchers/options/mode.rb,
lib/rspec/path_matchers/options/size.rb,
lib/rspec/path_matchers/matchers/base.rb,
lib/rspec/path_matchers/options/atime.rb,
lib/rspec/path_matchers/options/ctime.rb,
lib/rspec/path_matchers/options/group.rb,
lib/rspec/path_matchers/options/mtime.rb,
lib/rspec/path_matchers/options/owner.rb,
lib/rspec/path_matchers/options/content.rb,
lib/rspec/path_matchers/options/etc_base.rb,
lib/rspec/path_matchers/options/birthtime.rb,
lib/rspec/path_matchers/options/json_content.rb,
lib/rspec/path_matchers/options/yaml_content.rb,
lib/rspec/path_matchers/matchers/file_matcher.rb,
lib/rspec/path_matchers/options/symlink_atime.rb,
lib/rspec/path_matchers/options/symlink_ctime.rb,
lib/rspec/path_matchers/options/symlink_group.rb,
lib/rspec/path_matchers/options/symlink_mtime.rb,
lib/rspec/path_matchers/options/symlink_owner.rb,
lib/rspec/path_matchers/options/file_stat_base.rb,
lib/rspec/path_matchers/options/symlink_target.rb,
lib/rspec/path_matchers/matchers/symlink_matcher.rb,
lib/rspec/path_matchers/matchers/no_entry_matcher.rb,
lib/rspec/path_matchers/options/symlink_birthtime.rb,
lib/rspec/path_matchers/matchers/directory_matcher.rb,
lib/rspec/path_matchers/options/parsed_content_base.rb,
lib/rspec/path_matchers/options/symlink_target_type.rb,
lib/rspec/path_matchers/options/symlink_target_exist.rb
Overview
A collection of matchers for testing directory entries
This module provides the main DSL methods for use in RSpec tests.
Defined Under Namespace
Modules: Matchers, Options, Refinements
Constant Summary collapse
- Failure =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
A simple, immutable structure to hold failure data internally.
Data.define(:relative_path, :message)
- VERSION =
'0.2.2'
Top-Level Matchers collapse
-
#be_dir(**options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
Creates a matcher that tests if the subject path is a directory.
-
#be_file(**options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
Creates a matcher that tests if the subject path is a file.
-
#be_symlink(**options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
Creates a matcher that tests if the subject path is a symbolic link.
Top-Level Child Matchers collapse
-
#have_dir(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
A matcher to test if the subject path has a child directory with the given name.
-
#have_file(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
A matcher to test if the subject path has a child file with the given name.
-
#have_symlink(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
A matcher to test if the subject path has a child symlink with the given name.
Nested Entry Declarations collapse
-
#dir(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
Declares an expectation for a directory within a directory.
-
#file(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
Declares an expectation for a file within a directory.
-
#no_dir_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a directory with the given name does NOT exist.
-
#no_file_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a file with the given name does NOT exist.
-
#no_symlink_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a symlink with the given name does NOT exist.
-
#symlink(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
Declares an expectation for a symbolic link within a directory.
Class Method Summary collapse
-
.matcher?(object) ⇒ Boolean
private
Returns true if object is a matcher.
Class Method Details
.matcher?(object) ⇒ Boolean
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 true if object is a matcher
24 25 26 |
# File 'lib/rspec/path_matchers.rb', line 24 def self.matcher?(object) object.respond_to?(:matches?) && object.respond_to?(:description) end |
Instance Method Details
#be_dir(**options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
Creates a matcher that tests if the subject path is a directory
46 47 48 |
# File 'lib/rspec/path_matchers.rb', line 46 def be_dir(**) RSpec::PathMatchers::Matchers::DirectoryMatcher.new('', matcher_name: __method__, **) end |
#be_file(**options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
Creates a matcher that tests if the subject path is a file
58 59 60 |
# File 'lib/rspec/path_matchers.rb', line 58 def be_file(**) RSpec::PathMatchers::Matchers::FileMatcher.new('', matcher_name: __method__, **) end |
#be_symlink(**options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
Creates a matcher that tests if the subject path is a symbolic link
70 71 72 |
# File 'lib/rspec/path_matchers.rb', line 70 def be_symlink(**) RSpec::PathMatchers::Matchers::SymlinkMatcher.new('', matcher_name: __method__, **) end |
#dir(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
Declares an expectation for a directory within a directory
Intended for use as an argument to #containing or #containing_exactly.
141 142 143 |
# File 'lib/rspec/path_matchers.rb', line 141 def dir(name, **) RSpec::PathMatchers::Matchers::DirectoryMatcher.new(name, matcher_name: __method__, **) end |
#file(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
Declares an expectation for a file within a directory
Intended for use as an argument to #containing or #containing_exactly.
129 130 131 |
# File 'lib/rspec/path_matchers.rb', line 129 def file(name, **) RSpec::PathMatchers::Matchers::FileMatcher.new(name, matcher_name: __method__, **) end |
#have_dir(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::DirectoryMatcher
A matcher to test if the subject path has a child directory with the given name
87 88 89 |
# File 'lib/rspec/path_matchers.rb', line 87 def have_dir(entry_name, **) # rubocop:disable Naming/PredicatePrefix RSpec::PathMatchers::Matchers::DirectoryMatcher.new(entry_name, matcher_name: __method__, **) end |
#have_file(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::FileMatcher
A matcher to test if the subject path has a child file with the given name
100 101 102 |
# File 'lib/rspec/path_matchers.rb', line 100 def have_file(entry_name, **) # rubocop:disable Naming/PredicatePrefix RSpec::PathMatchers::Matchers::FileMatcher.new(entry_name, matcher_name: __method__, **) end |
#have_symlink(entry_name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
A matcher to test if the subject path has a child symlink with the given name
113 114 115 |
# File 'lib/rspec/path_matchers.rb', line 113 def have_symlink(entry_name, **) # rubocop:disable Naming/PredicatePrefix RSpec::PathMatchers::Matchers::SymlinkMatcher.new(entry_name, matcher_name: __method__, **) end |
#no_dir_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a directory with the given name does NOT exist
Intended for use as an argument to #containing or #containing_exactly.
164 165 166 |
# File 'lib/rspec/path_matchers.rb', line 164 def no_dir_named(name) RSpec::PathMatchers::Matchers::NoEntryMatcher.new(name, matcher_name: __method__, entry_type: :directory) end |
#no_file_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a file with the given name does NOT exist
Intended for use as an argument to #containing or #containing_exactly.
175 176 177 |
# File 'lib/rspec/path_matchers.rb', line 175 def no_file_named(name) RSpec::PathMatchers::Matchers::NoEntryMatcher.new(name, matcher_name: __method__, entry_type: :file) end |
#no_symlink_named(name) ⇒ RSpec::PathMatchers::Matchers::NoEntryMatcher
Declares an expectation that a symlink with the given name does NOT exist
Intended for use as an argument to #containing or #containing_exactly.
186 187 188 |
# File 'lib/rspec/path_matchers.rb', line 186 def no_symlink_named(name) RSpec::PathMatchers::Matchers::NoEntryMatcher.new(name, matcher_name: __method__, entry_type: :symlink) end |
#symlink(name, **options_hash) ⇒ RSpec::PathMatchers::Matchers::SymlinkMatcher
Declares an expectation for a symbolic link within a directory
Intended for use as an argument to #containing or #containing_exactly.
153 154 155 |
# File 'lib/rspec/path_matchers.rb', line 153 def symlink(name, **) RSpec::PathMatchers::Matchers::SymlinkMatcher.new(name, matcher_name: __method__, **) end |