minitest-color 0.0.1

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: 40e2db1a79608ec4f5bd86d20c660f45431af5ae
4
+ data.tar.gz: 163f45d61d438b5b9fb2dfba57c04cdbab10d3c4
5
+ SHA512:
6
+ metadata.gz: 7e15b3620fdf267fc2b56cdda2f724cc8855094f80aa6707b3218e0b660f1b36b2aaef13f77208cee4521757d5c3d8a7efd3251730a3b6cb7333543db464fa91
7
+ data.tar.gz: 3af0d7dc93b2ea92c4556779e0ec8b3e0abb86445cf2e50c2c155ad212adbc8d8e417dbfb6bcf78fa78b40723fa7e5844bddc80dda81fda3adfb328a4cc36415
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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-color.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Teo Ljungberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Minitest::Color
2
+
3
+ A color format for [minitest](https://github.com/seattlerb/minitest)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'minitest-color'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install minitest-color
18
+
19
+ ## Requirements
20
+
21
+ Minitest >= 5.0.0
22
+
23
+ ## Usage
24
+
25
+ Just pass `--color` as an argument while running your tests
26
+
27
+ ## What's the difference?
28
+ It colorizes your tests depending on their success
29
+
30
+ - `pass` => Green
31
+ - `skip` => Yellow
32
+ - `fail` => Red
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( http://github.com/teoljungberg/minitest-color/fork )
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.pattern = "test/**/*_test.rb"
7
+ end
8
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ require 'minitest'
2
+
3
+ Minitest.load_plugins
4
+ Minitest::Color.color!
@@ -0,0 +1,54 @@
1
+ require 'minitest'
2
+
3
+ module Minitest
4
+ def self.plugin_color_options opts, options
5
+ opts.on "--color", "Colorize the output" do
6
+ Color.color!
7
+ end
8
+ end
9
+
10
+ def self.plugin_color_init options
11
+ if Color.color?
12
+ io = options.delete(:io) || $stdout
13
+ self.reporter.reporters.reject! {|o| o.is_a? ProgressReporter }
14
+ self.reporter.reporters << Color.new(io, options)
15
+ end
16
+ end
17
+
18
+ class Color < Reporter
19
+ ESC = "\e["
20
+ NND = "#{ESC}0m"
21
+ GREEN = "#{ESC}32m"
22
+ RED = "#{ESC}31m"
23
+ YELLOW = "#{ESC}33m"
24
+
25
+ def self.color!
26
+ @color = true
27
+ end
28
+
29
+ def self.color?
30
+ @color ||= false
31
+ end
32
+
33
+ def record result
34
+ io.print color_code(result)
35
+ io.print result.result_code
36
+
37
+ io.print NND
38
+ end
39
+
40
+ private
41
+
42
+ def color_code result
43
+ color_code = case result.result_code
44
+ when "."
45
+ GREEN
46
+ when "E", "F"
47
+ RED
48
+ when "S"
49
+ YELLOW
50
+ end
51
+ color_code
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "minitest-color"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Teo Ljungberg"]
9
+ spec.email = ["teo.ljungberg@gmail.com"]
10
+ spec.summary = "Color formatter for Minitest"
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/teoljungberg/minitest-color"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,37 @@
1
+ require_relative 'test_case'
2
+ require 'minitest/color'
3
+
4
+ module Minitest
5
+ class ColorTest < TestCase
6
+ def setup
7
+ Color.color!
8
+ ExampleTest.generate_tests!
9
+ self.reporter = Color.new io
10
+ end
11
+ attr_accessor :reporter
12
+
13
+ def test_passing_tests_are_green
14
+ reporter.record ExampleTest.new(:test_pass).run
15
+
16
+ exp_format = "#{Color::GREEN}.#{Color::NND}"
17
+
18
+ assert_equal exp_format, io.string
19
+ end
20
+
21
+ def test_failing_tests_are_red
22
+ reporter.record ExampleTest.new(:test_fail).run
23
+
24
+ exp_format = "#{Color::RED}F#{Color::NND}"
25
+
26
+ assert_equal exp_format, io.string
27
+ end
28
+
29
+ def test_skipped_tests_are_yellow
30
+ reporter.record ExampleTest.new(:test_skip).run
31
+
32
+ exp_format = "#{Color::YELLOW}S#{Color::NND}"
33
+
34
+ assert_equal exp_format, io.string
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ require 'minitest/autorun'
2
+ require 'stringio'
3
+
4
+ module Minitest
5
+ class TestCase < Minitest::Test
6
+ ExampleTest = Class.new(Test) {
7
+ i_suck_and_my_tests_are_order_dependent!
8
+
9
+ def self.generate_tests!
10
+ define_method(:test_pass) { assert 'truthy' }
11
+ define_method(:test_fail) { refute 'truthy' }
12
+ define_method(:test_skip) { skip 'le skip' }
13
+ end
14
+ }
15
+
16
+ def io
17
+ @io ||= StringIO.new
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-color
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Teo Ljungberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Color formatter for Minitest
42
+ email:
43
+ - teo.ljungberg@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/minitest/color.rb
54
+ - lib/minitest/color_plugin.rb
55
+ - minitest-color.gemspec
56
+ - test/minitest/color_test.rb
57
+ - test/minitest/test_case.rb
58
+ homepage: https://github.com/teoljungberg/minitest-color
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Color formatter for Minitest
82
+ test_files:
83
+ - test/minitest/color_test.rb
84
+ - test/minitest/test_case.rb