Module: Minitest::Tagz::MinitestPatch

Defined in:
lib/minitest/tagz/minitest_patch.rb

Defined Under Namespace

Modules: RunnableMethodsPatch

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/minitest/tagz/minitest_patch.rb', line 4

def run(*args)
  # Check for no match and don't filter runnable methods if there would be no match
  if Tagz.run_all_if_no_match?
    run_map = Minitest::Runnable.runnables.reduce({}) {|memo, r| memo[r] = r.runnable_methods; memo}
    should_skip_filter = run_map.all? do |ctxt, methods|
      methods.all? do |m|
        serialized = Tagz.serialize(ctxt, m)
        tags = Tagz.tag_map[serialized]
        tags.nil? ||
          tags.empty? ||
          ((tags & Tagz.positive_tags).empty? &&
           (tags & Tagz.negative_tags).empty?)
      end
    end
    if should_skip_filter
      puts "Couldn't find any runnables with the given tag, running all runnables" if Tagz.log_if_no_match?
      return super
    end
  end

  Minitest::Test.singleton_class.class_eval { prepend(MinitestPatch::RunnableMethodsPatch) }
  super
end