summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
diff options
context:
space:
mode:
authorAshley Penney <ashley.penney@puppetlabs.com>2013-09-18 15:59:44 -0400
committerAshley Penney <ashley.penney@puppetlabs.com>2013-09-18 15:59:44 -0400
commitaeb3ea63ec561440c02f9d4c4d4c0ac3a1d096c9 (patch)
treeddead96743afd1c05c6afa857a665c40d07bb0bd /spec/unit/puppet/provider/vcsrepo/hg_spec.rb
parent0eeb6501b1b2ea84c38b0d4464ac42c12c4e9fa7 (diff)
Overhaul the spec tests to work in rspec2.
This work gets rid of the provider_example_group and reworks everything to work properly against rspec2. I don't know if I'd consider the style "better" but it works.
Diffstat (limited to 'spec/unit/puppet/provider/vcsrepo/hg_spec.rb')
-rw-r--r--spec/unit/puppet/provider/vcsrepo/hg_spec.rb52
1 files changed, 35 insertions, 17 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
index f17aa2f..7fd5348 100644
--- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
@@ -1,24 +1,38 @@
require 'spec_helper'
-describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
+describe Puppet::Type.type(:vcsrepo).provider(:hg) do
+
+ let(:resource) { Puppet::Type.type(:vcsrepo).new({
+ :name => 'test',
+ :ensure => :present,
+ :provider => :hg,
+ :path => '/tmp/vcsrepo',
+ })}
+
+ let(:provider) { resource.provider }
+
+ before :each do
+ Puppet::Util.stubs(:which).with('hg').returns('/usr/bin/hg')
+ end
describe 'creating' do
- resource_with :source do
- resource_with :revision do
- it "should execute 'hg clone -u' with the revision" do
- provider.expects(:hg).with('clone', '-u',
- resource.value(:revision),
- resource.value(:source),
- resource.value(:path))
- provider.create
- end
+ context 'with source and revision' do
+ it "should execute 'hg clone -u' with the revision" do
+ resource[:source] = 'something'
+ resource[:revision] = '1'
+ provider.expects(:hg).with('clone', '-u',
+ resource.value(:revision),
+ resource.value(:source),
+ resource.value(:path))
+ provider.create
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
+ context 'without revision' do
+ it "should just execute 'hg clone' without a revision" do
+ resource[:source] = 'something'
+ provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
+ provider.create
end
end
@@ -55,14 +69,16 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
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
+ context "when its SHA is not different than the current SHA" do
it "should return the ref" do
+ resource[:revision] = '0.6'
provider.revision.should == '0.6'
end
end
- context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
+ context "when its SHA is different than the current SHA" do
it "should return the current SHA" do
+ resource[:revision] = '0.5.3'
provider.revision.should == '34e6012c783a'
end
end
@@ -74,6 +90,7 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
it "should return it" do
+ resource[:revision] = '34e6012c783a'
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == resource.value(:revision)
end
@@ -81,6 +98,7 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
it "should return the current SHA" do
+ resource[:revision] = 'not-the-same'
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == '34e6012c783a'
end