minitest-redgreen 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9bb98b707193d5f9bd7c2dbce553711bf191b157
4
+ data.tar.gz: b29385c9f95834be41098ee49a09c8ea18842357
5
+ SHA512:
6
+ metadata.gz: 6cef7eed948326e7ef12b393c9f72ecb1dca3b71c9501ac990057f6c0dc328760e673c7fe2818cf92db2d55c9ec34f7c3e3b0d8bb7ca3f96e14727b053dda3ee
7
+ data.tar.gz: 36cbfeb0cf3e0282874e3e269e027c866a1de949464007c74f448dc3633ea0d1b57abf735563265d059d2ba6af7a4ea7ad833a7f559c5aa99e1067aee610f598
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2014 Dom Jocubeit
2
+ Original source code Copyright (c) 2012 John Parker (see https://github.com/jparker/minitest-redgreen)
3
+
4
+ MIT License
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.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Minitest::Redgreen
2
+
3
+ Colorizes and corrects pluralization of Minitest output.
4
+
5
+ This gem was forked from https://github.com/jparker/minitest-redgreen. I found it wasn't published to RubyGems.org, but was a viable working alternative to `minitest-colorize` which is still uses `require 'minitest/unit'` and the older `MiniTest` module name instead of the newer `Minitest`.
6
+
7
+ I've added pluralization correction to the Minitest output, because incorrect grammar annoys me.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ``` ruby
14
+ gem 'minitest-redgreen'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ``` bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ``` bash
26
+ $ gem install minitest-redgreen
27
+ ```
28
+
29
+ ## Requirements
30
+
31
+ This gem has a dependency on `minitest 5.x`.
32
+
33
+ ## Usage
34
+
35
+ Add this line to your application's test_helper.rb or spec_helper.rb:
36
+
37
+ ``` ruby
38
+ require 'minitest/redgreen'
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new :test do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/test_*.rb'
7
+ end
8
+ task default: :test
@@ -0,0 +1,5 @@
1
+ require 'minitest'
2
+ require 'minitest/redgreen/version'
3
+ require 'minitest/redgreen_plugin'
4
+
5
+ Minitest.load_plugins
@@ -0,0 +1,5 @@
1
+ module Minitest
2
+ class Redgreen
3
+ VERSION = "1.0"
4
+ end
5
+ end
@@ -0,0 +1,71 @@
1
+ require 'minitest'
2
+ require 'forwardable'
3
+
4
+ module Minitest
5
+ def self.plugin_redgreen_options(opts, options)
6
+ end
7
+
8
+ def self.plugin_redgreen_init(options)
9
+ io = Redgreen.new(options[:io])
10
+ self.reporter.reporters.grep(Minitest::Reporter).each do |r|
11
+ r.io = io
12
+ end
13
+ end
14
+
15
+ class Redgreen
16
+ extend Forwardable
17
+
18
+ BEGIN_ESCAPE = "\e["
19
+ END_ESCAPE = "#{BEGIN_ESCAPE}0m"
20
+
21
+ attr_reader :io
22
+
23
+ def initialize(io)
24
+ @io = io
25
+ end
26
+
27
+ def print(o)
28
+ case o
29
+ when '.' then
30
+ io.print passing(o)
31
+ when 'F'
32
+ io.print failing(o)
33
+ when 'E'
34
+ io.print erring(o)
35
+ when 'S'
36
+ io.print skipping(o)
37
+ else
38
+ io.print o
39
+ end
40
+ end
41
+
42
+ def puts(o=nil)
43
+ return io.puts if o.nil?
44
+
45
+ io.puts o
46
+ .gsub(/\b ((\d+) \s+ runs?) \b/x) { pluralize($1) }
47
+ .gsub(/\b ((\d+) \s+ assertions?) \b/x) { pluralize($1) }
48
+ .gsub(/\b ((\d+) \s+ failures?) \b/x) { Integer($2) > 0 ? failing(pluralize($1)) : passing(pluralize($1)) }
49
+ .gsub(/\b ((\d+) \s+ errors?) \b/x) { Integer($2) > 0 ? erring(pluralize($1)) : passing(pluralize($1)) }
50
+ .gsub(/\b ((\d+) \s+ skips?) \b/x) { Integer($2) > 0 ? skipping(pluralize($1)): passing(pluralize($1)) }
51
+ end
52
+
53
+ delegate [:sync, :sync=] => :io
54
+
55
+ private
56
+
57
+ def pluralize(input)
58
+ text = input.split(" ")
59
+ word = text[0].to_i == 1 ? "#{text[0]} #{text[1][0..-2]}" : "#{text[0]} #{text[1]}"
60
+ end
61
+
62
+ def failing(o); escape('31m') {o}; end
63
+ def passing(o); escape('32m') {o}; end
64
+ def skipping(o); escape('33m') {o}; end
65
+ def erring(o); escape('35m') {o}; end
66
+
67
+ def escape(sequence)
68
+ "\e[#{sequence}" << yield << "\e[0m"
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minitest/redgreen/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "minitest-redgreen"
8
+ gem.version = Minitest::Redgreen::VERSION
9
+ gem.authors = ["Dom Jocubeit", "John Parker"]
10
+ gem.email = ["hello@meetdom.com", "jparker@urgetopunt.com"]
11
+ gem.summary = %q{Colorize and pluralize minitest test output.}
12
+ gem.description = %q{Colorize and pluralize minitest output: failing red, pending yellow, passing green and errors purple.}
13
+ gem.homepage = "https://github.com/MeetDom/minitest-redgreen"
14
+ gem.platform = Gem::Platform::RUBY
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency 'minitest', '~> 5.0'
22
+ gem.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,37 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/redgreen'
3
+ require 'stringio'
4
+
5
+ class TestMinitestRedgreen < Minitest::Test
6
+ def setup
7
+ @iostream = StringIO.new
8
+ end
9
+
10
+ def test_passing
11
+ Minitest::Redgreen.new(@iostream).print('.')
12
+ @iostream.rewind
13
+ output = @iostream.read
14
+ assert_equal "\e[32m.\e[0m", output, "'#{output.inspect}' should be a green '.'"
15
+ end
16
+
17
+ def test_failing
18
+ Minitest::Redgreen.new(@iostream).print('F')
19
+ @iostream.rewind
20
+ output = @iostream.read
21
+ assert_equal "\e[31mF\e[0m", output, "'#{output.inspect}' should be a red 'F'"
22
+ end
23
+
24
+ def test_erring
25
+ Minitest::Redgreen.new(@iostream).print('E')
26
+ @iostream.rewind
27
+ output = @iostream.read
28
+ assert_equal "\e[35mE\e[0m", output, "'#{output.inspect}' should be a magenta 'E'"
29
+ end
30
+
31
+ def test_skipping
32
+ Minitest::Redgreen.new(@iostream).print('S')
33
+ @iostream.rewind
34
+ output = @iostream.read
35
+ assert_equal "\e[33mS\e[0m", output, "'#{output.inspect}' should be a yellow 'S'"
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-redgreen
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Dom Jocubeit
8
+ - John Parker
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '5.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '5.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: 'Colorize and pluralize minitest output: failing red, pending yellow,
43
+ passing green and errors purple.'
44
+ email:
45
+ - hello@meetdom.com
46
+ - jparker@urgetopunt.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - .gitignore
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/minitest/redgreen.rb
57
+ - lib/minitest/redgreen/version.rb
58
+ - lib/minitest/redgreen_plugin.rb
59
+ - minitest-redgreen.gemspec
60
+ - test/minitest/test_redgreen.rb
61
+ homepage: https://github.com/MeetDom/minitest-redgreen
62
+ licenses: []
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.0
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Colorize and pluralize minitest test output.
84
+ test_files:
85
+ - test/minitest/test_redgreen.rb