jgre-monkeyspecdoc 0.9.1

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 ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ $:.push File.dirname(__FILE__)
5
+ require 'specdoc'
6
+
7
+ ARGV.each do |file|
8
+ require file
9
+ end
data/examples/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ task :default => [:test]
2
+
3
+ task :test do
4
+ require 'rake/runtest'
5
+ require '../specdoc'
6
+ Rake.run_tests 'helloworld_test.rb'
7
+ end
@@ -0,0 +1,5 @@
1
+ class HelloWorld
2
+ def say_hello(io)
3
+ io.write('Hello, World')
4
+ end
5
+ end
@@ -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
data/lib/specdoc.rb ADDED
@@ -0,0 +1,75 @@
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
+ output_single("- #{should}: ")
50
+ else
51
+ test_started_old(name)
52
+ end
53
+ end
54
+
55
+ def add_fault(fault)
56
+ @faults << fault
57
+ @already_outputted = true
58
+ end
59
+
60
+ def test_finished(name)
61
+ if fault = @faults.find {|f| f.test_name == name}
62
+ fault_type = fault.is_a?(Test::Unit::Failure) ? "FAILED" : "ERROR"
63
+ output("\e[0;31m#{fault_type}\e[0m (#{@faults.length})")
64
+ else
65
+ output("\e[0;32mOK\e[0m")
66
+ end
67
+ @already_outputted = false
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{monkeyspecdoc}
3
+ s.version = "0.9.1"
4
+
5
+ s.authors = ["Janico Greifenberg"]
6
+ s.date = %q{2008-10-09}
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/specdoc.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
@@ -0,0 +1,11 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+
5
+ class TestError < Test::Unit::TestCase
6
+
7
+ should 'be ok' do
8
+ bla
9
+ end
10
+
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+
5
+ class TestFailure < Test::Unit::TestCase
6
+
7
+ should 'be ok' do
8
+ flunk
9
+ end
10
+
11
+ end
12
+
@@ -0,0 +1,45 @@
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 'specdoc'
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 /^- should be ok: .*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 /^- should be ok: .*FAILED.*(1)/, @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 /^- should be ok: .*ERROR.*(1)/, @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
+
45
+ end
@@ -0,0 +1,11 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+
5
+ class TestSuccess < Test::Unit::TestCase
6
+
7
+ should 'be ok' do
8
+ assert true
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jgre-monkeyspecdoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Janico Greifenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-09 00:00:00 -07:00
13
+ default_executable: mkspecdoc
14
+ dependencies: []
15
+
16
+ description: Specdoc output for Ruby's Test::Unit and Shoulda
17
+ email: jgre@jgre.org
18
+ executables:
19
+ - mkspecdoc
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - bin/mkspecdoc
26
+ - monkeyspecdoc.gemspec
27
+ - lib/specdoc.rb
28
+ - examples/helloworld.rb
29
+ - examples/helloworld_spec.rb
30
+ - examples/helloworld_test.rb
31
+ - examples/Rakefile
32
+ - test/error_test.rb
33
+ - test/failure_test.rb
34
+ - test/monkeyspecdoc_test.rb
35
+ - test/success_test.rb
36
+ has_rdoc: false
37
+ homepage: http://jgre.org/2008/09/03/monkeyspecdoc/
38
+ post_install_message:
39
+ rdoc_options: []
40
+
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
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Specdoc output for Ruby's Test::Unit and Shoulda
62
+ test_files:
63
+ - test/monkeyspecdoc_test.rb