maxitest 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63d1e9c4bb62f38867ffed9a061c639f2726371f
4
- data.tar.gz: f678636ae4d38cef099a82fd8e6d0ca6d293d352
3
+ metadata.gz: 271f7a9230cc5370341413d7f3d7d944831e5ab4
4
+ data.tar.gz: c8c7aaf229077231927a498915a713bad72c9306
5
5
  SHA512:
6
- metadata.gz: 0c25363ed5eff711abe65784ddb657c801c1fa4cfb13e3a04bd2e4298a454dd2733a5f27e42d778b3b701b0f82d7a0bd07554b6f25312c6cc11331d4a5d2c0c2
7
- data.tar.gz: 6bf5c87dde9d3816816b1a37ba2994d175acb9295cfb6e8869d9583d8fdbeefcad8694f9e1d025813e216d008919be132008e680aa7c84b8acffff6a8f6ec18f
6
+ metadata.gz: edaebf80fdc723a22c39c85e55eba26cd09c83396958bccab4286d045cfc57965a6a575e51a5a4c81eb8654139c920fcad98e9dda279085b56040608288d8fa1
7
+ data.tar.gz: 88ba8dbe7dd89d707727359c6b5116b05a0c53ceaf20cde5824c961abc02f2e9f1d08259f0536a224aa5cf2d69be8e967e5c4653936153eea7f1747361575312
@@ -10,4 +10,4 @@ module Maxitest
10
10
  end
11
11
  end
12
12
 
13
- Object.include Maxitest::ImplicitSubject # Minitest hacks Kernel -> we need to use alias method or go into Object
13
+ Object.send(:include, Maxitest::ImplicitSubject) # Minitest hacks Kernel -> we need to use alias method or go into Object
@@ -28,10 +28,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
 
29
29
  # https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/version.rb
30
30
  # BEGIN generated by rake update, do not modify
31
- module Minitest
32
- module Around
33
- VERSION = '0.3.0'
34
- end
31
+ module MinitestAround
32
+ VERSION = '0.3.0'
35
33
  end
36
34
  #END generated by rake update, do not modify
37
35
 
@@ -56,7 +54,7 @@ Minitest::Spec::DSL.class_eval do
56
54
  # - resume to call first part
57
55
  # - execute test
58
56
  # - resume fiber to execute last part
59
- def around(&block)
57
+ def around(*args, &block)
60
58
  fib = nil
61
59
  before do
62
60
  fib = Fiber.new do |context, resume|
@@ -26,9 +26,54 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
26
  =end
27
27
  #END generated by rake update, do not modify
28
28
 
29
- # https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line_plugin.rb
29
+ # https://raw.githubusercontent.com/grosser/minitest-line/grosser/describe/lib/minitest/line_plugin.rb
30
30
  # BEGIN generated by rake update, do not modify
31
31
  module Minitest
32
+ module Line
33
+ class << self
34
+ def tests_with_lines
35
+ target_file = target_file()
36
+ methods_with_lines(target_file).concat describes_with_lines(target_file)
37
+ end
38
+
39
+ private
40
+
41
+ def target_file
42
+ runnables.each do |r|
43
+ r.runnable_methods.each do |m|
44
+ file, line = r.instance_method(m).source_location
45
+ return file if file
46
+ end
47
+ end
48
+ nil
49
+ end
50
+
51
+ def methods_with_lines(target_file)
52
+ runnables.flat_map do |runnable|
53
+ rname = Class.instance_method(:name).bind(runnable).call
54
+ runnable.runnable_methods.map do |name|
55
+ file, line = runnable.instance_method(name).source_location
56
+ next unless file == target_file
57
+ test_name = (rname ? "#{rname}##{name}" : name)
58
+ [test_name, line]
59
+ end
60
+ end.uniq.compact
61
+ end
62
+
63
+ def describes_with_lines(target_file)
64
+ runnables.map do |runnable|
65
+ next unless caller = runnable.instance_variable_get(:@minitest_line_caller)
66
+ next unless line = caller.detect { |line| line.include?(target_file) }
67
+ ["/#{Regexp.escape(runnable.name)}/", line[/:(\d+):in/, 1].to_i]
68
+ end.compact
69
+ end
70
+
71
+ def runnables
72
+ Minitest::Runnable.runnables
73
+ end
74
+ end
75
+ end
76
+
32
77
  def self.plugin_line_options(opts, options)
33
78
  opts.on '-l', '--line N', Integer, "Run test at line number" do |lineno|
34
79
  options[:line] = lineno
@@ -36,35 +81,18 @@ module Minitest
36
81
  end
37
82
 
38
83
  def self.plugin_line_init(options)
39
- exp_line = options[:line]
40
- if !exp_line
84
+ unless exp_line = options[:line]
41
85
  reporter.reporters << LineReporter.new
42
86
  return
43
87
  end
44
88
 
45
- methods = Runnable.runnables.flat_map do |runnable|
46
- runnable.runnable_methods.map do |name|
47
- [name, runnable.instance_method(name)]
48
- end
49
- end.uniq
50
-
51
- current_filename = nil
52
- tests = {}
89
+ tests = Minitest::Line.tests_with_lines
53
90
 
54
- methods.each do |name, meth|
55
- next unless loc = meth.source_location
56
- current_filename ||= loc[0]
57
- next unless current_filename == loc[0]
58
- tests[loc[1]] = name
59
- end
91
+ filter, _ = tests.sort_by { |n, l| -l }.detect { |n, l| exp_line >= l }
60
92
 
61
- _, main_test = tests.sort_by { |k, v| -k }.detect do |line, name|
62
- exp_line >= line
63
- end
93
+ raise "Could not find test method after line #{exp_line}" unless filter
64
94
 
65
- raise "Could not find test method after line #{exp_line}" unless main_test
66
-
67
- options[:filter] = main_test
95
+ options[:filter] = filter
68
96
  end
69
97
 
70
98
  class LineReporter < Reporter
@@ -101,4 +129,21 @@ module Minitest
101
129
  def self.plugin_line_inject_reporter
102
130
  end
103
131
  end
132
+ #END generated by rake update, do not modify
133
+
134
+ # https://raw.githubusercontent.com/grosser/minitest-line/grosser/describe/lib/minitest/line/describe_track.rb
135
+ # BEGIN generated by rake update, do not modify
136
+ module Minitest
137
+ module Line
138
+ module DescribeTrack
139
+ def describe(*args, &block)
140
+ klass = super
141
+ klass.instance_variable_set(:@minitest_line_caller, caller[0..5])
142
+ klass
143
+ end
144
+ end
145
+ end
146
+ end
147
+
148
+ Object.send(:include, Minitest::Line::DescribeTrack)
104
149
  #END generated by rake update, do not modify
@@ -1,3 +1,3 @@
1
1
  module Maxitest
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest