maxitest 6.1.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -6
- data/lib/maxitest/autorun.rb +14 -5
- data/lib/maxitest/global_must.rb +37 -13
- data/lib/maxitest/helpers.rb +17 -20
- data/lib/maxitest/hook_all.rb +1 -0
- data/lib/maxitest/implicit_subject.rb +3 -2
- data/lib/maxitest/interrupt.rb +2 -2
- data/lib/maxitest/let_all.rb +1 -0
- data/lib/maxitest/let_bang.rb +1 -0
- data/lib/maxitest/line.rb +68 -0
- data/lib/maxitest/pending.rb +7 -4
- data/lib/maxitest/shorted_backtrace.rb +10 -7
- data/lib/maxitest/static_class_order.rb +2 -1
- data/lib/maxitest/threads.rb +2 -1
- data/lib/maxitest/timeout.rb +2 -3
- data/lib/maxitest/vendor/around.rb +5 -5
- data/lib/maxitest/verbose_backtrace.rb +21 -19
- data/lib/maxitest/version.rb +2 -1
- metadata +8 -14
- data/bin/mtest +0 -34
- data/lib/maxitest/vendor/line.rb +0 -122
- data/lib/maxitest/vendor/line_describe.rb +0 -16
- data/lib/maxitest/vendor/testrbl.rb +0 -194
- data/lib/maxitest.rb +0 -2
- data/lib/minitest/maxitest_plugin.rb +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 982184ff34c2a4958c9e52ebc4906d861a9c18caa3af656940e0cd1d7918d2c4
|
|
4
|
+
data.tar.gz: e282741931d6eac6b10a2bed360c7fa6fd67121e307e2450fa264ff62f5251ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dac139633277d2b16ef1c01cd34c5ddf4948de2dacc0ed7fd5974207b89fec846ecb6e1b88595b4c8ee5e685bcdf4bb6e0e0ed1ae39e4ef1c2e8ca04fe115853
|
|
7
|
+
data.tar.gz: 456476d7ec079121af8ef2e1c8640370494efd9bc062f59f03052e10ced0be8e1c11fec5ca7772a20f335e88c57a4a7c8d4053fff4458cbabd8bcef7b59f62bb
|
data/README.md
CHANGED
|
@@ -12,7 +12,6 @@ Features
|
|
|
12
12
|
- `before :all` blocks
|
|
13
13
|
- **around** blocks `around { |t| Dir.chdir(...) { t.call } }`
|
|
14
14
|
- **red-green** output (disabled/integrated on rails 5)
|
|
15
|
-
- `mtest` executable to **run by line number** and by folder (disabled/integrated on rails 5)
|
|
16
15
|
- full backtrace for errors and assertions with verbose (`-v`)
|
|
17
16
|
- `let!`
|
|
18
17
|
- `let_all` execute once for all tests in a class and it's subclasses
|
|
@@ -26,7 +25,7 @@ Features
|
|
|
26
25
|
- `capture_stdout` and `capture_stderr` to capture stdout or stderr but not both (like `capture_io` does)
|
|
27
26
|
- `require 'maxitest/timeout'` to make hanging tests fail after `Maxitest.timeout` seconds
|
|
28
27
|
- `require 'maxitest/threads'` fail tests that leave extra threads running
|
|
29
|
-
- `require 'maxitest/global_must'` (before autorun)
|
|
28
|
+
- `require 'maxitest/global_must'` (before autorun) enable global `must_*` methods on all objects
|
|
30
29
|
|
|
31
30
|
Install
|
|
32
31
|
=======
|
|
@@ -53,8 +52,8 @@ end
|
|
|
53
52
|
|
|
54
53
|
### pending
|
|
55
54
|
|
|
56
|
-
- `pending "need to fix" do` to show why something is pending
|
|
57
|
-
- `pending "need to fix", if: ENV["CI"] do` to only skip on CI (if something is supposed to work locally)
|
|
55
|
+
- `pending "need to fix" do` to show why something is pending
|
|
56
|
+
- `pending "need to fix", if: ENV["CI"] do` to only skip on CI (if something is supposed to work locally)
|
|
58
57
|
|
|
59
58
|
### with_env
|
|
60
59
|
|
|
@@ -97,9 +96,7 @@ Development
|
|
|
97
96
|
|
|
98
97
|
Author
|
|
99
98
|
======
|
|
100
|
-
- running by line number from [minitest-line](https://github.com/judofyr/minitest-line)
|
|
101
99
|
- around from [minitest-around](https://github.com/splattael/minitest-around)
|
|
102
|
-
- mtest from [testrbl](https://github.com/grosser/testrbl)
|
|
103
100
|
- red-green from [minitest-rg](https://github.com/blowmage/minitest-rg)
|
|
104
101
|
|
|
105
102
|
[Michael Grosser](http://grosser.it)<br>
|
data/lib/maxitest/autorun.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require "minitest"
|
|
2
3
|
require "minitest/autorun"
|
|
4
|
+
|
|
3
5
|
require "maxitest/vendor/around"
|
|
4
6
|
require "maxitest/interrupt" unless ENV["MAXITEST_NO_INTERRUPT"]
|
|
5
7
|
require "maxitest/let_bang"
|
|
@@ -10,19 +12,26 @@ require "maxitest/helpers"
|
|
|
10
12
|
require "maxitest/xit"
|
|
11
13
|
require "maxitest/static_class_order"
|
|
12
14
|
require "maxitest/shorted_backtrace"
|
|
13
|
-
require "maxitest/vendor/line_describe" # not a plugin
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
unless Gem::Specification.find_all_by_name("rails").any? # rails adds default red/green output
|
|
17
|
+
require "maxitest/vendor/rg"
|
|
18
|
+
Minitest.extensions << "rg"
|
|
19
|
+
Minitest::RG.rg! $stdout.tty?
|
|
17
20
|
end
|
|
18
21
|
|
|
22
|
+
require "maxitest/verbose_backtrace"
|
|
23
|
+
Minitest.extensions << Maxitest::VerboseBacktrace::MinitestPlugin
|
|
24
|
+
|
|
25
|
+
require "maxitest/line"
|
|
26
|
+
Minitest.extensions << Maxitest::Line::MinitestPlugin
|
|
27
|
+
|
|
19
28
|
Minitest::Spec::DSL.send(:alias_method, :context, :describe)
|
|
20
29
|
|
|
21
30
|
class << Minitest::Test
|
|
22
|
-
|
|
31
|
+
alias order_dependent! i_suck_and_my_tests_are_order_dependent!
|
|
23
32
|
end
|
|
24
33
|
|
|
25
34
|
# do not show maxitest as causing errors, but the last line in the users code
|
|
26
35
|
old = Minitest::BacktraceFilter::MT_RE
|
|
27
36
|
Minitest::BacktraceFilter.send(:remove_const, :MT_RE)
|
|
28
|
-
Minitest::BacktraceFilter::MT_RE = Regexp.union(old, %r
|
|
37
|
+
Minitest::BacktraceFilter::MT_RE = Regexp.union(old, %r{lib/maxitest})
|
data/lib/maxitest/global_must.rb
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Allow .must_* and .wont_* assertions on all objects
|
|
3
|
+
# this was removed from minitest v6
|
|
2
4
|
#
|
|
3
5
|
# Must be required before maxitest/autorun
|
|
4
|
-
Module.prepend(Module.new do
|
|
5
|
-
def infect_an_assertion(_, new_name, *)
|
|
6
|
-
super # define with deprecation
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
require "minitest"
|
|
8
|
+
require "minitest/spec"
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
EOM
|
|
10
|
+
module Maxitest
|
|
11
|
+
# Track current test instance for global must_* support
|
|
12
|
+
def self.current_test
|
|
13
|
+
Thread.current[:maxitest_current_test]
|
|
17
14
|
end
|
|
18
|
-
|
|
15
|
+
|
|
16
|
+
def self.current_test=(test)
|
|
17
|
+
Thread.current[:maxitest_current_test] = test
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Track the current test instance using prepend on run
|
|
22
|
+
Minitest::Test.prepend(
|
|
23
|
+
Module.new do
|
|
24
|
+
def run
|
|
25
|
+
Maxitest.current_test = self
|
|
26
|
+
super
|
|
27
|
+
ensure
|
|
28
|
+
Maxitest.current_test = nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# Define global must_* methods on Object
|
|
34
|
+
# This mimics what mintest 5 infect_an_assertion used to do
|
|
35
|
+
expectation_methods = Minitest::Expectation.instance_methods - Object.instance_methods
|
|
36
|
+
expectation_methods.grep(/^must_|^wont_/).each do |meth|
|
|
37
|
+
Object.define_method(meth) do |*args, &block|
|
|
38
|
+
ctx = Maxitest.current_test ||
|
|
39
|
+
raise(NotImplementedError, "Global #{meth} called outside of test context")
|
|
40
|
+
Minitest::Expectation.new(self, ctx).public_send(meth, *args, &block)
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/maxitest/helpers.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Maxitest
|
|
2
3
|
module Helpers
|
|
3
4
|
module InstanceMethods
|
|
@@ -14,30 +15,26 @@ module Maxitest
|
|
|
14
15
|
# stripped down version of capture_io
|
|
15
16
|
def capture_stdout
|
|
16
17
|
_synchronize do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
$stdout = orig_stdout
|
|
25
|
-
end
|
|
18
|
+
captured_stdout = StringIO.new
|
|
19
|
+
orig_stdout = $stdout
|
|
20
|
+
$stdout = captured_stdout
|
|
21
|
+
yield
|
|
22
|
+
return captured_stdout.string
|
|
23
|
+
ensure
|
|
24
|
+
$stdout = orig_stdout
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
# stripped down version of capture_io
|
|
30
29
|
def capture_stderr
|
|
31
30
|
_synchronize do
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
$stderr = orig_stderr
|
|
40
|
-
end
|
|
31
|
+
captured_stderr = StringIO.new
|
|
32
|
+
orig_stderr = $stderr
|
|
33
|
+
$stderr = captured_stderr
|
|
34
|
+
yield
|
|
35
|
+
return captured_stderr.string
|
|
36
|
+
ensure
|
|
37
|
+
$stderr = orig_stderr
|
|
41
38
|
end
|
|
42
39
|
end
|
|
43
40
|
end
|
|
@@ -50,5 +47,5 @@ module Maxitest
|
|
|
50
47
|
end
|
|
51
48
|
end
|
|
52
49
|
|
|
53
|
-
Minitest::Test.
|
|
54
|
-
Minitest::Test.
|
|
50
|
+
Minitest::Test.include Maxitest::Helpers::InstanceMethods
|
|
51
|
+
Minitest::Test.extend Maxitest::Helpers::ClassMethods
|
data/lib/maxitest/hook_all.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# this is a bit hacky / overwrites describe, so not included by default ...
|
|
2
3
|
module Maxitest
|
|
3
4
|
module ImplicitSubject
|
|
4
5
|
def describe(*args, &block)
|
|
5
6
|
klass = super
|
|
6
|
-
if args.first.is_a?(Class) && !klass.
|
|
7
|
+
if args.first.is_a?(Class) && !klass.method_defined?(:subject, false)
|
|
7
8
|
klass.let(:subject) { args.first.new }
|
|
8
9
|
end
|
|
9
10
|
klass
|
|
@@ -11,4 +12,4 @@ module Maxitest
|
|
|
11
12
|
end
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
Object.
|
|
15
|
+
Object.include Maxitest::ImplicitSubject # Minitest hacks Kernel -> we need to use alias method or go into Object
|
data/lib/maxitest/interrupt.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Maxitest
|
|
|
12
12
|
module InterruptHandler
|
|
13
13
|
# capture interrupt and treat it as a regular error so we get a backtrace
|
|
14
14
|
def capture_exceptions(&block)
|
|
15
|
-
super
|
|
15
|
+
super
|
|
16
16
|
rescue Interrupt => e
|
|
17
17
|
Maxitest.interrupted = true
|
|
18
18
|
failures << Minitest::UnexpectedError.new(e)
|
|
@@ -32,7 +32,7 @@ module Maxitest
|
|
|
32
32
|
result.time = 0
|
|
33
33
|
result
|
|
34
34
|
else
|
|
35
|
-
super
|
|
35
|
+
super
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
data/lib/maxitest/let_all.rb
CHANGED
data/lib/maxitest/let_bang.rb
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# https://raw.githubusercontent.com/judofyr/minitest-line/master/MIT-LICENSE.txt
|
|
3
|
+
=begin
|
|
4
|
+
Copyright (c) 2014 Magnus Holm
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
=end
|
|
25
|
+
|
|
26
|
+
# https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line_plugin.rb
|
|
27
|
+
module Maxitest
|
|
28
|
+
module Line
|
|
29
|
+
module MinitestPlugin
|
|
30
|
+
def self.minitest_plugin_init(options)
|
|
31
|
+
return if options[:include] # do not re-print when already filtered
|
|
32
|
+
Minitest.reporter.reporters << LineReporter.new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class LineReporter < Minitest::Reporter
|
|
37
|
+
def initialize(*)
|
|
38
|
+
super
|
|
39
|
+
@failures = []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def record(result)
|
|
43
|
+
if !result.skipped? && !result.passed?
|
|
44
|
+
@failures << result
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def report
|
|
49
|
+
return unless @failures.any?
|
|
50
|
+
io.puts
|
|
51
|
+
io.puts "Focus on failing tests:"
|
|
52
|
+
pwd = Pathname.new(Dir.pwd)
|
|
53
|
+
bin_rails = File.exist?("bin/rails")
|
|
54
|
+
@failures.each do |res|
|
|
55
|
+
result = (res.respond_to?(:source_location) ? res : res.method(res.name))
|
|
56
|
+
file, line = result.source_location
|
|
57
|
+
next unless file
|
|
58
|
+
|
|
59
|
+
file = Pathname.new(file)
|
|
60
|
+
file = file.relative_path_from(pwd) if file.absolute?
|
|
61
|
+
output = "#{bin_rails ? "bin/rails test" : "minitest"} #{file}:#{line}"
|
|
62
|
+
output = "\e[31m#{output}\e[0m" if $stdout.tty?
|
|
63
|
+
io.puts output
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/maxitest/pending.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Maxitest
|
|
2
3
|
module Pending
|
|
3
|
-
def pending(reason=nil, **kwargs)
|
|
4
|
+
def pending(reason = nil, **kwargs)
|
|
4
5
|
raise ArgumentError, "Need a block to execute" unless block_given?
|
|
5
|
-
raise ArgumentError, "Only :if option is supported" if (kwargs.keys | [:if] != [:if]
|
|
6
|
-
|
|
6
|
+
raise ArgumentError, "Only :if option is supported" if (kwargs.keys | [:if]) != [:if]
|
|
7
|
+
|
|
8
|
+
# allow user to for example mark test only pending on CI with `if: ENV["CI"]`
|
|
9
|
+
return yield if kwargs.fetch(:if, true) == false
|
|
7
10
|
|
|
8
11
|
begin
|
|
9
12
|
yield # execute test
|
|
@@ -16,4 +19,4 @@ module Maxitest
|
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
Minitest::Test.
|
|
22
|
+
Minitest::Test.include Maxitest::Pending
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
Minitest::BacktraceFilter.prepend(
|
|
3
|
+
Module.new do
|
|
4
|
+
def filter(*)
|
|
5
|
+
backtrace = super
|
|
6
|
+
pwd = "#{Dir.pwd}/"
|
|
7
|
+
section = pwd.size..-1
|
|
8
|
+
backtrace.map { |b| b.start_with?(pwd) ? b[section] : b }
|
|
9
|
+
end
|
|
7
10
|
end
|
|
8
|
-
|
|
11
|
+
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Maxitest
|
|
2
3
|
class << self
|
|
3
4
|
attr_accessor :static_class_order
|
|
@@ -5,7 +6,7 @@ module Maxitest
|
|
|
5
6
|
end
|
|
6
7
|
|
|
7
8
|
class << Minitest::Runnable
|
|
8
|
-
|
|
9
|
+
alias runnables_without_static_order runnables
|
|
9
10
|
|
|
10
11
|
def runnables
|
|
11
12
|
return runnables_without_static_order unless Maxitest.static_class_order
|
data/lib/maxitest/threads.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# tests that leave extra threads running can break other tests in weird ways ... prevent that from happening
|
|
2
3
|
|
|
3
4
|
module Maxitest
|
|
@@ -34,4 +35,4 @@ end
|
|
|
34
35
|
|
|
35
36
|
# not using prepend since that would clash with webmock
|
|
36
37
|
# include works because original setup lives in also included Minitest::LifecycleHooks
|
|
37
|
-
Minitest::Test.
|
|
38
|
+
Minitest::Test.include Maxitest::Threads
|
data/lib/maxitest/timeout.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# tests sometimes hang locally or on ci and with this we can actually debug the cause instead of just hanging forever
|
|
2
3
|
require 'timeout'
|
|
3
4
|
|
|
@@ -29,6 +30,4 @@ module Maxitest
|
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
Minitest::Test.
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
Minitest::Test.prepend Maxitest::Timeout
|
|
@@ -36,18 +36,18 @@ end
|
|
|
36
36
|
|
|
37
37
|
# BEGIN generated by rake update, do not modify
|
|
38
38
|
# https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/unit.rb
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
# Modified for MT6 compatibility using prepend instead of alias_method
|
|
40
|
+
Minitest::Test.prepend(Module.new do
|
|
41
41
|
def run(*args)
|
|
42
42
|
if defined?(around)
|
|
43
43
|
result = nil
|
|
44
|
-
around { result =
|
|
44
|
+
around { result = super(*args) }
|
|
45
45
|
result
|
|
46
46
|
else
|
|
47
|
-
|
|
47
|
+
super(*args)
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
-
end
|
|
50
|
+
end)
|
|
51
51
|
# END generated by rake update, do not modify
|
|
52
52
|
|
|
53
53
|
# BEGIN generated by rake update, do not modify
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Maxitest
|
|
2
3
|
module VerboseBacktrace
|
|
3
4
|
class NullFilter
|
|
@@ -6,30 +7,31 @@ module Maxitest
|
|
|
6
7
|
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
# when printing messages print more if verbose was enabled
|
|
11
|
+
module Assertion
|
|
12
|
+
def message
|
|
13
|
+
if Maxitest::VerboseBacktrace.enabled
|
|
14
|
+
"#{self.class}: #{super}\n #{backtrace.join "\n "}"
|
|
15
|
+
else
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
11
19
|
end
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
module MinitestPlugin
|
|
22
|
+
def self.minitest_plugin_init(options)
|
|
23
|
+
return unless options[:verbose]
|
|
24
|
+
Maxitest::VerboseBacktrace.enabled = true
|
|
25
|
+
Minitest.backtrace_filter = Maxitest::VerboseBacktrace::NullFilter
|
|
26
|
+
# rails has --backtrace which disables rails own backtrace cleaner, but not minitests
|
|
27
|
+
Rails.backtrace_cleaner.remove_silencers! if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
|
|
28
|
+
end
|
|
18
29
|
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
Minitest.extensions << 'maxitest_verbose_backtrace'
|
|
23
|
-
Minitest.extend Maxitest::VerboseBacktrace
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if Maxitest::VerboseBacktrace.verbose
|
|
28
|
-
"#{self.class}: #{super}\n #{backtrace.join "\n "}"
|
|
29
|
-
else
|
|
30
|
-
super
|
|
31
|
+
class << self
|
|
32
|
+
attr_accessor :enabled
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
35
|
-
Minitest::Assertion.
|
|
37
|
+
Minitest::Assertion.include Maxitest::VerboseBacktrace::Assertion
|
data/lib/maxitest/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: maxitest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 7.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Grosser
|
|
@@ -15,20 +15,20 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 6.0.0
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
21
|
+
version: 6.1.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version:
|
|
28
|
+
version: 6.0.0
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version:
|
|
31
|
+
version: 6.1.0
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: rake
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,16 +58,13 @@ dependencies:
|
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '0'
|
|
60
60
|
email: michael@grosser.it
|
|
61
|
-
executables:
|
|
62
|
-
- mtest
|
|
61
|
+
executables: []
|
|
63
62
|
extensions: []
|
|
64
63
|
extra_rdoc_files: []
|
|
65
64
|
files:
|
|
66
65
|
- CHANGELOG.md
|
|
67
66
|
- MIT-LICENSE
|
|
68
67
|
- README.md
|
|
69
|
-
- bin/mtest
|
|
70
|
-
- lib/maxitest.rb
|
|
71
68
|
- lib/maxitest/autorun.rb
|
|
72
69
|
- lib/maxitest/global_must.rb
|
|
73
70
|
- lib/maxitest/helpers.rb
|
|
@@ -76,20 +73,17 @@ files:
|
|
|
76
73
|
- lib/maxitest/interrupt.rb
|
|
77
74
|
- lib/maxitest/let_all.rb
|
|
78
75
|
- lib/maxitest/let_bang.rb
|
|
76
|
+
- lib/maxitest/line.rb
|
|
79
77
|
- lib/maxitest/pending.rb
|
|
80
78
|
- lib/maxitest/shorted_backtrace.rb
|
|
81
79
|
- lib/maxitest/static_class_order.rb
|
|
82
80
|
- lib/maxitest/threads.rb
|
|
83
81
|
- lib/maxitest/timeout.rb
|
|
84
82
|
- lib/maxitest/vendor/around.rb
|
|
85
|
-
- lib/maxitest/vendor/line.rb
|
|
86
|
-
- lib/maxitest/vendor/line_describe.rb
|
|
87
83
|
- lib/maxitest/vendor/rg.rb
|
|
88
|
-
- lib/maxitest/vendor/testrbl.rb
|
|
89
84
|
- lib/maxitest/verbose_backtrace.rb
|
|
90
85
|
- lib/maxitest/version.rb
|
|
91
86
|
- lib/maxitest/xit.rb
|
|
92
|
-
- lib/minitest/maxitest_plugin.rb
|
|
93
87
|
homepage: https://github.com/grosser/maxitest
|
|
94
88
|
licenses:
|
|
95
89
|
- MIT
|
|
@@ -104,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
104
98
|
version: '3.2'
|
|
105
99
|
- - "<"
|
|
106
100
|
- !ruby/object:Gem::Version
|
|
107
|
-
version: '
|
|
101
|
+
version: '4.1'
|
|
108
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
103
|
requirements:
|
|
110
104
|
- - ">="
|
data/bin/mtest
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# parse raw -v but not verbose
|
|
4
|
-
if ARGV == ["-v"] || ARGV == ["--version"]
|
|
5
|
-
puts Maxitest::VERSION
|
|
6
|
-
exit 0
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
# parse raw -h
|
|
10
|
-
if ARGV == ["-h"] || ARGV == ["--help"]
|
|
11
|
-
puts <<~EOF
|
|
12
|
-
test given file, folder or file:line
|
|
13
|
-
Usage: mtest foo_test.rb
|
|
14
|
-
|
|
15
|
-
-v to run without bracktrace cleaner
|
|
16
|
-
--changed to run all all tests in current `git diff` or `git show`
|
|
17
|
-
EOF
|
|
18
|
-
exit 0
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# send rest to testrbl to get --changed support, but do not guess at lines but just convert number to -l
|
|
22
|
-
# so minitest-line picks it up
|
|
23
|
-
require 'optparse'
|
|
24
|
-
|
|
25
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
26
|
-
require 'maxitest/vendor/testrbl'
|
|
27
|
-
|
|
28
|
-
class << Maxitest::Testrbl
|
|
29
|
-
def line_pattern_option(file, line)
|
|
30
|
-
[file, "-l", line]
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
Maxitest::Testrbl.run_from_cli(ARGV)
|
data/lib/maxitest/vendor/line.rb
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# BEGIN generated by rake update, do not modify
|
|
2
|
-
# https://raw.githubusercontent.com/judofyr/minitest-line/master/MIT-LICENSE.txt
|
|
3
|
-
=begin
|
|
4
|
-
Copyright (c) 2014 Magnus Holm
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
-
a copy of this software and associated documentation files (the
|
|
8
|
-
"Software"), to deal in the Software without restriction, including
|
|
9
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
-
the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be
|
|
15
|
-
included in all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
=end
|
|
25
|
-
# END generated by rake update, do not modify
|
|
26
|
-
|
|
27
|
-
# BEGIN generated by rake update, do not modify
|
|
28
|
-
# https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line_plugin.rb
|
|
29
|
-
module Minitest
|
|
30
|
-
module Line
|
|
31
|
-
class << self
|
|
32
|
-
def tests_with_lines
|
|
33
|
-
target_file = $0
|
|
34
|
-
methods_with_lines(target_file).concat describes_with_lines(target_file)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
def methods_with_lines(target_file)
|
|
40
|
-
runnables.flat_map do |runnable|
|
|
41
|
-
rname = runnable.name
|
|
42
|
-
runnable.runnable_methods.map do |name|
|
|
43
|
-
file, line = runnable.instance_method(name).source_location
|
|
44
|
-
next unless file == target_file
|
|
45
|
-
test_name = (rname ? "#{rname}##{name}" : name)
|
|
46
|
-
[test_name, line]
|
|
47
|
-
end
|
|
48
|
-
end.uniq.compact
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def describes_with_lines(target_file)
|
|
52
|
-
runnables.map do |runnable|
|
|
53
|
-
next unless caller = runnable.instance_variable_defined?(:@minitest_line_caller) && runnable.instance_variable_get(:@minitest_line_caller)
|
|
54
|
-
next unless line = caller.detect { |l| l.include?(target_file) }
|
|
55
|
-
["/#{Regexp.escape(runnable.name)}/", line[/:(\d+):in/, 1].to_i]
|
|
56
|
-
end.compact
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def runnables
|
|
60
|
-
Minitest::Runnable.runnables
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def self.plugin_line_options(opts, options)
|
|
66
|
-
opts.on '-l', '--line N', Integer, "Run test at line number" do |lineno|
|
|
67
|
-
options[:line] = lineno
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def self.plugin_line_init(options)
|
|
72
|
-
unless exp_line = options[:line]
|
|
73
|
-
reporter.reporters << LineReporter.new
|
|
74
|
-
return
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
tests = Minitest::Line.tests_with_lines
|
|
78
|
-
|
|
79
|
-
filter, _ = tests.sort_by { |n, l| -l }.detect { |n, l| exp_line >= l }
|
|
80
|
-
|
|
81
|
-
raise "Could not find test method before line #{exp_line}" unless filter
|
|
82
|
-
|
|
83
|
-
options[:filter] = filter
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
class LineReporter < Reporter
|
|
87
|
-
def initialize(*)
|
|
88
|
-
super
|
|
89
|
-
@failures = []
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def record(result)
|
|
93
|
-
if !result.skipped? && !result.passed?
|
|
94
|
-
@failures << result
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def report
|
|
99
|
-
return unless @failures.any?
|
|
100
|
-
io.puts
|
|
101
|
-
io.puts "Focus on failing tests:"
|
|
102
|
-
pwd = Pathname.new(Dir.pwd)
|
|
103
|
-
bin_rails = File.exist?("bin/rails")
|
|
104
|
-
@failures.each do |res|
|
|
105
|
-
result = (res.respond_to?(:source_location) ? res : res.method(res.name))
|
|
106
|
-
file, line = result.source_location
|
|
107
|
-
|
|
108
|
-
if file
|
|
109
|
-
file = Pathname.new(file)
|
|
110
|
-
file = file.relative_path_from(pwd) if file.absolute?
|
|
111
|
-
output = "#{bin_rails ? "bin/rails test" : "mtest"} #{file}:#{line}"
|
|
112
|
-
output = "\e[31m#{output}\e[0m" if $stdout.tty?
|
|
113
|
-
io.puts output
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def self.plugin_line_inject_reporter
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
# END generated by rake update, do not modify
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# BEGIN generated by rake update, do not modify
|
|
2
|
-
# https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line/describe_track.rb
|
|
3
|
-
module Minitest
|
|
4
|
-
module Line
|
|
5
|
-
module DescribeTrack
|
|
6
|
-
def describe(*args, &block)
|
|
7
|
-
klass = super
|
|
8
|
-
klass.instance_variable_set(:@minitest_line_caller, caller(0..5))
|
|
9
|
-
klass
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
Object.send(:include, Minitest::Line::DescribeTrack)
|
|
16
|
-
# END generated by rake update, do not modify
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
# BEGIN generated by rake update, do not modify
|
|
2
|
-
# https://raw.githubusercontent.com/grosser/testrbl/master/lib/testrbl.rb
|
|
3
|
-
module Maxitest
|
|
4
|
-
module Testrbl
|
|
5
|
-
PATTERNS = [
|
|
6
|
-
/^(\s+)(should|test|it)(\s+|\s*\(\s*)['"](.*)['"](\s*\))?\s+do\s*(?:#.*)?$/,
|
|
7
|
-
/^(\s+)(context|describe)(\s+|\s*\(\s*)['"]?(.*?)['"]?(\s*\))?\s+do\s*(?:#.*)?$/,
|
|
8
|
-
/^(\s+)def(\s+)(test_)([a-z_\d]+)\s*(?:#.*)?$/
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "--name", "-e", "--exclude", "-s", "--seed"]
|
|
12
|
-
INTERPOLATION = /\\\#\\\{.*?\\\}/
|
|
13
|
-
|
|
14
|
-
class << self
|
|
15
|
-
def run_from_cli(argv)
|
|
16
|
-
files, options = partition_argv(argv)
|
|
17
|
-
files.concat(changed_files) if options.delete("--changed")
|
|
18
|
-
files = ["test"] if files.empty?
|
|
19
|
-
files = files.map { |f| localize(f) }
|
|
20
|
-
load_options, options = partition_options(options)
|
|
21
|
-
|
|
22
|
-
if files.size == 1 and files.first =~ /^(\S+):(\d+)$/
|
|
23
|
-
file = $1
|
|
24
|
-
line = $2
|
|
25
|
-
run(ruby + load_options + line_pattern_option(file, line) + options)
|
|
26
|
-
else
|
|
27
|
-
if files.size == 1 and File.file?(files.first)
|
|
28
|
-
run(ruby + load_options + files + options)
|
|
29
|
-
elsif options.none? { |arg| arg =~ /^-n/ }
|
|
30
|
-
seed = if seed = options.index("--seed")
|
|
31
|
-
["--"] + options.slice!(seed, 2)
|
|
32
|
-
else
|
|
33
|
-
[]
|
|
34
|
-
end
|
|
35
|
-
files = files.map { |f| File.directory?(f) ? all_test_files_in(f) : f }.flatten
|
|
36
|
-
run(ruby + load_options + files.map { |f| "-r#{f}" } + options + ["-e", ""] + seed)
|
|
37
|
-
else # pass though
|
|
38
|
-
# no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
|
|
39
|
-
run ["testrb"] + argv
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# overwritten by maxitest to just return line
|
|
45
|
-
def line_pattern_option(file, line)
|
|
46
|
-
[file, "-n", "/#{pattern_from_file(File.readlines(file), line)}/"]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# usable via external tools like zeus
|
|
50
|
-
def pattern_from_file(lines, line)
|
|
51
|
-
possible_lines = lines[0..(line.to_i-1)].reverse
|
|
52
|
-
|
|
53
|
-
found = possible_lines.map { |line| test_pattern_from_line(line) || block_start_from_line(line) }.compact
|
|
54
|
-
|
|
55
|
-
# pattern and the groups it is nested under (like describe - describe - it)
|
|
56
|
-
last_spaces = " " * 100
|
|
57
|
-
patterns = found.select do |spaces, name|
|
|
58
|
-
last_spaces = spaces if spaces.size < last_spaces.size
|
|
59
|
-
end.map(&:last).compact
|
|
60
|
-
|
|
61
|
-
return filter_duplicate_final(patterns).reverse.join(".*") if found.size > 0
|
|
62
|
-
|
|
63
|
-
raise "no test found before line #{line}"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# only keep 1 pattern that stops matching via $
|
|
67
|
-
def filter_duplicate_final(patterns)
|
|
68
|
-
found_final = 0
|
|
69
|
-
patterns.reject { |p| p.end_with?("$") and (found_final += 1) > 1 }
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
def all_test_files_in(folder)
|
|
75
|
-
Dir[File.join(folder, "{**/,}*_{test,spec}.rb")].uniq
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def partition_options(options)
|
|
79
|
-
next_is_before = false
|
|
80
|
-
options.partition do |option|
|
|
81
|
-
if next_is_before
|
|
82
|
-
next_is_before = false
|
|
83
|
-
true
|
|
84
|
-
else
|
|
85
|
-
if option =~ /^-(r|I)/
|
|
86
|
-
next_is_before = (option.size == 2)
|
|
87
|
-
true
|
|
88
|
-
else
|
|
89
|
-
false
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# fix 1.9 not being able to load local files
|
|
96
|
-
def localize(file)
|
|
97
|
-
file =~ /^[-a-z\d_]/ ? "./#{file}" : file
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def partition_argv(argv)
|
|
101
|
-
next_is_option = false
|
|
102
|
-
argv.partition do |arg|
|
|
103
|
-
if next_is_option
|
|
104
|
-
next_is_option = false
|
|
105
|
-
else
|
|
106
|
-
if arg =~ /^-.$/ or arg =~ /^--/ # single letter option followed by argument like -I test or long options like --verbose
|
|
107
|
-
next_is_option = true if OPTION_WITH_ARGUMENT.include?(arg)
|
|
108
|
-
false
|
|
109
|
-
elsif arg =~ /^-/ # multi letter option like -Itest
|
|
110
|
-
false
|
|
111
|
-
else
|
|
112
|
-
true
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def changed_files
|
|
119
|
-
changed_files = sh("git status -s").split("\n").map { |l| l.strip.split(/\s+/, 2)[1] }
|
|
120
|
-
|
|
121
|
-
if changed_files.empty?
|
|
122
|
-
# user wants to test last commit and not current diff
|
|
123
|
-
changed_files = sh("git show --name-only").split("\n\n").last.split("\n")
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# we only want test files that were added or changed (not deleted)
|
|
127
|
-
changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) }
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def sh(command)
|
|
131
|
-
result = `#{command}`
|
|
132
|
-
raise "Failed: #{command} -> #{result}" unless $?.success?
|
|
133
|
-
result
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def ruby
|
|
137
|
-
if File.file?("Gemfile")
|
|
138
|
-
["ruby", "-rbundler/setup"] # faster then bundle exec ruby
|
|
139
|
-
else
|
|
140
|
-
["ruby"]
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def run(command)
|
|
145
|
-
puts command.join(" ")
|
|
146
|
-
STDOUT.flush # if exec fails horribly we at least see some output
|
|
147
|
-
Kernel.exec *command
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def block_start_from_line(line)
|
|
151
|
-
if line =~ /^(\s*).* do( \|.*\|)?$/
|
|
152
|
-
[$1, nil]
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def test_pattern_from_line(line)
|
|
157
|
-
PATTERNS.each do |r|
|
|
158
|
-
next unless line =~ r
|
|
159
|
-
whitespace, method, test_name = $1, $2, $4
|
|
160
|
-
return [whitespace, test_pattern_from_match(method, test_name)]
|
|
161
|
-
end
|
|
162
|
-
nil
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def test_pattern_from_match(method, test_name)
|
|
166
|
-
regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*")
|
|
167
|
-
|
|
168
|
-
regex = if method == "test"
|
|
169
|
-
# test "xxx -_ yyy"
|
|
170
|
-
# test-unit: "test: xxx -_ yyy"
|
|
171
|
-
# activesupport: "test_xxx_-__yyy"
|
|
172
|
-
"^test(: |_)#{regex.gsub(" ", ".")}$"
|
|
173
|
-
elsif method == "describe" || (method == "context" && !via_shoulda?)
|
|
174
|
-
"#{regex}(::)?"
|
|
175
|
-
elsif method == "should" && via_shoulda?
|
|
176
|
-
optional_test_name = "(?:\(.*\))?"
|
|
177
|
-
"#{method} #{regex}\. #{optional_test_name}$"
|
|
178
|
-
elsif ["it", "should"].include?(method) # minitest aliases for shoulda
|
|
179
|
-
"#test_\\d+_#{regex}$"
|
|
180
|
-
else
|
|
181
|
-
regex
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
regex.gsub("'", ".")
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
def via_shoulda?
|
|
188
|
-
return @via_shoulda if defined?(@via_shoulda)
|
|
189
|
-
@via_shoulda = !File.exist?("Gemfile.lock") || File.read("Gemfile.lock").include?(" shoulda-context ")
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
# END generated by rake update, do not modify
|
data/lib/maxitest.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# we are not enabling our extensions unless maxitest/autorun was loaded
|
|
2
|
-
# minitest plugin system auto-loads all files in the load path and that would
|
|
3
|
-
# always enable all our plugins even if they were not wanted
|
|
4
|
-
if defined?(Maxitest::ENABLE_PLUGINS) && Maxitest::ENABLE_PLUGINS
|
|
5
|
-
disabled_for_rails = begin
|
|
6
|
-
require 'rails/version'
|
|
7
|
-
Rails::VERSION::MAJOR >= 5
|
|
8
|
-
rescue LoadError
|
|
9
|
-
false
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# rails has --backtrace which disables rails own backtrace cleaner, but not minitests
|
|
13
|
-
require "maxitest/verbose_backtrace"
|
|
14
|
-
|
|
15
|
-
unless disabled_for_rails # rails 5 adds default red/green output
|
|
16
|
-
require "maxitest/vendor/rg"
|
|
17
|
-
Minitest.extensions << "rg"
|
|
18
|
-
Minitest::RG.rg! $stdout.tty?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# rails 5.2+ has it's own line support
|
|
22
|
-
# - it breaks `mtest file:line` format
|
|
23
|
-
# - we still want our format with the nice summary at the end, even if the `bin/rails test` output is already inline
|
|
24
|
-
require "maxitest/vendor/line"
|
|
25
|
-
Minitest.extensions << "line"
|
|
26
|
-
end
|