Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: libgit2/rugged
...
head fork: libgit2/rugged
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 13, 2012
@tenderlove tenderlove Give a hoot, don't pollute... the global namespace
* Move test related methods to the base class test case
* Move global variables to constants inside the base test case
96d902b
@vmg vmg Merge pull request #74 from tenderlove/give_a_hoot
Give a hoot, don't pollute... the global namespace
7dd043e
Showing with 28 additions and 31 deletions.
  1. +28 −31 test/test_helper.rb
View
59 test/test_helper.rb
@@ -1,5 +1,3 @@
-$TEST_DIR = File.dirname(File.expand_path(__FILE__))
-$TESTING = true
require 'tempfile'
require 'tmpdir'
require 'rubygems'
@@ -12,6 +10,8 @@
module Rugged
class TestCase < MiniTest::Spec
+ TEST_DIR = File.dirname(File.expand_path(__FILE__))
+
class << self
# backwards compat with test/spec/mini 3
alias :setup :before
@@ -22,43 +22,40 @@ class << self
# backwards compat with test/unit
alias :assert_not_nil :refute_nil
alias :assert_raise :assert_raises
- end
-end
-
-MiniTest::Spec.register_spec_type(/./, Rugged::TestCase)
-
-def temp_repo(repo)
- dir = temp_dir
- repo_dir = File.join($TEST_DIR, (File.join('fixtures', repo, '.')))
- `git clone #{repo_dir} #{dir}`
- dir
-end
-def temp_dir
- Dir.mktmpdir 'dir'
-end
+ private
-def rm_loose(oid)
+ def temp_repo(repo)
+ dir = Dir.mktmpdir 'dir'
+ repo_dir = File.join(TEST_DIR, (File.join('fixtures', repo, '.')))
+ `git clone #{repo_dir} #{dir}`
+ dir
+ end
- base_path = File.join(@path, "objects", oid[0, 2])
+ def rm_loose(oid)
+ base_path = File.join(@path, "objects", oid[0, 2])
- file = File.join(base_path, oid[2, 38])
- dir_contents = File.join(base_path, "*")
+ file = File.join(base_path, oid[2, 38])
+ dir_contents = File.join(base_path, "*")
- File.delete(file)
+ File.delete(file)
- if Dir[dir_contents].empty?
- Dir.delete(base_path)
- end
-end
+ if Dir[dir_contents].empty?
+ Dir.delete(base_path)
+ end
+ end
-def with_default_encoding(encoding, &block)
- old_encoding = Encoding.default_internal
+ def with_default_encoding(encoding, &block)
+ old_encoding = Encoding.default_internal
- new_encoding = Encoding.find(encoding)
- Encoding.default_internal = new_encoding
+ new_encoding = Encoding.find(encoding)
+ Encoding.default_internal = new_encoding
- yield new_encoding
+ yield new_encoding
- Encoding.default_internal = old_encoding
+ Encoding.default_internal = old_encoding
+ end
+ end
end
+
+MiniTest::Spec.register_spec_type(/./, Rugged::TestCase)

No commit comments for this range

Something went wrong with that request. Please try again.