Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exception when Git is autoloaded (#594)
Signed-off-by: James Couball <jcouball@yahoo.com>
- Loading branch information
Showing
4 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
Dir.chdir(File.dirname(__FILE__)) do | ||
Dir.glob('**/test_*.rb') do |test_case| | ||
require "#{File.expand_path(File.dirname(__FILE__))}/#{test_case}" | ||
Dir.glob('**/test_*.rb') do |test_case| | ||
require "#{File.expand_path(File.dirname(__FILE__))}/#{test_case}" | ||
end | ||
end | ||
|
||
# To run a single test: | ||
# require_relative 'units/test_lib_meets_required_version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class TestLibMeetsRequiredVersion < Test::Unit::TestCase | ||
def test_with_supported_command_version | ||
lib = Git::Lib.new(nil, nil) | ||
major_version, minor_version = lib.required_command_version | ||
lib.define_singleton_method(:current_command_version) { [major_version, minor_version] } | ||
assert lib.meets_required_version? | ||
end | ||
|
||
def test_with_old_command_version | ||
lib = Git::Lib.new(nil, nil) | ||
major_version, minor_version = lib.required_command_version | ||
|
||
# Set the major version to be returned by #current_command_version to be an | ||
# earlier version than required | ||
major_version = major_version - 1 | ||
|
||
lib.define_singleton_method(:current_command_version) { [major_version, minor_version] } | ||
assert !lib.meets_required_version? | ||
end | ||
end |