1 require 'pathname'; Pathname.new(__FILE__).realpath.ascend { |x| begin; require (x + 'spec_helper.rb'); break; rescue LoadError; end }
3 describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
6 resource_with :source do
7 resource_with :revision do
8 it "should execute 'hg clone -u' with the revision" do
9 provider.expects(:hg).with('clone', '-u',
10 resource.value(:revision),
11 resource.value(:source),
12 resource.value(:path))
17 resource_without :revision do
18 it "should just execute 'hg clone' without a revision" do
19 provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
25 context "when a source is not given" do
26 it "should execute 'hg init'" do
27 provider.expects(:hg).with('init', resource.value(:path))
33 describe 'destroying' do
34 it "it should remove the directory" do
40 describe "checking existence" do
41 it "should check for the directory" do
42 expects_directory?(true, File.join(resource.value(:path), '.hg'))
47 describe "checking the revision property" do
52 context "when given a non-SHA as the resource revision" do
54 provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
55 provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
58 context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do
59 it "should return the ref" do
60 provider.revision.should == '0.6'
64 context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
65 it "should return the current SHA" do
66 provider.revision.should == '34e6012c783a'
70 context "when given a SHA as the resource revision" do
72 provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
75 context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
76 it "should return it" do
77 provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
78 provider.revision.should == resource.value(:revision)
82 context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
83 it "should return the current SHA" do
84 provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
85 provider.revision.should == '34e6012c783a'
91 describe "setting the revision property" do
93 @revision = '6aa99e9b3ab1'
95 it "should use 'hg update ---clean -r'" do
97 provider.expects('hg').with('pull')
98 provider.expects('hg').with('merge')
99 provider.expects('hg').with('update', '--clean', '-r', @revision)
100 provider.revision = @revision