diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/filesystem_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/fixture_helpers.rb | 1 | ||||
-rw-r--r-- | spec/support/provider_example_group.rb | 6 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/bzr_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 22 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 6 |
7 files changed, 31 insertions, 32 deletions
diff --git a/spec/support/filesystem_helpers.rb b/spec/support/filesystem_helpers.rb index 08345b4..15e2ca7 100644 --- a/spec/support/filesystem_helpers.rb +++ b/spec/support/filesystem_helpers.rb @@ -3,7 +3,7 @@ module FilesystemHelpers def expects_chdir(path = resource.value(:path)) Dir.expects(:chdir).with(path).at_least_once.yields end - + def expects_mkdir(path = resource.value(:path)) Dir.expects(:mkdir).with(path).at_least_once end diff --git a/spec/support/fixture_helpers.rb b/spec/support/fixture_helpers.rb index 7b7b20a..205715c 100644 --- a/spec/support/fixture_helpers.rb +++ b/spec/support/fixture_helpers.rb @@ -3,5 +3,4 @@ module FixtureHelpers def fixture(name, ext = '.txt') File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', name.to_s + ext)) end - end diff --git a/spec/support/provider_example_group.rb b/spec/support/provider_example_group.rb index 2a8865f..1431f78 100644 --- a/spec/support/provider_example_group.rb +++ b/spec/support/provider_example_group.rb @@ -14,7 +14,7 @@ class ProviderExampleGroup < Spec::Example::ExampleGroup # Build the provider subject { described_class.new(@resource) } - + # Allow access to it via +provider+ alias :provider :subject @@ -47,14 +47,14 @@ class ProviderExampleGroup < Spec::Example::ExampleGroup context("and with a #{text}", {:resource => placeholders}, &block) end end - + def self.build_value_context(params = {}, &block) #:nodoc: unless params.empty? text = params.map { |k, v| "#{k} => #{v.inspect}" }.join(' and with ') context("and with #{text}", {:resource => params}, &block) end end - + # Generate a context for a provider operating on a resource without # a given parameter/property. diff --git a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb index f073b8e..6c66ef4 100644 --- a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb @@ -78,7 +78,7 @@ describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do end end end - + describe "setting the revision property" do it "should use 'bzr update -r' with the revision" do revision = 'somerev' diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index cc195eb..9bae8ae 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -11,24 +11,24 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.') provider.create - end + end end - + resource_without :revision do it "should just execute 'cvs checkout' without a revision" do provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) provider.create - end + end end - + context "with a compression", :resource => {:compression => '3'} do it "should just execute 'cvs checkout' without a revision" do provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) provider.create - end + end end end - + context "when a source is not given" do it "should execute 'cvs init'" do provider.expects(:cvs).with('-d', resource.value(:path), 'init') @@ -51,7 +51,7 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do provider.exists? end end - + resource_without :source do it "should check for the CVSROOT directory" do File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT')) @@ -64,7 +64,7 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do before do @tag_file = File.join(resource.value(:path), 'CVS', 'Tag') end - + context "when CVS/Tag exists" do before do @tag = 'HEAD' @@ -75,22 +75,22 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do provider.revision.should == @tag end end - + context "when CVS/Tag does not exist" do before do File.expects(:exist?).with(@tag_file).returns(false) end it "assumes MAIN" do - provider.revision.should == 'MAIN' + provider.revision.should == 'MAIN' end end end - + describe "when setting the revision property" do before do @tag = 'SOMETAG' end - + it "should use 'cvs update -r'" do expects_chdir provider.expects('cvs').with('update', '-r', @tag, '.') diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb index 6f32d44..e1287cf 100644 --- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb @@ -11,17 +11,17 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do resource.value(:source), resource.value(:path)) provider.create - end + end end - + resource_without :revision do it "should just execute 'hg clone' without a revision" do provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path)) provider.create - end + end end end - + context "when a source is not given" do it "should execute 'hg init'" do provider.expects(:hg).with('init', resource.value(:path)) @@ -48,37 +48,37 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do before do expects_chdir end - + context "when given a non-SHA as the resource revision" do before do provider.expects(:hg).with('parents').returns(fixture(:hg_parents)) provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) end - + context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do it "should return the ref" do provider.revision.should == '0.6' end end - + context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do it "should return the current SHA" do provider.revision.should == '34e6012c783a' - end + end end end context "when given a SHA as the resource revision" do before do provider.expects(:hg).with('parents').returns(fixture(:hg_parents)) end - + context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do it "should return it" do provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) provider.revision.should == resource.value(:revision) end end - + context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do it "should return the current SHA" do provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) @@ -87,7 +87,7 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do end end end - + describe "setting the revision property" do before do @revision = '6aa99e9b3ab1' diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index db4a4c7..5587d4c 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -11,7 +11,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do resource.value(:source), resource.value(:path)) provider.create - end + end end resource_without :revision do it "should just execute 'svn checkout' without a revision" do @@ -19,7 +19,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do resource.value(:source), resource.value(:path)) provider.create - end + end end end resource_without :source do @@ -63,7 +63,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do provider.revision.should == '4' end end - + describe "setting the revision property" do before do @revision = '30' |