Skip to content

Commit

Permalink
Add nanotest adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mynyml committed Nov 4, 2009
1 parent 5ba79a9 commit 004fbe4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Manifest
Expand Up @@ -6,6 +6,7 @@ Rakefile
lib/redgreen.rb
lib/redgreen/expectations.rb
lib/redgreen/minitest.rb
lib/redgreen/nanotest.rb
lib/redgreen/testunit.rb
redgreen.gemspec
specs.watchr
Expand All @@ -18,6 +19,8 @@ test/expectations/test_failure.rb
test/expectations/test_success.rb
test/minitest/test_failure.rb
test/minitest/test_success.rb
test/nanotest/test_failure.rb
test/nanotest/test_success.rb
test/shoulda/test_failure.rb
test/shoulda/test_success.rb
test/tests.rake
Expand Down
1 change: 1 addition & 0 deletions lib/redgreen.rb
Expand Up @@ -15,6 +15,7 @@ def visual
dir = Pathname(__FILE__).dirname.parent.join('lib/redgreen')

if defined?(Expectations::SuiteRunner) then require dir.join('expectations')
elsif defined?(NanoTest) then require dir.join('nanotest')
elsif defined?(MiniTest::Unit::TestCase) then require dir.join('minitest')
elsif defined?(Test::Unit::TestCase) then require dir.join('testunit')
end
10 changes: 10 additions & 0 deletions lib/redgreen/nanotest.rb
@@ -0,0 +1,10 @@
require 'nanotest'

at_exit do
if NanoTest::FAILURES.empty?
NanoTest::FAILURES << RedGreen.visual + "\n\n"
else
RedGreen.colour = :red
NanoTest::FAILURES << RedGreen.visual + "\n\n"
end
end
10 changes: 5 additions & 5 deletions specs.watchr
Expand Up @@ -5,11 +5,11 @@
# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch( '^test.*/test_.*\.rb' ) { |m| system "ruby -rubygems -I.:lib %s" % m[0] }
watch( '^lib/redgreen/(.*)\.rb' ) { |m| system "rake test:by_fw FW=%s" % m[1] }
watch( '^lib/redgreen/testunit\.rb' ) { |m| system "rake test:by_fw FW=testunit,shoulda,context,contest" }
watch( '^lib/redgreen\.rb' ) { |m| system "rake -s test:all" }
watch( '^test/test_helper\.rb' ) { |m| system "rake -s test:all" }
watch( '^test.*/test_.*\.rb' ) { |m| system "ruby -rubygems -I.:lib %s" % m[0] }
watch( '^lib/redgreen/(.*)\.rb' ) { |m| system "rake -s test:by_fw FW=%s" % m[1] }
watch( '^lib/redgreen/testunit\.rb' ) { |m| system "rake -s test:by_fw FW=testunit,shoulda,context,contest" }
watch( '^lib/redgreen\.rb' ) { |m| system "rake -s test:all" }
watch( '^test/test_helper\.rb' ) { |m| system "rake -s test:all" }

# --------------------------------------------------
# Signal Handling
Expand Down
5 changes: 5 additions & 0 deletions test/nanotest/test_failure.rb
@@ -0,0 +1,5 @@
require 'nanotest'
require 'lib/redgreen'

include NanoTest
assert { false }
5 changes: 5 additions & 0 deletions test/nanotest/test_success.rb
@@ -0,0 +1,5 @@
require 'nanotest'
require 'lib/redgreen'

include NanoTest
assert { true }
2 changes: 2 additions & 0 deletions test/tests.rake
Expand Up @@ -6,6 +6,8 @@ namespace(:test) do
test_root = Pathname(__FILE__).dirname

files = %w(
nanotest/test_failure.rb
nanotest/test_success.rb
testunit/test_failure.rb
testunit/test_success.rb
minitest/test_failure.rb
Expand Down

0 comments on commit 004fbe4

Please sign in to comment.