Permalink
Browse files

Merge pull request #5 from sentientmonkey/minitest-5

! Convert to minitest plugin for minitest 5. (sentientmonkey)
  • Loading branch information...
2 parents 4ad1dc0 + 8b07114 commit 46d6f57af17a06edf514db6edf77297420a49129 @zenspider zenspider committed Nov 13, 2013
Showing with 60 additions and 29 deletions.
  1. +1 −0 Manifest.txt
  2. +3 −29 lib/minitest/emoji.rb
  3. +56 −0 lib/minitest/emoji_plugin.rb
View
@@ -4,4 +4,5 @@ Manifest.txt
README.rdoc
Rakefile
lib/minitest/emoji.rb
+lib/minitest/emoji_plugin.rb
test/test_minitest_emoji.rb
View
@@ -1,30 +1,4 @@
-module MiniTest
- class Emoji
- VERSION = '1.0.0'
+require "minitest"
- DEFAULT = {
- '.' => "\u{1F49A} ",
- 'E' => "\u{1f525} ",
- 'F' => "\u{1f4a9} ",
- 'S' => "\u{1f633} ",
- }
-
- attr_reader :io, :chars
-
- def initialize io, chars = DEFAULT
- @io = io
- @chars = DEFAULT
- end
-
- def print o
- io.print(chars[o] || o)
- end
-
- def method_missing msg, *args
- return super unless io.respond_to? msg
- io.send(msg, *args)
- end
- end
-end
-
-MiniTest::Unit.output = MiniTest::Emoji.new(MiniTest::Unit.output)
+Minitest.load_plugins
+Minitest::Emoji.emoji!
@@ -0,0 +1,56 @@
+require 'minitest/autorun'
+
+module Minitest
+
+ def self.plugin_emoji_options opts, options # :nodoc:
+ opts.on "-e", "--emoji", "Show Emoji instead of dots" do
+ Emoji.emoji!
+ end
+ end
+
+ def self.plugin_emoji_init options # :nodoc:
+ if Emoji.emoji? then
+ io = Emoji.new options[:io]
+
+ self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
+ rep.io = io
+ end
+ end
+ end
+
+ class Emoji
+
+ VERSION = '1.0.0'
+
+ DEFAULT = {
+ '.' => "\u{1F49A} ",
+ 'E' => "\u{1f525} ",
+ 'F' => "\u{1f4a9} ",
+ 'S' => "\u{1f633} ",
+ }
+
+ attr_reader :io, :chars
+
+ def self.emoji!
+ @emoji = true
+ end
+
+ def self.emoji?
+ @emoji ||= false
+ end
+
+ def initialize io, chars = DEFAULT
+ @io = io
+ @chars = DEFAULT
+ end
+
+ def print o
+ io.print(chars[o] || o)
+ end
+
+ def method_missing msg, *args
+ return super unless io.respond_to? msg
+ io.send(msg, *args)
+ end
+ end
+end

0 comments on commit 46d6f57

Please sign in to comment.