pretty_test 0.2.0 → 0.2.1

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Mzc2ZDViYmMxZDAxNWYyOGNjMGJlNDU0NWE3NzNhZjMwNDUyZWE1OQ==
5
- data.tar.gz: !binary |-
6
- MGZiZTJlOTdiM2MwNGIzNzE1NGMzN2M3MmY3ZWQyZjk5YTMzZGJhMQ==
2
+ SHA1:
3
+ metadata.gz: 61f6626db8635023eb496da2f3ec76ed19fac4d1
4
+ data.tar.gz: 400dc1707a9ffea466cc692e71b1fa4359a65c64
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzE2YzdlOWEzOTYzYzNlMGQ4NTIxMzdmYzZlYzhlMmEzNzBhNzEyYTkyZDIw
10
- NzlmODU5NTYxOTlmOTVlNTAzN2U3Y2EzNjAyOTVjNjBmYjg2ZGQ1MWUyMDI4
11
- NzQ2MjA2OWNmMGJiMmYwYzdjMjU1M2YxYzU3YjU3OTZiNzNhMzc=
12
- data.tar.gz: !binary |-
13
- ZDE0MmI3NmZlYjNjY2M1OWViNWJlNmQwYjUyZWZhZmQwNGNlZmNiYjZlMWE1
14
- YzViNzI2ZTMzMTQxMmY3OWNkNzFmMmU4M2I3NmYwMjMxMTk5MjIyYjg4ZjAz
15
- NDMwYTJmN2Y1ZDVlMGVlODljMWUzYTRmZTEyOTYxMTgzMGNkYjg=
6
+ metadata.gz: 2c84b263c1d5bdca1b41c57bf326aadfd0321842242506eeced9dcc5ebc8b9af06a3d2bd7d9c88c63db053706b265a35c9655a641a5d646acfc6e2048fa4a18e
7
+ data.tar.gz: a080c24784a9e890de33c4776933baf2a191e4de0c94813793a9092d56f9493e4ea3752711566cf2452e2f2b6ecc758b215def911df2ab44ffe87d9772040a60
@@ -1,3 +1,5 @@
1
+ require "minitest/unit"
2
+
1
3
  module PrettyTest
2
4
 
3
5
  class Runner < ::MiniTest::Unit
@@ -5,9 +7,9 @@ module PrettyTest
5
7
  SKIP_FORMAT = "\e[33m[SKIPPED] %s: %s\e[0m\n%s\n%s"
6
8
  FAILURE_FORMAT = "\e[31m[FAILURE] %s: %s\e[0m\n\e[31m%s: %s\e[0m\n%s"
7
9
  ERROR_FORMAT = "\e[31m[ERROR] %s: %s\e[0m\n\e[31m%s: %s\e[0m\n%s"
8
- STATUS_FORMAT = "\e[2K\r\e[?7l\e[37m(%.1fs) \e[32m%d/%d tests\e[37m, \e[36m%d assertions\e[37m, \e[31m%d errors\e[37m, \e[31m%d failures\e[37m, \e[33m%d skips \e[37m%s\e[?7h\e[0m"
10
+ STATUS_FORMAT = "\e[2K\r\e[?7l\e[37m(%.1fs) \e[32m%d/%d tests (%d%%)\e[37m, \e[36m%d assertions\e[37m, \e[31m%d errors\e[37m, \e[31m%d failures\e[37m, \e[33m%d skips \e[37m%s\e[?7h\e[0m"
9
11
 
10
- attr_accessor :started_at, :test_count, :assertion_count, :progress, :suite_name, :test_name
12
+ attr_accessor :started_at, :test_count, :assertion_count, :completed, :suite_name, :test_name, :test_record
11
13
 
12
14
  def _run_anything(type)
13
15
  suites = TestCase.send("#{type}_suites")
@@ -31,12 +33,16 @@ module PrettyTest
31
33
  after_suite(suite, type)
32
34
  end
33
35
 
36
+ def record(suite, test, assertions, time, exception)
37
+ @test_record = TestRecord.new(suite, test, assertions, time, exception)
38
+ end
39
+
34
40
  private
35
41
 
36
42
  def before_suites(suites, type)
37
43
  @started_at = Time.now
38
44
  @test_count = suites.map { |suite| suite.send("#{type}_methods").count }.sum
39
- @progress = 0
45
+ @completed = 0
40
46
  @assertion_count = 0
41
47
  end
42
48
 
@@ -61,7 +67,13 @@ module PrettyTest
61
67
  end
62
68
 
63
69
  def after_test
64
- @progress += 1
70
+ @completed += 1
71
+ case exception = test_record.exception
72
+ when nil then pass
73
+ when ::MiniTest::Skip then skip(exception)
74
+ when ::MiniTest::Assertion then failure(exception)
75
+ else error(exception)
76
+ end
65
77
  update_status("")
66
78
  end
67
79
 
@@ -69,26 +81,21 @@ module PrettyTest
69
81
  end
70
82
 
71
83
  def skip(exception)
72
- test_name = pretty_test_name(test)
73
84
  location = pretty_location(exception)
74
85
  message = exception.message.strip
75
86
  print_error SKIP_FORMAT, suite_name, test_name, message, location
76
87
  end
77
88
 
78
89
  def failure(exception)
79
- error = test_runner.exception
80
- test_name = pretty_test_name(test)
81
- index = find_assertion_index(error)
82
- trace = pretty_trace(error, index)
83
- print_error FAILURE_FORMAT, suite_name, test_name, error.class, error.message, trace
90
+ index = find_assertion_index(exception)
91
+ trace = pretty_trace(exception, index)
92
+ print_error FAILURE_FORMAT, suite_name, test_name, exception.class, exception.message, trace
84
93
  end
85
94
 
86
- def error(suite, test, test_runner)
87
- error = test_runner.exception
88
- test_name = pretty_test_name(test)
89
- index = find_exception_index(error)
90
- trace = pretty_trace(error, index)
91
- print_error ERROR_FORMAT, suite_name, test_name, error.class, error.message, trace
95
+ def error(exception)
96
+ index = find_exception_index(exception)
97
+ trace = pretty_trace(exception, index)
98
+ print_error ERROR_FORMAT, suite_name, test_name, exception.class, exception.message, trace
92
99
  end
93
100
 
94
101
  def after_suite(suite, type)
@@ -97,9 +104,9 @@ module PrettyTest
97
104
  def after_suites(suites, type)
98
105
  update_status
99
106
  if errors + failures == 0
100
- puts "\e[32m----- PASSED! -----\e[0m"
107
+ puts " \e[32m----- PASSED! -----\e[0m"
101
108
  else
102
- puts "\e[31m----- FAILED! -----\e[0m"
109
+ puts " \e[31m----- FAILED! -----\e[0m"
103
110
  end
104
111
  end
105
112
 
@@ -163,11 +170,15 @@ module PrettyTest
163
170
 
164
171
  def update_status(message = "")
165
172
  running_time = Time.now - started_at
166
- print STATUS_FORMAT % [running_time, progress, test_count, assertion_count, errors, failures, skips, message]
173
+ progress = 100.0 * completed / test_count
174
+ print STATUS_FORMAT % [running_time, completed, test_count, progress, assertion_count, errors, failures, skips, message]
167
175
  end
168
176
 
169
177
  def remove_status
170
178
  print "\e[2K\r"
171
179
  end
180
+
181
+ class TestRecord < Struct.new(:suite, :test, :assertions, :time, :exception)
182
+ end
172
183
  end
173
184
  end
data/pretty_test.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
12
  gem.name = "pretty_test"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "0.2.0"
14
+ gem.version = "0.2.1"
15
15
 
16
16
  gem.add_dependency "minitest", "~> 4"
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Bobes Tuzinsky
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4'
27
27
  description: Minitest patch for pretty (and useful) output.
@@ -31,7 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
35
  - Gemfile
36
36
  - README.md
37
37
  - lib/pretty_test.rb
@@ -47,17 +47,17 @@ require_paths:
47
47
  - lib
48
48
  required_ruby_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ! '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ! '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.1.11
60
+ rubygems_version: 2.2.0.rc.1
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Minitest patch for pretty output