minitest-nyan-cat 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07394006884c6e8b83b366c892ce0fdde4b1b5f6
4
+ data.tar.gz: d09c91e34a7353a84f54a0ded30954be468e5675
5
+ SHA512:
6
+ metadata.gz: 513e2716333f37a139a4145cdb2c88fdaf10b6415a575361fa21bcc41451157ade36b4a37d67839dd222d2baeca95facd21ff123a491b6d1a7591a75d916f9e2
7
+ data.tar.gz: 59f52ce20f9eae102b94c199d7bf6d9392f4df8a8d6e38e51a75585451d8be12166603c0db69f5636c2639b878a36f81edb11e154b4945ad0aebd79e0a16f92e
@@ -0,0 +1,4 @@
1
+ require "minitest"
2
+
3
+ Minitest.load_plugins
4
+ Minitest::NyanCat.nyan!
@@ -0,0 +1,122 @@
1
+ require "minitest"
2
+ require 'nyan_cat_formatter/common'
3
+
4
+ module Minitest
5
+ def self.plugin_nyan_cat_options(opts, _options)
6
+ opts.on "-nyan", "--nyancat", "Nyan nyan nyan nyan nyan nyan nyan nyan nyan" do
7
+ NyanCat.nyan!
8
+ end
9
+ end
10
+
11
+ def self.plugin_nyan_cat_init(options)
12
+ if NyanCat.nyan? then
13
+ io = NyanCat.new options[:io]
14
+
15
+ self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
16
+ rep.io = io
17
+ end
18
+ end
19
+ end
20
+
21
+ class NyanCat
22
+ include ::NyanCat::Common
23
+
24
+ attr_reader :output
25
+
26
+ def initialize(io)
27
+ @example_count = total_count
28
+ @current = @color_index = @passing_count = @failure_count = @pending_count = 0
29
+ @example_results = []
30
+ @output = io
31
+ end
32
+
33
+ def self.nyan!
34
+ @nyan = true
35
+ end
36
+
37
+ def self.nyan?
38
+ @nyan ||= false
39
+ end
40
+
41
+ def print(o)
42
+ case o
43
+ when "." then
44
+ @passing_count += 1
45
+ tick PASS
46
+ when "E", "F" then
47
+ @failure_count += 1
48
+ tick FAIL
49
+ when "S" then
50
+ @pending_count += 1
51
+ tick PENDING
52
+ else
53
+ output.print o
54
+ end
55
+ end
56
+
57
+ def puts(*o)
58
+ if o.first =~ /Finished in (.+)s/
59
+ output.puts "\nYou've Nyaned for #{format_duration($1.to_f)}\n".each_char.map {|c| rainbowify(c)}.join
60
+ summary = "#{@example_count} example#{'s' unless @example_count == 1}, #{@failure_count} failure#{'s' unless @failure_count == 1}"
61
+ summary << ", #{@pending_count} pending" if @pending_count > 0
62
+
63
+ if @failure_count > 0
64
+ # Red background with white chars
65
+ output.puts "#{ESC}41m#{ESC}37m#{summary}#{NND}\n"
66
+ elsif pending_count > 0
67
+ # Gray background with white chars
68
+ output.puts "#{ESC}43m#{ESC}40m#{summary}#{NND}\n"
69
+ else
70
+ # Green background with white chars
71
+ output.puts "#{ESC}42m#{ESC}37m#{summary}#{NND}\n"
72
+ end
73
+ elsif o.first =~ /runs/
74
+ else
75
+ output.puts(o)
76
+ end
77
+ end
78
+
79
+ def method_missing(msg, *args)
80
+ output.send(msg, *args)
81
+ end
82
+
83
+ private
84
+
85
+ # Hack to get the total number of assertions
86
+ def total_count
87
+ Minitest::Runnable.runnables.map(&:runnable_methods).flatten.size
88
+ end
89
+
90
+ # Override method since it assumes RSpec is used
91
+ def wrap(text, code_or_symbol)
92
+ text
93
+ end
94
+
95
+ # Override to make it work with Minitest
96
+ def success_color(text)
97
+ "#{ESC}32m#{text}#{NND}"
98
+ end
99
+
100
+ # Override to make it work with Minitest
101
+ def pending_color(text)
102
+ "#{ESC}33m#{text}#{NND}"
103
+ end
104
+
105
+ # Override to make it work with Minitest
106
+ def failure_color(text)
107
+ "#{ESC}31m#{text}#{NND}"
108
+ end
109
+
110
+ # Override to make it work with Minitest
111
+ def scoreboard
112
+ padding = @example_count.to_s.length
113
+
114
+ [
115
+ @current.to_s.rjust(padding),
116
+ success_color(@passing_count.to_s.rjust(padding)),
117
+ failure_color(@failure_count.to_s.rjust(padding)),
118
+ pending_color(@pending_count.to_s.rjust(padding))
119
+ ]
120
+ end
121
+ end
122
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-nyan-cat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alan Guo Xiang Tan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nyan-cat-formatter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: '0.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: '0.11'
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/minitest/nyan_cat.rb
34
+ - lib/minitest/nyan_cat_plugin.rb
35
+ homepage: https://github.com/tgxworld/minitest-nyan-cat
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.4.5
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Prints a Nyan Cat trail for your test output
59
+ test_files: []
60
+ has_rdoc: