disinnovate-greeneggs 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/greeneggs.gemspec +2 -2
- data/lib/greeneggs.rb +33 -39
- data/spec/greeneggs_spec.rb +6 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/greeneggs.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{greeneggs}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.8"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Michael Fleet"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-14}
|
10
10
|
s.email = %q{disinnovate@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
data/lib/greeneggs.rb
CHANGED
@@ -9,57 +9,51 @@
|
|
9
9
|
|
10
10
|
module Bacon
|
11
11
|
class << self
|
12
|
-
|
13
|
-
|
14
|
-
:fail => "\e[1m\e[31m", # FAILED: red
|
15
|
-
'E' => "\e[1m\e[35m", # ERROR: purple
|
16
|
-
'M' => "\e[1m\e[33m", # MISSING: yellow
|
17
|
-
:ok => "\e[1m\e[32m" # PASSED/OK: green
|
18
|
-
}
|
12
|
+
# ANSI terminal colors
|
13
|
+
COLORS = { 'F' => 31, 'E' => 35, 'M' => 33, :ok => 32 }
|
19
14
|
|
20
|
-
|
21
|
-
def handle_requirement(description)
|
22
|
-
print(colorize_requirement { output_handle_requirement(description) { yield } })
|
23
|
-
end
|
24
|
-
|
25
|
-
alias_method :output_handle_summary, :handle_summary
|
26
|
-
def handle_summary
|
27
|
-
puts(colorize_summary { output_handle_summary })
|
28
|
-
end
|
15
|
+
def colorize_string(text, color); "\e[1m\e[#{COLORS[color]}m#{text}\e[0m"; end
|
29
16
|
|
30
|
-
|
31
|
-
|
32
|
-
s = StringIO.new
|
33
|
-
oldstdout = $stdout
|
34
|
-
$stdout = s
|
35
|
-
yield
|
36
|
-
s.string
|
37
|
-
ensure
|
38
|
-
$stdout = oldstdout
|
39
|
-
end
|
40
|
-
|
41
|
-
def colorize_requirement
|
42
|
-
out = capture_stdout { yield }
|
17
|
+
def colorize_result(out)
|
18
|
+
return out if PLATFORM =~ /win32/
|
43
19
|
|
44
|
-
|
20
|
+
requirement_color = case out
|
45
21
|
when /(FAILED|ERROR|MISSING)/ then $1[0..0] # SpecDox, Tap, Knock
|
46
22
|
when /\A([FME])\Z/ then $1 # TestUnit
|
47
23
|
else :ok
|
48
24
|
end
|
49
25
|
|
50
|
-
out.
|
51
|
-
end
|
52
|
-
|
53
|
-
def colorize_summary
|
54
|
-
line = capture_stdout { yield }
|
26
|
+
summary_color = out.match(/0 failures, 0 errors/).nil? ? 'F' : :ok
|
55
27
|
|
56
|
-
|
57
|
-
|
28
|
+
out.sub(/^(.|(ok|not ok|-) .+)$/,
|
29
|
+
colorize_string('\0', requirement_color)).sub(/^.+\d+ failures, \d+ errors$/,
|
30
|
+
colorize_string('\0', summary_color))
|
58
31
|
end
|
59
32
|
|
60
|
-
def
|
61
|
-
|
33
|
+
def puts(*args)
|
34
|
+
args.map! { |arg| arg.instance_of?(String) ? colorize_result(arg) : arg }
|
35
|
+
super(args)
|
62
36
|
end
|
63
37
|
|
38
|
+
def print(*args)
|
39
|
+
args.map! { |arg| arg.instance_of?(String) ? colorize_result(arg) : arg }
|
40
|
+
super(args)
|
41
|
+
end
|
64
42
|
end
|
43
|
+
|
44
|
+
module SpecDoxOutput
|
45
|
+
def handle_requirement(description)
|
46
|
+
error = yield
|
47
|
+
puts "- #{description}" << (error.empty? ? "" : " [#{error}]")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
module TestUnitOutput
|
52
|
+
def handle_summary
|
53
|
+
puts "\n"
|
54
|
+
puts ErrorLog if Backtraces
|
55
|
+
puts "%d tests, %d assertions, %d failures, %d errors" %
|
56
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
57
|
+
end
|
58
|
+
end
|
65
59
|
end
|
data/spec/greeneggs_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
|
-
describe '
|
4
|
-
it 'should display passing specs in green' do
|
3
|
+
describe 'GreenEggs terminal output' do
|
4
|
+
it 'should display this passing specs in green' do
|
5
5
|
true.should.eql? true
|
6
6
|
end
|
7
7
|
|
8
|
-
it 'should display empty
|
8
|
+
it 'should display this empty spec in yellow' do
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should display
|
11
|
+
it 'should display this error-raising spec in purple/magenta' do
|
12
12
|
raise 'this is a dummy error'
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should display failed
|
15
|
+
it 'should display this failed spec in red' do
|
16
16
|
should.flunk 'this is a dummy failure'
|
17
17
|
end
|
18
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disinnovate-greeneggs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Fleet
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|