Class: Minitest::Filesystem::Matcher
- Inherits:
-
Object
- Object
- Minitest::Filesystem::Matcher
- Defined in:
- lib/minitest/filesystem/matcher.rb
Defined Under Namespace
Classes: MatchingTree
Instance Method Summary collapse
- #dir(dir, &block) ⇒ Object
- #file(file) ⇒ Object
-
#initialize(root, &block) ⇒ Matcher
constructor
A new instance of Matcher.
- #link(link, target = nil) ⇒ Object
- #match_found? ⇒ Boolean
- #message ⇒ Object
Constructor Details
#initialize(root, &block) ⇒ Matcher
Returns a new instance of Matcher.
6 7 8 9 10 |
# File 'lib/minitest/filesystem/matcher.rb', line 6 def initialize(root, &block) @actual_tree = MatchingTree.new(root) @expected_tree = block @is_matching = true end |
Instance Method Details
#dir(dir, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/minitest/filesystem/matcher.rb', line 20 def dir(dir, &block) matcher = self.class.new(@actual_tree.(dir), &block) if block_given? entry(dir, :directory) && is_a?(dir, :directory) && subtree(matcher) end |
#file(file) ⇒ Object
12 13 14 |
# File 'lib/minitest/filesystem/matcher.rb', line 12 def file(file) entry(file, :file) && is_a?(file, :file) end |
#link(link, target = nil) ⇒ Object
16 17 18 |
# File 'lib/minitest/filesystem/matcher.rb', line 16 def link(link, target=nil) entry(link, :symlink) && is_a?(link, :symlink) && is_target_correct?(link, target) end |
#match_found? ⇒ Boolean
26 27 28 29 |
# File 'lib/minitest/filesystem/matcher.rb', line 26 def match_found? instance_eval(&@expected_tree) @is_matching end |
#message ⇒ Object
31 32 33 |
# File 'lib/minitest/filesystem/matcher.rb', line 31 def @failure_msg || "" end |