minitest-example 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: '085f5ea74b76cd8a630d85bbc22a888a503eec70cb1326007bea502a29f468b6'
4
- data.tar.gz: d8655c87b970eda0dab604062bac62784f6e48681cb663d916b4892a22b83168
3
+ metadata.gz: 368624d0592e344cd48707c0d0103f09b8d46b6ba5d59b60b247db1554df2a9a
4
+ data.tar.gz: 57fb3b6d0bff1c1e2c496be03c3ce0955798458ee96a15e6f61f4569646fed01
5
5
  SHA512:
6
- metadata.gz: 3934248e4a055504ff14bd1827fe0f3a3ce342d8c77c7b9597e78fdf7e223da5fdedafee111e59d3f264f4483a38a976114cf760367036e9f05922fabb154fd3
7
- data.tar.gz: 96adc5a6a7a7c40e5eed7c8d0608d1da2e00b58cee74b7fdf4f2196e2db7ac16d94e354025a2f2964abbd4ea4c43ad0992e7ff9b5765c35d53ef22911b560522
6
+ metadata.gz: 62c40e7f453625633ad158cd744e0c5167b1ad072f986a36b04241b386681895934ba2d149d483840d1abc7b86e00513fb4d28761a6e4594088b1137c0594aab
7
+ data.tar.gz: 3f4d5c41cfdc473de031dcfacd705b9fa90c78f8ba284a433a2c0c6505c742968a4c6a89d1e9f17dd2e56aec6d969295ad1bd5f37f232c72fe9af96f3680abd4
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
@@ -8,28 +8,58 @@ module Minitest
8
8
  def runnable_methods
9
9
  methods_matching(/^example_/)
10
10
  end
11
+ end
11
12
 
12
- def run_one_method klass, method_name, reporter
13
- code = klass.instance_method(method_name).source
14
- parser = Rgot::ExampleParser.new(code)
15
- parser.parse
16
- example = parser.examples.first
13
+ def run
14
+ code = self.class.instance_method(self.name).source
15
+ parser = Rgot::ExampleParser.new(code)
16
+ parser.parse
17
+ example = parser.examples.first
17
18
 
18
- reporter.prerecord klass, method_name
19
- out = capture_stdout { reporter.record Minitest.run_one_method(klass, method_name) }
19
+ with_info_handler do
20
+ time_it do
21
+ capture_exceptions do
22
+ before_setup; setup; after_setup
20
23
 
21
- klass.new(method_name).assert_equal example.output.strip, out.strip
22
- end
24
+ out = capture_stdout do
25
+ self.send self.name
26
+ end
27
+
28
+ assert_equal example.output.strip, out.strip
29
+ end
23
30
 
24
- def capture_stdout
25
- original_out = $stdout
26
- out = StringIO.new
27
- $stdout = out
28
- yield
29
- out.string
30
- ensure
31
- $stdout = original_out
31
+ TEARDOWN_METHODS.each do |hook|
32
+ capture_exceptions do
33
+ self.send hook
34
+ end
35
+ end
36
+ end
32
37
  end
38
+
39
+ result = ExampleResult.from self # per contract
40
+ result.source_location = self.method(self.name).source_location
41
+ result
42
+ end
43
+
44
+ def capture_stdout
45
+ original_out = $stdout
46
+ out = StringIO.new
47
+ $stdout = out
48
+ yield
49
+ out.string
50
+ ensure
51
+ $stdout = original_out
52
+ end
53
+ end
54
+
55
+ class ExampleResult < Minitest::Result
56
+ def self.runnable_methods
57
+ []
58
+ end
59
+
60
+ def location
61
+ loc = " [#{source_location[0]}:#{source_location[1]}]" unless passed? or error?
62
+ "#{self.class_name}##{self.name}#{loc}"
33
63
  end
34
64
  end
35
65
  end
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "minitest-example"
6
- spec.version = "0.0.1"
6
+ spec.version = "0.0.2"
7
7
  spec.authors = ["Yuji Yaginuma"]
8
8
  spec.email = ["yuuji.yaginuma@gmail.com"]
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-example
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgot
@@ -105,7 +105,6 @@ files:
105
105
  - ".travis.yml"
106
106
  - CODE_OF_CONDUCT.md
107
107
  - Gemfile
108
- - Gemfile.lock
109
108
  - LICENSE.txt
110
109
  - README.md
111
110
  - Rakefile
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- minitest-example (0.0.1)
5
- method_source
6
- rgot
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- byebug (10.0.2)
12
- method_source (0.9.0)
13
- minitest (5.11.3)
14
- rake (10.5.0)
15
- rgot (0.2.0)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- bundler (~> 1.16)
22
- byebug
23
- minitest (~> 5.0)
24
- minitest-example!
25
- rake (~> 10.0)
26
-
27
- BUNDLED WITH
28
- 1.16.2