Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Switch test base class to minitest/spec #69

Merged
merged 1 commit into from

2 participants

@tenderlove
Collaborator

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.

@tenderlove tenderlove 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.
d8b0f3b
@brianmario brianmario commented on the diff
@@ -1,3 +1,4 @@
source "http://rubygems.org"
gem 'rake-compiler'
+gem 'minitest', '~> 3.0.0'
@brianmario Owner

could/should we condition this for 1.8 only?

@tenderlove Collaborator

I figured we just have no conditional, but remove this line when (or if) rugged goes to 1.9 only. But a conditional would be fine too. This PR should work on 1.9 without adding gem 'minitest'.

@brianmario Owner

ah cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@brianmario
Owner

:+1:

@brianmario brianmario merged commit b81dab7 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 12, 2012
  1. @tenderlove

    Switch test base class to minitest/spec

    tenderlove authored
    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.
This page is out of date. Refresh to see the latest.
View
1  Gemfile
@@ -1,3 +1,4 @@
source "http://rubygems.org"
gem 'rake-compiler'
+gem 'minitest', '~> 3.0.0'
@brianmario Owner

could/should we condition this for 1.8 only?

@tenderlove Collaborator

I figured we just have no conditional, but remove this line when (or if) rugged goes to 1.9 only. But a conditional would be fine too. This PR should work on 1.9 without adding gem 'minitest'.

@brianmario Owner

ah cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
2  Gemfile.lock
@@ -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
View
2  test/config_test.rb
@@ -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
View
44 test/test_helper.rb
@@ -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
Something went wrong with that request. Please try again.