#
# given(:ensure)
# given(:ensure => :present)
- def context_with(*args, &block)
+ def context_with_resource(*args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
if args.empty?
text = options.map { |k, v| "#{k} => #{v.inspect}" }.join(' and with ')
end
end
- def context_without(field, &block)
+ def context_without_resource(field, &block)
context("and without a #{field}", &block)
end
describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
- context_with :source do
- context_with :revision do
+ context_with_resource :source do
+ context_with_resource :revision do
it "should execute 'bzr clone -r' with the revision" do
provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path))
provider.create
end
end
- context_without :revision do
+ context_without_resource :revision do
it "should just execute 'bzr clone' without a revision" do
provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path))
provider.create
end
end
end
- context_without :source do
+ context_without_resource :source do
it "should execute 'bzr init'" do
provider.expects(:bzr).with('init', resource.value(:path))
provider.create
describe 'creating' do
context "with a source", :resource => {:source => ':ext:source@example.com:/foo/bar'} do
- context_with :revision do
+ context_with_resource :revision do
it "should execute 'cvs checkout' and 'cvs update -r'" do
expects_chdir
expects_chdir(File.dirname(resource.value(:path)))
end
end
- context_without :revision do
+ context_without_resource :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
describe "checking existence" do
- context_with :source do
+ context_with_resource :source do
it "should check for the CVS directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
provider.exists?
end
end
- context_without :source do
+ context_without_resource :source do
it "should check for the CVSROOT directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
provider.exists?
describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context 'creating' do
- context_with :source do
- context_with :ensure => :present do
- context_with :revision do
+ context_with_resource :source do
+ context_with_resource :ensure => :present do
+ context_with_resource :revision do
it "should execute 'git clone' and 'git reset --hard'" do
provider.expects('git').with('clone', resource.value(:source), resource.value(:path))
expects_chdir
end
end
- context_without :revision do
+ context_without_resource :revision do
it "should just execute 'git clone'" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
provider.create
end
end
- context_with :ensure => :bare do
- context_with :revision do
+ context_with_resource :ensure => :bare do
+ context_with_resource :revision do
it "should just execute 'git clone --bare'" do
subject.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
subject.create
end
end
- context_without :revision do
+ context_without_resource :revision do
it "should just execute 'git clone --bare'" do
subject.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
subject.create
end
context "when a source is not given" do
- context_with :ensure => :present do
+ context_with_resource :ensure => :present do
context "when the path does not exist" do
it "should execute 'git init'" do
expects_mkdir
end
end
- context_with :ensure => :bare do
+ context_with_resource :ensure => :bare do
context "when the path does not exist" do
it "should execute 'git init --bare'" do
expects_chdir
end
context "checking the revision property" do
- context_with :revision do
+ context_with_resource :revision do
before do
expects_chdir
provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha')
describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
- context_with :source do
- context_with :revision do
+ context_with_resource :source do
+ context_with_resource :revision do
it "should execute 'hg clone -u' with the revision" do
provider.expects(:hg).with('clone', '-u',
resource.value(:revision),
end
end
- context_without :revision do
+ context_without_resource :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
describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
- context_with :source do
- context_with :revision do
+ context_with_resource :source do
+ context_with_resource :revision do
it "should execute 'svn checkout' with a revision" do
provider.expects(:svn).with('checkout', '-r',
resource.value(:revision),
provider.create
end
end
- context_without :revision do
+ context_without_resource :revision do
it "should just execute 'svn checkout' without a revision" do
provider.expects(:svn).with('checkout',
resource.value(:source),
end
end
end
- context_without :source do
- context_with :fstype do
+ context_without_resource :source do
+ context_with_resource :fstype do
it "should execute 'svnadmin create' with an '--fs-type' option" do
provider.expects(:svnadmin).with('create', '--fs-type',
resource.value(:fstype),
provider.create
end
end
- context_without :fstype do
+ context_without_resource :fstype do
it "should execute 'svnadmin create' without an '--fs-type' option" do
provider.expects(:svnadmin).with('create', resource.value(:path))
provider.create