Merge pull request #31 from ghoneycutt/noticket/master/missing_trailing_comma
[puppet_vcsrepo.git] / spec / unit / puppet / provider / vcsrepo / svn_spec.rb
1 require 'pathname'; Pathname.new(__FILE__).realpath.ascend { |x| begin; require (x + 'spec_helper.rb'); break; rescue LoadError; end }
2
3 describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
4
5   describe 'creating' do
6     resource_with :source do
7       resource_with :revision do
8         it "should execute 'svn checkout' with a revision" do
9           provider.expects(:svn).with('checkout', '-r',
10                                       resource.value(:revision),
11                                       resource.value(:source),
12                                       resource.value(:path))
13           provider.create
14         end
15       end
16       resource_without :revision do
17         it "should just execute 'svn checkout' without a revision" do
18           provider.expects(:svn).with('checkout',
19                                       resource.value(:source),
20                                       resource.value(:path))
21           provider.create
22         end
23       end
24     end
25     resource_without :source do
26       resource_with :fstype do
27         it "should execute 'svnadmin create' with an '--fs-type' option" do
28           provider.expects(:svnadmin).with('create', '--fs-type',
29                                            resource.value(:fstype),
30                                            resource.value(:path))
31           provider.create
32         end
33       end
34       resource_without :fstype do
35         it "should execute 'svnadmin create' without an '--fs-type' option" do
36           provider.expects(:svnadmin).with('create', resource.value(:path))
37           provider.create
38         end
39       end
40     end
41   end
42
43   describe 'destroying' do
44     it "it should remove the directory" do
45       expects_rm_rf
46       provider.destroy
47     end
48   end
49
50   describe "checking existence" do
51     it "should check for the directory" do
52       expects_directory?(true, File.join(resource.value(:path), '.svn'))
53       provider.exists?
54     end
55   end
56
57   describe "checking the revision property" do
58     before do
59       provider.expects('svn').with('info').returns(fixture(:svn_info))
60     end
61     it "should use 'svn info'" do
62       expects_chdir
63       provider.revision.should == '4'
64     end
65   end
66
67   describe "setting the revision property" do
68     before do
69       @revision = '30'
70     end
71     it "should use 'svn update'" do
72       expects_chdir
73       provider.expects('svn').with('update', '-r', @revision)
74       provider.revision = @revision
75     end
76   end
77
78 end