File: focus_plugin.rb

package info (click to toggle)
ruby-minitest-focus 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112 kB
  • sloc: ruby: 65; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 751 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Minitest
  def self.plugin_focus_options opts, options
    opts.on "--no-focus", "Disable `focus` calls in tests." do |n|
      @nofocus = true
    end
  end

  def self.plugin_focus_init options # :nodoc:
    return unless Minitest::Test.respond_to? :filtered_names
    return if Minitest::Test.filtered_names.empty?

    if options[:filter] then
      order = %w[ `focus` --name ]
      a, b = @nofocus ? order : order.reverse
      extra = " Use --no-focus to override." unless @nofocus
      warn "Ignoring #{a} filters in favor of #{b} filters.#{extra}"
      warn ""
    end

    return if @nofocus

    re = "/^(#{Regexp.union(Minitest::Test.filtered_names).source})$/"
    options[:filter] = re
  end
end