Class: Minitest::Filesystem::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/filesystem/matcher.rb

Defined Under Namespace

Classes: MatchingTree

Instance Method Summary collapse

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.expand_path(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


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

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/minitest/filesystem/matcher.rb', line 26

def match_found?
  instance_eval(&@expected_tree)
  @is_matching
end

#messageObject



31
32
33
# File 'lib/minitest/filesystem/matcher.rb', line 31

def message
  @failure_msg || ""
end