Skip to content
Browse files

+ Split minitest/excludes.rb out to its own gem

[git-p4: depot-paths = "//src/minitest/dev/": change = 6831]
  • Loading branch information...
1 parent 546c779 commit c19fd85653eeee6eea66265b6822d1ef46bafe5f @zenspider zenspider committed Dec 20, 2011
Showing with 17 additions and 141 deletions.
  1. +0 −2 Manifest.txt
  2. +0 −72 lib/minitest/excludes.rb
  3. +0 −67 test/test_minitest_excludes.rb
  4. +17 −0 x.rb
View
2 Manifest.txt
@@ -7,14 +7,12 @@ design_rationale.rb
lib/hoe/minitest.rb
lib/minitest/autorun.rb
lib/minitest/benchmark.rb
-lib/minitest/excludes.rb
lib/minitest/mock.rb
lib/minitest/pride.rb
lib/minitest/spec.rb
lib/minitest/unit.rb
test/metametameta.rb
test/test_minitest_benchmark.rb
-test/test_minitest_excludes.rb
test/test_minitest_mock.rb
test/test_minitest_spec.rb
test/test_minitest_unit.rb
View
72 lib/minitest/excludes.rb
@@ -1,72 +0,0 @@
-require 'minitest/unit'
-
-##
-# minitest/excludes.rb extends MiniTest::Unit::TestCase to provide a
-# clean API for excluding certain tests you don't want to run under
-# certain conditions.
-#
-# For example, in test/test_xyz.rb you have:
-#
-# class TestXYZ < MiniTest::Unit::TestCase
-# def test_good
-# # test that passes
-# end
-#
-# def test_bad
-# # test that fails only on jruby
-# end
-# end
-#
-# For jruby runs, you can add test/excludes/TestXYZ.rb with:
-#
-# exclude :test_bad, "Uses ObjectSpace" if jruby?
-#
-# The file is instance_eval'd on TestXYZ so you can call the exclude
-# class method directly. Since it is ruby you can provide any sort
-# of conditions you want to figure out if your tests should be
-# excluded.
-#
-# TestCase.exclude causes test methods to call skip with the reason
-# you provide. If you run your tests in verbose mode, you'll see a
-# full report of the tests you've excluded.
-#
-# If you want to change where the exclude files are located, you can
-# set the EXCLUDE_DIR environment variable.
-
-class MiniTest::Unit::TestCase
- EXCLUDE_DIR = ENV['EXCLUDE_DIR'] || "test/excludes"
-
- ##
- # Exclude a test from a testcase. This is intended to be used by
- # exclusion files.
-
- def self.exclude name, reason
- return warn "Method #{self}##{name} is not defined" unless
- method_defined? name
-
- remove_method name
- end
-
- ##
- # Loads the exclusion file for the class, if any.
-
- def self.load_excludes
- @__load_excludes__ ||=
- begin
- if name and not name.empty? then
- file = File.join EXCLUDE_DIR, "#{name.gsub(/::/, '/')}.rb"
- instance_eval File.read file if File.exist? file
- end
- true
- end
- end
-
- class << self
- alias :old_test_methods :test_methods # :nodoc:
-
- def test_methods # :nodoc:
- load_excludes
- old_test_methods
- end
- end
-end
View
67 test/test_minitest_excludes.rb
@@ -1,67 +0,0 @@
-require 'test/metametameta'
-require 'minitest/excludes'
-
-class TestMiniTestExcludes < MetaMetaMetaTestCase
- def test_cls_excludes
- srand 42
- old_exclude_base = MiniTest::Unit::TestCase::EXCLUDE_DIR
-
- @assertion_count = 0
-
- Dir.mktmpdir do |path|
- MiniTest::Unit::TestCase::EXCLUDE_DIR.replace(path)
- Dir.mkdir File.join path, "ATestCase"
-
- s = 'exclude :test_test2, "because it is borked"'
-
- File.open File.join(path, "ATestCase.rb"), "w" do |f|
- f.puts s
- end
-
- File.open File.join(path, "ATestCase/Nested.rb"), "w" do |f|
- f.puts s
- end
-
- tc1 = tc2 = nil
-
- tc1 = Class.new(MiniTest::Unit::TestCase) do
- def test_test1; assert true end
- def test_test2; assert false end # oh noes!
- def test_test3; assert true end
-
- tc2 = Class.new(MiniTest::Unit::TestCase) do
- def test_test1; assert true end
- def test_test2; assert false end # oh noes!
- def test_test3; assert true end
- end
- end
-
- Object.const_set(:ATestCase, tc1)
- ATestCase.const_set(:Nested, tc2)
-
- assert_equal %w(test_test3 test_test1), ATestCase.test_methods
- assert_equal %w(test_test1 test_test3), ATestCase::Nested.test_methods
-
- @tu.run %w[--seed 42 --verbose]
-
- expected = <<-EOM.gsub(/^ {8}/, '')
- Run options: --seed 42 --verbose
-
- # Running tests:
-
- ATestCase#test_test1 = 0.00 s = .
- ATestCase#test_test3 = 0.00 s = .
- ATestCase::Nested#test_test1 = 0.00 s = .
- ATestCase::Nested#test_test3 = 0.00 s = .
-
-
- Finished tests in 0.00
-
- 4 tests, 4 assertions, 0 failures, 0 errors, 0 skips
- EOM
- assert_report expected
- end
- ensure
- MiniTest::Unit::TestCase::EXCLUDE_DIR.replace(old_exclude_base)
- end
-end
View
17 x.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/ruby -w
+
+require 'minitest/autorun'
+
+class User; end
+
+describe User do
+ before do
+ @greeting = "Hello, world"
+ end
+
+ describe "greeting" do
+ it "should contain a greeting" do
+ assert @greeting, "must not be nil"
+ end
+ end
+end

0 comments on commit c19fd85

Please sign in to comment.
Something went wrong with that request. Please try again.