Permalink
Browse files

run a subdirectory of tests, closes #1

  • Loading branch information...
1 parent a8f7ba9 commit ba3f1496c4c7fc0bf71543231293875d368d9802 @qrush committed Jan 12, 2012
View
@@ -11,6 +11,16 @@ def initialize(argv)
# Parse out ARGV, it should be coming in in a format like `test/test_file.rb:9`
@file, line = argv.first.split(':')
@line = line.to_i
+
+ if Dir.exist?(@file)
+ require 'rake/testtask'
+ Rake::TestTask.new(:custom) do |t|
+ t.libs << 'test'
+ t.pattern = "#{@file}/*test*.rb"
+ end
+ Rake::Task['custom'].invoke
+ exit
+ end
end
end
View
@@ -11,8 +11,8 @@ Gem::Specification.new do |gem|
gem.version = "0.0.1"
gem.add_runtime_dependency "method_source", "~> 0.6.7"
+ gem.add_runtime_dependency "rake", "~> 0.9.2.2"
gem.add_development_dependency "activesupport"
- gem.add_development_dependency "rake"
gem.add_development_dependency "rdiscount"
gem.add_development_dependency "rocco"
@@ -2,7 +2,7 @@
class ActiveSupportTest < MTest
def test_run_simple_test_by_line_number
- output = m('examples/active_support_example_test.rb:11')
+ output = m('examples/active_support_example_test.rb:12')
assert_output /1 tests, 1 assertions/, output
end
@@ -12,17 +12,17 @@ def test_runs_entire_test_without_line_number
end
def test_run_inside_of_test
- output = m('examples/active_support_example_test.rb:12')
+ output = m('examples/active_support_example_test.rb:13')
assert_output /1 tests, 1 assertions/, output
end
def test_run_on_end_of_test
- output = m('examples/active_support_example_test.rb:13')
+ output = m('examples/active_support_example_test.rb:14')
assert_output /1 tests, 1 assertions/, output
end
def test_run_inside_big_test
- output = m('examples/active_support_example_test.rb:17')
+ output = m('examples/active_support_example_test.rb:18')
assert_output /1 tests, 3 assertions/, output
end
@@ -33,16 +33,16 @@ def test_run_on_blank_line_orders_tests_by_line_number
expected = <<-EOF
No tests found on line 2. Valid tests to run:
- test_normal: m examples/active_support_example_test.rb:7
- test_carrot: m examples/active_support_example_test.rb:11
- test_daikon: m examples/active_support_example_test.rb:15
-test_eggplant_fig: m examples/active_support_example_test.rb:21
+ test_normal: m examples/active_support_example_test.rb:8
+ test_carrot: m examples/active_support_example_test.rb:12
+ test_daikon: m examples/active_support_example_test.rb:16
+test_eggplant_fig: m examples/active_support_example_test.rb:22
EOF
assert_equal expected.strip, output
end
def test_run_on_test_with_spaces
- output = m('examples/active_support_example_test.rb:21')
+ output = m('examples/active_support_example_test.rb:22')
assert_output /1 tests, 1 assertions/, output
end
end
View
@@ -12,4 +12,12 @@ def test_missing_file_gives_a_decent_error_message
assert_match /Failed loading test file/, output
assert_match /cannot load such file/, output
end
+
+ def test_running_tests_within_a_subdirectory
+ output = m('examples/subdir')
+ assert_output /3 tests/, output
+
+ output = m('examples')
+ assert_output /10 tests/, output
+ end
end
@@ -1,4 +1,5 @@
-require 'test_helper'
+require 'test/unit'
+require 'active_support/test_case'
class ActiveSupportExampleTest < ActiveSupport::TestCase
setup do
@@ -1,4 +1,5 @@
-require 'test_helper'
+require 'test/unit'
+require 'active_support/test_case'
class MultipleExampleTest < ActiveSupport::TestCase
%w(grape habanero iceplant).each do |fruit|
@@ -0,0 +1,7 @@
+require 'test/unit'
+
+class ATest < Test::Unit::TestCase
+ def test_a
+ assert_equal 1, 1
+ end
+end
@@ -0,0 +1,7 @@
+require 'test/unit'
+
+class BTest < Test::Unit::TestCase
+ def test_b
+ assert_equal 1, 1
+ end
+end
@@ -0,0 +1,7 @@
+require 'test/unit'
+
+class CTest < Test::Unit::TestCase
+ def test_c
+ assert_equal 1, 1
+ end
+end
@@ -1,4 +1,4 @@
-require 'test_helper'
+require 'test/unit'
class TestUnitExampleTest < Test::Unit::TestCase
def setup
View
@@ -1,4 +1,3 @@
-require 'rubygems'
require 'test/unit'
require 'active_support/test_case'

0 comments on commit ba3f149

Please sign in to comment.