lib/minitest/filesystem/matcher.rb in minitest-filesystem-0.1.0 vs lib/minitest/filesystem/matcher.rb in minitest-filesystem-1.0.0

- old
+ new

@@ -8,17 +8,17 @@ @expected_tree = block @is_matching = true end def file(file) - entry(:file, file) && is_a?(:file, file) + entry(file, :file) && is_a?(file, :file) end def dir(dir, &block) matcher = self.class.new(@actual_tree.expand_path(dir), &block) if block_given? - entry(:directory, dir) && is_a?(:directory, dir) && subtree(matcher) + entry(dir, :directory) && is_a?(dir, :directory) && subtree(matcher) end def match_found? instance_eval(&@expected_tree) @is_matching @@ -28,38 +28,38 @@ @failure_msg || "" end private - def entry(kind = :entry, entry) + def entry(entry, kind=:entry) update_matching_status( @actual_tree.include?(entry), - not_found_msg_for(kind, entry)) + not_found_msg_for(entry, kind)) end def subtree(matcher) update_matching_status(matcher.match_found?, matcher.message) if matcher end - def is_a?(kind, entry) + def is_a?(entry, kind) update_matching_status( - @actual_tree.is_a?(kind, entry), - mismatch_msg_for(kind, entry)) + @actual_tree.is_a?(entry, kind), + mismatch_msg_for(entry, kind)) end def update_matching_status(check, msg) @is_matching = @is_matching && check set_failure_msg(msg) unless @is_matching @is_matching end - def not_found_msg_for(kind, entry) + def not_found_msg_for(entry, kind) "Expected `#{@actual_tree.root}` to contain #{kind} `#{entry}`." end - def mismatch_msg_for(kind, entry) + def mismatch_msg_for(entry, kind) "Expected `#{entry}` to be a #{kind}, but it was not." end def set_failure_msg(msg) @failure_msg ||= msg @@ -75,10 +75,10 @@ def include?(entry) @tree.include?(expand_path(entry)) end - def is_a?(kind, entry) + def is_a?(entry, kind) (expand_path entry).send("#{kind}?") end def expand_path(file) @root + Pathname.new(file)