pretty_test 0.0.10 → 0.2.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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Mzc2ZDViYmMxZDAxNWYyOGNjMGJlNDU0NWE3NzNhZjMwNDUyZWE1OQ==
5
+ data.tar.gz: !binary |-
6
+ MGZiZTJlOTdiM2MwNGIzNzE1NGMzN2M3MmY3ZWQyZjk5YTMzZGJhMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzE2YzdlOWEzOTYzYzNlMGQ4NTIxMzdmYzZlYzhlMmEzNzBhNzEyYTkyZDIw
10
+ NzlmODU5NTYxOTlmOTVlNTAzN2U3Y2EzNjAyOTVjNjBmYjg2ZGQ1MWUyMDI4
11
+ NzQ2MjA2OWNmMGJiMmYwYzdjMjU1M2YxYzU3YjU3OTZiNzNhMzc=
12
+ data.tar.gz: !binary |-
13
+ ZDE0MmI3NmZlYjNjY2M1OWViNWJlNmQwYjUyZWZhZmQwNGNlZmNiYjZlMWE1
14
+ YzViNzI2ZTMzMTQxMmY3OWNkNzFmMmU4M2I3NmYwMjMxMTk5MjIyYjg4ZjAz
15
+ NDMwYTJmN2Y1ZDVlMGVlODljMWUzYTRmZTEyOTYxMTgzMGNkYjg=
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
  gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Pretty Test
2
+
3
+ `pretty_test` is a Ruby gem that will make output from your
4
+ [minitest](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/minitest/unit/rdoc/index.html)
5
+ tests pretty and useful.
6
+
7
+ ## The problem
8
+
9
+ There are only two things I want to see *while* running a suite of tests: progress and failed tests.
10
+
11
+ [minitest](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/minitest/unit/rdoc/index.html)
12
+ prints dots for passed tests and Fs for failed tests - not very useful. If you want to know *which* tests failed and *why*, you have to wait until the whole suite is finished. This kind of feedback is painfully slow.
13
+
14
+ [Turn](https://github.com/TwP/turn) with the default settings brings a huge improvement by printing failed test details immediately. But it also prints one line for every passed test. So you'll often get just a glimpse of a failed test stack trace immediately replaced by a fast-scrolling list of passed tests. *(I know there are other output formats in turn but I haven't found any of them very useful.)*
15
+
16
+ ## The solution
17
+
18
+ With `pretty_test` you'll get
19
+
20
+ * number of passed and failed tests, number of passed assertions,
21
+ * name of currently running test,
22
+ * error information and a colorised stack trace for every failed test,
23
+ * highlighted line of code that most likely caused the failure.
24
+
25
+ And all of this in real time.
26
+
27
+ ## Install
28
+
29
+ All you need to do is to add `pretty_test` to your Gemfile:
30
+
31
+ group :test do
32
+ gem "pretty_test"
33
+ # ...
34
+ end
35
+
36
+ and enjoy pretty and useful test output.
@@ -1,46 +1,81 @@
1
- require "minitap"
2
1
  module PrettyTest
3
2
 
4
- class Tap < ::MiniTest::MiniTap
3
+ class Runner < ::MiniTest::Unit
5
4
 
6
5
  SKIP_FORMAT = "\e[33m[SKIPPED] %s: %s\e[0m\n%s\n%s"
7
6
  FAILURE_FORMAT = "\e[31m[FAILURE] %s: %s\e[0m\n\e[31m%s: %s\e[0m\n%s"
8
7
  ERROR_FORMAT = "\e[31m[ERROR] %s: %s\e[0m\n\e[31m%s: %s\e[0m\n%s"
9
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
9
 
11
- attr_accessor :started_at, :progress, :suite_name, :test_name
10
+ attr_accessor :started_at, :test_count, :assertion_count, :progress, :suite_name, :test_name
12
11
 
13
- def tapout_before_suites(suites, type)
12
+ def _run_anything(type)
13
+ suites = TestCase.send("#{type}_suites")
14
+ _run_suites(suites, type)
15
+ end
16
+
17
+ def _run_suites(suites, type)
18
+ before_suites(suites, type)
19
+ super
20
+ ensure
21
+ after_suites(suites, type)
22
+ end
23
+
24
+ def _run_suite(suite, type)
25
+ before_suite(suite)
26
+ tests = suite.send("#{type}_methods")
27
+ tests.each do |test|
28
+ run_test(suite, test)
29
+ end
30
+ ensure
31
+ after_suite(suite, type)
32
+ end
33
+
34
+ private
35
+
36
+ def before_suites(suites, type)
14
37
  @started_at = Time.now
38
+ @test_count = suites.map { |suite| suite.send("#{type}_methods").count }.sum
15
39
  @progress = 0
40
+ @assertion_count = 0
16
41
  end
17
42
 
18
- def tapout_before_suite(suite)
43
+ def before_suite(suite)
19
44
  @suite_name = pretty_suite_name(suite.name)
20
45
  end
21
46
 
22
- def tapout_before_test(suite, test)
47
+ def run_test(suite, test)
48
+ before_test(test)
49
+ instance = suite.new(test)
50
+ instance._assertions = 0
51
+ instance.run(self)
52
+ @assertion_count += instance._assertions
53
+ ensure
54
+ after_test
55
+ end
56
+
57
+ def before_test(test)
23
58
  @test_name = pretty_test_name(test)
24
59
  remove_status
25
60
  update_status("#{suite_name}: #{test_name}")
26
61
  end
27
62
 
28
- def tapout_pass(suite, test, test_runner)
63
+ def after_test
29
64
  @progress += 1
30
65
  update_status("")
31
66
  end
32
67
 
33
- def tapout_skip(suite, test, test_runner)
34
- @progress += 1
35
- error = test_runner.exception
68
+ def pass
69
+ end
70
+
71
+ def skip(exception)
36
72
  test_name = pretty_test_name(test)
37
- location = pretty_location(error)
38
- message = error.message.strip
73
+ location = pretty_location(exception)
74
+ message = exception.message.strip
39
75
  print_error SKIP_FORMAT, suite_name, test_name, message, location
40
76
  end
41
77
 
42
- def tapout_failure(suite, test, test_runner)
43
- @progress += 1
78
+ def failure(exception)
44
79
  error = test_runner.exception
45
80
  test_name = pretty_test_name(test)
46
81
  index = find_assertion_index(error)
@@ -48,8 +83,7 @@ module PrettyTest
48
83
  print_error FAILURE_FORMAT, suite_name, test_name, error.class, error.message, trace
49
84
  end
50
85
 
51
- def tapout_error(suite, test, test_runner)
52
- @progress += 1
86
+ def error(suite, test, test_runner)
53
87
  error = test_runner.exception
54
88
  test_name = pretty_test_name(test)
55
89
  index = find_exception_index(error)
@@ -57,9 +91,11 @@ module PrettyTest
57
91
  print_error ERROR_FORMAT, suite_name, test_name, error.class, error.message, trace
58
92
  end
59
93
 
60
- def tapout_after_suites(suites, type)
94
+ def after_suite(suite, type)
95
+ end
96
+
97
+ def after_suites(suites, type)
61
98
  update_status
62
- puts "\n\nSuite seed: #{options[:seed]}\n\n"
63
99
  if errors + failures == 0
64
100
  puts "\e[32m----- PASSED! -----\e[0m"
65
101
  else
@@ -67,14 +103,6 @@ module PrettyTest
67
103
  end
68
104
  end
69
105
 
70
- def tapout_(suite, test, test_runner)
71
- remove_status
72
- puts "\n\e[31mCould not run #{suite}##{test} for an unknown reason\e[0m\n"
73
- puts
74
- end
75
-
76
- protected
77
-
78
106
  def pretty_suite_name(suite)
79
107
  suite = suite.dup
80
108
  suite.gsub!(/(::|_)/, " ")
@@ -134,7 +162,8 @@ module PrettyTest
134
162
  end
135
163
 
136
164
  def update_status(message = "")
137
- print STATUS_FORMAT % [Time.now - started_at, progress, test_count, assertion_count, errors, failures, skips, message]
165
+ running_time = Time.now - started_at
166
+ print STATUS_FORMAT % [running_time, progress, test_count, assertion_count, errors, failures, skips, message]
138
167
  end
139
168
 
140
169
  def remove_status
data/lib/pretty_test.rb CHANGED
@@ -1,3 +1,3 @@
1
- require "pretty_test/tap"
1
+ require "pretty_test/runner"
2
2
 
3
- MiniTest::Unit.runner = PrettyTest::Tap.new if STDOUT.tty?
3
+ MiniTest::Unit.runner = PrettyTest::Runner.new if STDOUT.tty?
data/pretty_test.gemspec CHANGED
@@ -1,18 +1,17 @@
1
- # -*- encoding: utf-8 -*-
2
1
  Gem::Specification.new do |gem|
3
2
  gem.authors = ["Vladimir Bobes Tuzinsky"]
4
3
  gem.email = ["vladimir@tuzinsky.com"]
5
4
  gem.summary = %q{Minitest patch for pretty output}
6
5
  gem.description = %q{Minitest patch for pretty (and useful) output.}
7
6
  gem.homepage = "https://github.com/bobes/pretty_test"
7
+ gem.license = "MIT"
8
8
 
9
9
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
10
10
  gem.files = `git ls-files`.split("\n")
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.0.10"
14
+ gem.version = "0.2.0"
15
15
 
16
- gem.add_dependency "minitest", ">= 2.6"
17
- gem.add_dependency "minitap", ">= 0.3"
16
+ gem.add_dependency "minitest", "~> 4"
18
17
  end
metadata CHANGED
@@ -1,48 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Vladimir Bobes Tuzinsky
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
11
+ date: 2013-12-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: minitest
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '2.6'
19
+ version: '4'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '2.6'
30
- - !ruby/object:Gem::Dependency
31
- name: minitap
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0.3'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0.3'
26
+ version: '4'
46
27
  description: Minitest patch for pretty (and useful) output.
47
28
  email:
48
29
  - vladimir@tuzinsky.com
@@ -52,31 +33,32 @@ extra_rdoc_files: []
52
33
  files:
53
34
  - .gitignore
54
35
  - Gemfile
36
+ - README.md
55
37
  - lib/pretty_test.rb
56
- - lib/pretty_test/tap.rb
38
+ - lib/pretty_test/runner.rb
57
39
  - pretty_test.gemspec
58
40
  homepage: https://github.com/bobes/pretty_test
59
- licenses: []
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
60
44
  post_install_message:
61
45
  rdoc_options: []
62
46
  require_paths:
63
47
  - lib
64
48
  required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
49
  requirements:
67
50
  - - ! '>='
68
51
  - !ruby/object:Gem::Version
69
52
  version: '0'
70
53
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
54
  requirements:
73
55
  - - ! '>='
74
56
  - !ruby/object:Gem::Version
75
57
  version: '0'
76
58
  requirements: []
77
59
  rubyforge_project:
78
- rubygems_version: 1.8.23
60
+ rubygems_version: 2.1.11
79
61
  signing_key:
80
- specification_version: 3
62
+ specification_version: 4
81
63
  summary: Minitest patch for pretty output
82
64
  test_files: []