monkeyspecdoc 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/mkspecdoc +9 -0
- data/examples/Rakefile +7 -0
- data/examples/helloworld.rb +5 -0
- data/examples/helloworld_spec.rb +20 -0
- data/examples/helloworld_test.rb +24 -0
- data/lib/monkeyspecdoc.rb +81 -0
- data/monkeyspecdoc.gemspec +18 -0
- data/test/error_test.rb +11 -0
- data/test/failure_test.rb +12 -0
- data/test/monkeyspecdoc_test.rb +44 -0
- data/test/success_test.rb +11 -0
- metadata +72 -0
data/bin/mkspecdoc
ADDED
data/examples/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$: << File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'stringio'
|
6
|
+
require 'helloworld'
|
7
|
+
|
8
|
+
describe HelloWorld do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@hello = HelloWorld.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should say "Hello, World!"' do
|
15
|
+
sio = StringIO.new
|
16
|
+
@hello.say_hello(sio)
|
17
|
+
sio.string.should == 'Hello, World!'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
$: << File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'shoulda'
|
6
|
+
require 'stringio'
|
7
|
+
require 'helloworld'
|
8
|
+
|
9
|
+
class TestHelloWorld < Test::Unit::TestCase
|
10
|
+
|
11
|
+
context 'HelloWorld' do
|
12
|
+
|
13
|
+
setup do
|
14
|
+
@hello = HelloWorld.new
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'say "Hello, World!"' do
|
18
|
+
sio = StringIO.new
|
19
|
+
@hello.say_hello(sio)
|
20
|
+
assert_equal 'Hello, World!', sio.string
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'test/unit/ui/console/testrunner'
|
3
|
+
|
4
|
+
def split_shoulda_names(name)
|
5
|
+
if /test: (.*) (should .*)\./ =~ name
|
6
|
+
[$1, $2]
|
7
|
+
elsif /(.*)\(Test(.*)\)/ =~ name
|
8
|
+
[$2, $1]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Test
|
13
|
+
module Unit
|
14
|
+
|
15
|
+
class Failure
|
16
|
+
def long_display
|
17
|
+
location_display = if(location.size == 1)
|
18
|
+
location[0].sub(/\A(.+:\d+).*/, ' [\\1]')
|
19
|
+
else
|
20
|
+
"\n [#{location.join("\n ")}]"
|
21
|
+
end
|
22
|
+
name=(split=split_shoulda_names(@test_name))?split.join(" "):@test_name
|
23
|
+
"#{name} FAILED: #{location_display}:\n #@message"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Error
|
28
|
+
def long_display
|
29
|
+
backtrace = filter_backtrace(@exception.backtrace).join("\n ")
|
30
|
+
name=(split=split_shoulda_names(@test_name))?split.join(" "):@test_name
|
31
|
+
"#{@exception.class.name} in #{name}:\n#{message}\n #{backtrace}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module UI
|
36
|
+
module Console
|
37
|
+
class TestRunner
|
38
|
+
|
39
|
+
alias_method :test_started_old, :test_started
|
40
|
+
|
41
|
+
def test_started(name)
|
42
|
+
ctx, should = split_shoulda_names(name)
|
43
|
+
unless ctx.nil? or should.nil?
|
44
|
+
if ctx != @ctx
|
45
|
+
nl
|
46
|
+
output("#{ctx}:")
|
47
|
+
end
|
48
|
+
@ctx = ctx
|
49
|
+
@current_test_text = " ==> #{should}"
|
50
|
+
#output_single("- #{should}: ")
|
51
|
+
else
|
52
|
+
test_started_old(name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_fault(fault)
|
57
|
+
@faults << fault
|
58
|
+
@already_outputted = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_finished(name)
|
62
|
+
# can cause issues if there's no test text.
|
63
|
+
@current_test_text = ' ' if @current_test_text.empty? || @current_test_text.nil?
|
64
|
+
if fault = @faults.find {|f| f.test_name == name}
|
65
|
+
# Added ! to ERROR for length consistency
|
66
|
+
fault_type = fault.is_a?(Test::Unit::Failure) ? "FAILED" : "ERROR!"
|
67
|
+
# NOTE -- Concatenation because "\e[0m]" does funky stuff.
|
68
|
+
output("[\e[0;31m#{fault_type}\e[0m" + "]#{@current_test_text} (#{@faults.length})")
|
69
|
+
else
|
70
|
+
# Added spaces on either side of OK for length consistency
|
71
|
+
output("[ \e[0;32mOK\e[0m ]#{@current_test_text}")
|
72
|
+
end
|
73
|
+
@already_outputted = false
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{monkeyspecdoc}
|
3
|
+
s.version = "0.9.5"
|
4
|
+
|
5
|
+
s.authors = ["Janico Greifenberg"]
|
6
|
+
s.date = %q{2008-12-18}
|
7
|
+
s.default_executable = %q{mkspecdoc}
|
8
|
+
s.description = %q{Specdoc output for Ruby's Test::Unit and Shoulda}
|
9
|
+
s.email = %q{jgre@jgre.org}
|
10
|
+
s.executables = ["mkspecdoc"]
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.files = %w{bin/mkspecdoc monkeyspecdoc.gemspec lib/monkeyspecdoc.rb examples/helloworld.rb examples/helloworld_spec.rb examples/helloworld_test.rb examples/Rakefile test/error_test.rb test/failure_test.rb test/monkeyspecdoc_test.rb test/success_test.rb}
|
13
|
+
s.has_rdoc = false
|
14
|
+
s.homepage = %q{http://jgre.org/2008/09/03/monkeyspecdoc/}
|
15
|
+
s.summary = %q{Specdoc output for Ruby's Test::Unit and Shoulda}
|
16
|
+
s.test_files = ["test/monkeyspecdoc_test.rb"]
|
17
|
+
end
|
18
|
+
|
data/test/error_test.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
$: << File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'test/unit/ui/console/testrunner'
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'shoulda'
|
9
|
+
require 'monkeyspecdoc'
|
10
|
+
require 'stringio'
|
11
|
+
|
12
|
+
|
13
|
+
class TestMonkeySpecDoc < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@sio = StringIO.new
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'print success messages' do
|
20
|
+
require 'success_test'
|
21
|
+
Test::Unit::UI::Console::TestRunner.new(TestSuccess, 2, @sio).start
|
22
|
+
assert_match /^Success:$/, @sio.string
|
23
|
+
assert_match /^\[ .*OK.* \] ==> should be ok/, @sio.string
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'print failure messages' do
|
27
|
+
require 'failure_test'
|
28
|
+
Test::Unit::UI::Console::TestRunner.new(TestFailure, 2, @sio).start
|
29
|
+
assert_match /^Failure:$/, @sio.string
|
30
|
+
assert_match /^\[.*FAILED.*\] ==> should be ok \(\d\)/, @sio.string
|
31
|
+
assert_match /1\) Failure should be ok FAILED:/, @sio.string
|
32
|
+
assert_match /Flunked./, @sio.string
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'print error messages' do
|
36
|
+
require 'error_test'
|
37
|
+
Test::Unit::UI::Console::TestRunner.new(TestError, 2, @sio).start
|
38
|
+
assert_match /^Error:$/, @sio.string
|
39
|
+
assert_match /^\[.*ERROR\!.*\] ==> should be ok \(\d\)/, @sio.string
|
40
|
+
assert_match /1\) NameError in Error should be ok:/, @sio.string
|
41
|
+
assert_match /NameError: undefined local variable or method .bla. for/,
|
42
|
+
@sio.string
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monkeyspecdoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 5
|
9
|
+
version: 0.9.5
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Janico Greifenberg
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2008-12-18 00:00:00 +01:00
|
18
|
+
default_executable: mkspecdoc
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Specdoc output for Ruby's Test::Unit and Shoulda
|
22
|
+
email: jgre@jgre.org
|
23
|
+
executables:
|
24
|
+
- mkspecdoc
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- bin/mkspecdoc
|
31
|
+
- monkeyspecdoc.gemspec
|
32
|
+
- lib/monkeyspecdoc.rb
|
33
|
+
- examples/helloworld.rb
|
34
|
+
- examples/helloworld_spec.rb
|
35
|
+
- examples/helloworld_test.rb
|
36
|
+
- examples/Rakefile
|
37
|
+
- test/error_test.rb
|
38
|
+
- test/failure_test.rb
|
39
|
+
- test/monkeyspecdoc_test.rb
|
40
|
+
- test/success_test.rb
|
41
|
+
has_rdoc: false
|
42
|
+
homepage: http://jgre.org/2008/09/03/monkeyspecdoc/
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.6
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Specdoc output for Ruby's Test::Unit and Shoulda
|
71
|
+
test_files:
|
72
|
+
- test/monkeyspecdoc_test.rb
|