spec/mirror_spec.rb in braid-1.0.17 vs spec/mirror_spec.rb in braid-1.0.18

- old
+ new

@@ -13,10 +13,62 @@ it 'should strip trailing slash from specified path' do new_from_options('http://path.git', 'path' => 'vendor/tools/mytool/') expect(@mirror.path).to eq('vendor/tools/mytool') end + + it 'should define local_ref correctly when default branch specified' do + new_from_options('http://mytool.git') + expect(@mirror.local_ref).to eq('master/braid/mytool/master') + end + + it 'should define local_ref correctly when explicit branch specified' do + new_from_options('http://mytool.git', 'branch' => 'mybranch') + expect(@mirror.local_ref).to eq('mybranch/braid/mytool/mybranch') + end + + it 'should define local_ref correctly when explicit tag specified' do + new_from_options('http://mytool.git', 'tag' => 'v1') + expect(@mirror.local_ref).to eq('tags/v1') + end + + it 'should raise an exception if both tag and branch specified' do + expect { + new_from_options('http://mytool.git', 'tag' => 'v1', 'branch' => 'mybranch') + }.to raise_error(Braid::Mirror::NoTagAndBranch) + end + + it 'should define remote_ref correctly when default branch specified' do + new_from_options('http://mytool.git') + expect(@mirror.remote_ref).to eq('+refs/heads/master') + end + + it 'should define remote_ref correctly when explicit branch specified' do + new_from_options('http://mytool.git', 'branch' => 'mybranch') + expect(@mirror.remote_ref).to eq('+refs/heads/mybranch') + end + + it 'should define remote_ref correctly when explicit tag specified' do + new_from_options('http://mytool.git', 'tag' => 'v1') + expect(@mirror.remote_ref).to eq('+refs/tags/v1') + end + + it 'should define remote correctly when default branch specified' do + new_from_options('http://mytool.git') + expect(@mirror.remote).to eq('master/braid/mytool') + end + + it 'should define remote correctly when explicit branch specified' do + new_from_options('http://mytool.git', 'branch' => 'mybranch') + expect(@mirror.remote).to eq('mybranch/braid/mytool') + end + + it 'should define remote correctly when explicit tag specified' do + new_from_options('http://mytool.git', 'tag' => 'v1') + expect(@mirror.remote).to eq('v1/braid/mytool') + end + end describe 'Braid::Mirror#diff' do before(:each) do @mirror = build_mirror('revision' => 'a' * 40, 'url' => 'git://path') @@ -61,11 +113,11 @@ describe 'Braid::Mirror#inferred_revision' do it 'should return the last commit before the most recent update' do @mirror = new_from_options('git://path') git.expects(:rev_list).times(2).returns( - "#{'a' * 40}\n", - "commit #{'b' * 40}\n#{'t' * 40}\n" + "#{'a' * 40}\n", + "commit #{'b' * 40}\n#{'t' * 40}\n" ) git.expects(:tree_hash).with(@mirror.path, 'a' * 40).returns('t' * 40) expect(@mirror.send(:inferred_revision)).to eq('b' * 40) end end