Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch test base class to minitest/spec

Switching base test class to minitest/spec so that test/spec/mini 3 can
be removed.  Method aliases keep backwards compatibility so that we
don't have to change every test file.
  • Loading branch information...
commit d8b0f3b74c264cae3cdf06665bc002fd7d5175db 1 parent 4ea3d82
Aaron Patterson authored
1  Gemfile
View
@@ -1,3 +1,4 @@
source "http://rubygems.org"
gem 'rake-compiler'
+gem 'minitest', '~> 3.0.0'
2  Gemfile.lock
View
@@ -1,6 +1,7 @@
GEM
remote: http://rubygems.org/
specs:
+ minitest (3.0.1)
rake (0.9.2.2)
rake-compiler (0.7.9)
rake
@@ -9,4 +10,5 @@ PLATFORMS
ruby
DEPENDENCIES
+ minitest (~> 3.0.0)
rake-compiler
2  test/config_test.rb
View
@@ -2,7 +2,7 @@
context "Rugged::Config tests" do
setup do
- @repo = Rugged::Repository.new(test_repo('testrepo.git'))
+ @repo = Rugged::Repository.new(temp_repo('testrepo.git'))
end
test "can read the config file from repo" do
44 test/test_helper.rb
View
@@ -1,42 +1,34 @@
-dir = File.dirname(File.expand_path(__FILE__))
-$LOAD_PATH.unshift dir + '/../lib'
$TEST_DIR = File.dirname(File.expand_path(__FILE__))
$TESTING = true
-require 'test/unit'
require 'tempfile'
require 'rubygems'
+require 'minitest/autorun'
require 'rugged'
require 'pp'
-##
-# test/spec/mini 3
-# http://gist.github.com/25455
-# chris@ozmm.org
-#
-def context(*args, &block)
- return super unless (name = args.first) && block
- require 'test/unit'
- klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
- def self.test(name, &block)
- define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
+# backwards compat with test/spec/mini 3
+alias :context :describe
+
+module Rugged
+ class TestCase < MiniTest::Spec
+ class << self
+ # backwards compat with test/spec/mini 3
+ alias :setup :before
+ alias :teardown :after
+ alias :test :it
end
- def self.xtest(*args) end
- def self.setup(&block) define_method(:setup, &block) end
- def self.teardown(&block) define_method(:teardown, &block) end
+
+ # backwards compat with test/unit
+ alias :assert_not_nil :refute_nil
+ alias :assert_raise :assert_raises
end
- (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
- klass.class_eval &block
- ($contexts ||= []) << klass # make sure klass doesn't get GC'd
- klass
end
-def testpath(path)
- File.join($TEST_DIR, path)
-end
+MiniTest::Spec.register_spec_type(/./, Rugged::TestCase)
-def test_repo(repo)
+def temp_repo(repo)
dir = temp_dir
- repo_dir = testpath(File.join('fixtures', repo, '.'))
+ repo_dir = File.join($TEST_DIR, (File.join('fixtures', repo, '.')))
`git clone #{repo_dir} #{dir}`
dir
end
Please sign in to comment.
Something went wrong with that request. Please try again.