Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68bf90f
commit 7e87e04
Showing
5 changed files
with
49 additions
and
49 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
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,66 +1,66 @@ | ||
require File.dirname(__FILE__) + '/test_helper' | ||
|
||
describe "Braid::Operations::Git#remote_url" do | ||
it "should use git config" do | ||
describe 'Braid::Operations::Git#remote_url' do | ||
it 'should use git config' do | ||
# FIXME weak test | ||
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns("git://path") | ||
git.remote_url("braid/git/one").should == "git://path" | ||
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns('git://path') | ||
git.remote_url('braid/git/one').should == 'git://path' | ||
end | ||
end | ||
|
||
describe "Braid::Operations::Git#rev_parse" do | ||
it "should return the full hash when a hash is found" do | ||
describe 'Braid::Operations::Git#rev_parse' do | ||
it 'should return the full hash when a hash is found' do | ||
full_revision = 'a' * 40 | ||
git.expects(:exec).returns([0, full_revision, ""]) | ||
git.expects(:exec).returns([0, full_revision, '']) | ||
git.rev_parse('a' * 7).should == full_revision | ||
end | ||
|
||
it "should raise a revision error when the hash is not found" do | ||
it 'should raise a revision error when the hash is not found' do | ||
ambiguous_revision = 'b' * 7 | ||
git.expects(:exec).returns([1, ambiguous_revision, "fatal: ..."]) | ||
git.expects(:exec).returns([1, ambiguous_revision, 'fatal: ...']) | ||
lambda { git.rev_parse(ambiguous_revision) }.should raise_error(Braid::Operations::UnknownRevision) | ||
end | ||
end | ||
|
||
describe "Braid::Operations::Git#version" do | ||
ACTUAL_VERSION = "1.5.5.1.98.gf0ec4" | ||
describe 'Braid::Operations::Git#version' do | ||
ACTUAL_VERSION = '1.5.5.1.98.gf0ec4' | ||
|
||
before(:each) do | ||
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ""]) | ||
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", '']) | ||
end | ||
|
||
it "should extract from git --version output" do | ||
it 'should extract from git --version output' do | ||
git.version.should == ACTUAL_VERSION | ||
end | ||
end | ||
|
||
describe "Braid::Operations::Git#require_version" do | ||
REQUIRED_VERSION = "1.5.4.5" | ||
describe 'Braid::Operations::Git#require_version' do | ||
REQUIRED_VERSION = '1.5.4.5' | ||
PASS_VERSIONS = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4) | ||
FAIL_VERSIONS = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6) | ||
|
||
def set_version(str) | ||
git.expects(:exec).returns([0, "git version #{str}\n", ""]) | ||
git.expects(:exec).returns([0, "git version #{str}\n", '']) | ||
end | ||
|
||
it "should return true for higher revisions" do | ||
it 'should return true for higher revisions' do | ||
PASS_VERSIONS.each do |version| | ||
set_version(version) | ||
git.require_version(REQUIRED_VERSION).should == true | ||
end | ||
end | ||
|
||
it "should return false for lower revisions" do | ||
it 'should return false for lower revisions' do | ||
FAIL_VERSIONS.each do |version| | ||
set_version(version) | ||
git.require_version(REQUIRED_VERSION).should == false | ||
end | ||
end | ||
end | ||
|
||
describe "Braid::Operations::GitCache#path" do | ||
it "should use the local cache directory and strip characters" do | ||
git_cache.path("git://path").should == File.join(Braid.local_cache_dir, "git___path") | ||
git_cache.path("git@domain:repository.git").should == File.join(Braid.local_cache_dir, "git_domain_repository.git") | ||
describe 'Braid::Operations::GitCache#path' do | ||
it 'should use the local cache directory and strip characters' do | ||
git_cache.path('git://path').should == File.join(Braid.local_cache_dir, 'git___path') | ||
git_cache.path('git@domain:repository.git').should == File.join(Braid.local_cache_dir, 'git_domain_repository.git') | ||
end | ||
end |