summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/provider/vcsrepo/dummy.rb2
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb11
-rw-r--r--lib/puppet/provider/vcsrepo/p4.rb86
-rw-r--r--spec/acceptance/clone_repo_spec.rb49
-rw-r--r--spec/acceptance/create_repo_spec.rb8
-rw-r--r--spec/acceptance/remove_repo_spec.rb2
-rw-r--r--spec/acceptance/remove_repo_spec_noop.rb2
-rw-r--r--spec/spec_helper.rb9
-rw-r--r--spec/spec_helper_acceptance.rb28
-rw-r--r--spec/unit/puppet/provider/vcsrepo/bzr_spec.rb8
-rw-r--r--spec/unit/puppet/provider/vcsrepo/cvs_spec.rb4
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb24
-rw-r--r--spec/unit/puppet/provider/vcsrepo/hg_spec.rb8
-rw-r--r--spec/unit/puppet/provider/vcsrepo/p4_spec.rb10
-rw-r--r--spec/unit/puppet/provider/vcsrepo/svn_spec.rb2
15 files changed, 143 insertions, 110 deletions
diff --git a/lib/puppet/provider/vcsrepo/dummy.rb b/lib/puppet/provider/vcsrepo/dummy.rb
index f7b4e54..27bfbbe 100644
--- a/lib/puppet/provider/vcsrepo/dummy.rb
+++ b/lib/puppet/provider/vcsrepo/dummy.rb
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:dummy, :parent => Puppet::Provider::Vcsrepo) do
desc "Dummy default provider"
- defaultfor :vcsrepo => :dummy
+ defaultfor :feature => :posix
def working_copy_exists?
providers = @resource.class.providers.map{|x| x.to_s}.sort.reject{|x| x == "dummy"}.join(", ") rescue "none"
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 9e0306b..1c6588c 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -279,7 +279,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
# @!visibility private
def set_excludes
- at_path { open('.git/info/exclude', 'w') { |f| @resource.value(:excludes).each { |ex| f.write(ex + "\n") }}}
+ # Excludes may be an Array or a String.
+ at_path do
+ open('.git/info/exclude', 'w') do |f|
+ if @resource.value(:excludes).respond_to?(:each)
+ @resource.value(:excludes).each { |ex| f.puts ex }
+ else
+ f.puts @resource.value(:excludes)
+ end
+ end
+ end
end
# Finds the latest revision or sha of the current branch if on a branch, or
diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb
index 63d3df2..b429bcb 100644
--- a/lib/puppet/provider/vcsrepo/p4.rb
+++ b/lib/puppet/provider/vcsrepo/p4.rb
@@ -4,11 +4,11 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
desc "Supports Perforce depots"
has_features :filesystem_types, :reference_tracking, :p4config
-
+
def create
- # create or update client
+ # create or update client
create_client(client_name)
-
+
# if source provided, sync client
source = @resource.value(:source)
if source
@@ -22,12 +22,12 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
def working_copy_exists?
# Check if the server is there, or raise error
p4(['info'], {:marshal => false})
-
+
# Check if workspace is setup
args = ['where']
args.push(@resource.value(:path) + "...")
hash = p4(args, {:raise => false})
-
+
return (hash['code'] != "error")
end
@@ -49,14 +49,14 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
(rev >= self.latest)
else
true
- end
+ end
end
def latest
args = ['changes']
args.push('-m1', @resource.value(:source))
hash = p4(args)
-
+
return hash['change'].to_i
end
@@ -65,7 +65,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
args.push(@resource.value(:source))
hash = p4(args, {:marshal => false})
hash = marshal_cstat(hash)
-
+
revision = 0
if hash && hash['code'] != 'error'
hash['data'].each do |c|
@@ -90,7 +90,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
set_ownership
end
end
-
+
# Sync the client workspace files to head or specified revision.
# Params:
# +source+:: Depot path to sync
@@ -105,16 +105,16 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
end
p4(args)
end
-
- # Returns the name of the Perforce client workspace
+
+ # Returns the name of the Perforce client workspace
def client_name
p4config = @resource.value(:p4config)
-
+
# default (generated) client name
path = @resource.value(:path)
host = Facter.value('hostname')
default = "puppet-" + Digest::MD5.hexdigest(path + host)
-
+
# check config for client name
set_client = nil
if p4config && File.file?(p4config)
@@ -124,10 +124,10 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
set_client = p.match(m)[1] if m
end
end
-
+
return set_client || ENV['P4CLIENT'] || default
end
-
+
# Create (or update) a client workspace spec.
# If a client name is not provided then a hash based on the path is used.
# Params:
@@ -135,13 +135,13 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
# +path+:: The Root location of the Perforce client workspace
def create_client(client)
Puppet.debug "Creating client: #{client}"
-
+
# fetch client spec
hash = parse_client(client)
hash['Root'] = @resource.value(:path)
hash['Description'] = "Generated by Puppet VCSrepo"
-
- # check is source is a Stream
+
+ # check is source is a Stream
source = @resource.value(:source)
if source
parts = source.split(/\//)
@@ -154,7 +154,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
end
end
end
-
+
# save client spec
save_client(hash)
end
@@ -170,15 +170,15 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
return hash
end
-
-
- # Saves the client workspace spec from the given hash
+
+
+ # Saves the client workspace spec from the given hash
# Params:
# +hash+:: hash map of client spec
def save_client(hash)
spec = String.new
view = "\nView:\n"
-
+
hash.keys.sort.each do |k|
v = hash[k]
next if( k == "code" )
@@ -187,40 +187,40 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
else
spec += "#{k.to_s}: #{v.to_s}\n"
end
- end
+ end
spec += view
-
+
args = ['client']
args.push('-i')
p4(args, {:input => spec, :marshal => false})
- end
-
+ end
+
# Sets Perforce Configuration environment.
# P4CLIENT generated, but overwitten if defined in config.
def config
p4config = @resource.value(:p4config)
-
+
cfg = Hash.new
cfg.store 'P4CONFIG', p4config if p4config
cfg.store 'P4CLIENT', client_name
- return cfg
+ return cfg
end
-
+
def p4(args, options = {})
# Merge custom options with defaults
- opts = {
+ opts = {
:raise => true, # Raise errors
:marshal => true, # Marshal output
}.merge(options)
-
+
cmd = ['p4']
cmd.push '-R' if opts[:marshal]
cmd.push args
cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd
-
+
Puppet.debug "environment: #{config}"
Puppet.debug "command: #{cmd_str}"
-
+
hash = Hash.new
Open3.popen3(config, cmd_str) do |i, o, e, t|
# Send input stream if provided
@@ -229,13 +229,13 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
i.write opts[:input]
i.close
end
-
+
if(opts[:marshal])
hash = Marshal.load(o)
else
- hash['data'] = o.read
+ hash['data'] = o.read
end
-
+
# Raise errors, Perforce or Exec
if(opts[:raise] && !e.eof && t.value != 0)
raise Puppet::Error, "\nP4: #{e.read}"
@@ -244,22 +244,22 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
raise Puppet::Error, "\nP4: #{hash['data']}"
end
end
-
+
Puppet.debug "hash: #{hash}\n"
return hash
end
-
+
# helper method as cstat does not Marshal
def marshal_cstat(hash)
data = hash['data']
code = 'error'
-
+
list = Array.new
change = Hash.new
data.each_line do |l|
p = /^\.\.\. (.*) (.*)$/
m = p.match(l)
- if m
+ if m
change[m[1]] = m[2]
if m[1] == 'status'
code = 'stat'
@@ -268,11 +268,11 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d
end
end
end
-
+
hash = Hash.new
hash.store 'code', code
hash.store 'data', list
return hash
end
-
+
end
diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb
index c52a5d2..f3e77db 100644
--- a/spec/acceptance/clone_repo_spec.rb
+++ b/spec/acceptance/clone_repo_spec.rb
@@ -30,11 +30,11 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
describe file("#{tmpdir}/testrepo/.git/HEAD") do
- it { should contain 'ref: refs/heads/master' }
+ it { is_expected.to contain 'ref: refs/heads/master' }
end
end
@@ -63,11 +63,11 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_sha/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do
- it { should contain sha }
+ it { is_expected.to contain sha }
end
end
@@ -88,7 +88,7 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_tag/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
it 'should have the tag as the HEAD' do
@@ -113,11 +113,11 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_branch/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do
- it { should contain 'ref: refs/heads/a_branch' }
+ it { is_expected.to contain 'ref: refs/heads/a_branch' }
end
end
@@ -183,7 +183,7 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do
- it { should be_file }
+ it { is_expected.to be_file }
end
end
@@ -229,8 +229,8 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_owner") do
- it { should be_directory }
- it { should be_owned_by 'vagrant' }
+ it { is_expected.to be_directory }
+ it { is_expected.to be_owned_by 'vagrant' }
end
end
@@ -259,8 +259,8 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_group") do
- it { should be_directory }
- it { should be_grouped_into 'vagrant' }
+ it { is_expected.to be_directory }
+ it { is_expected.to be_grouped_into 'vagrant' }
end
end
@@ -281,8 +281,15 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do
- its(:content) { should match /exclude1.txt/ }
- its(:content) { should match /exclude2.txt/ }
+ describe '#content' do
+ subject { super().content }
+ it { is_expected.to match /exclude1.txt/ }
+ end
+
+ describe '#content' do
+ subject { super().content }
+ it { is_expected.to match /exclude2.txt/ }
+ end
end
end
@@ -308,15 +315,15 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_force/folder") do
- it { should_not be_directory }
+ it { is_expected.not_to be_directory }
end
describe file("#{tmpdir}/testrepo_force/temp.txt") do
- it { should_not be_file }
+ it { is_expected.not_to be_file }
end
describe file("#{tmpdir}/testrepo_force/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
context 'and noop' do
@@ -382,13 +389,13 @@ describe 'clones a remote repo' do
end
describe file("#{tmpdir}/testrepo_user") do
- it { should be_directory }
- it { should be_owned_by 'testuser' }
+ it { is_expected.to be_directory }
+ it { is_expected.to be_owned_by 'testuser' }
end
describe file("#{tmpdir}/testrepo_user") do
- it { should be_directory }
- it { should be_grouped_into 'testuser' }
+ it { is_expected.to be_directory }
+ it { is_expected.to be_grouped_into 'testuser' }
end
end
diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb
index 1b46449..db0cd29 100644
--- a/spec/acceptance/create_repo_spec.rb
+++ b/spec/acceptance/create_repo_spec.rb
@@ -26,7 +26,7 @@ describe 'create a repo' do
end
describe file("#{tmpdir}/testrepo_blank_repo/.git") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
end
@@ -45,11 +45,11 @@ describe 'create a repo' do
end
describe file("#{tmpdir}/testrepo_bare_repo/config") do
- it { should contain 'bare = true' }
+ it { is_expected.to contain 'bare = true' }
end
describe file("#{tmpdir}/testrepo_bare_repo/.git") do
- it { should_not be_directory }
+ it { is_expected.not_to be_directory }
end
end
@@ -67,7 +67,7 @@ describe 'create a repo' do
end
describe file("#{tmpdir}/testrepo_bare_repo_rev") do
- it { should_not be_directory }
+ it { is_expected.not_to be_directory }
end
end
end
diff --git a/spec/acceptance/remove_repo_spec.rb b/spec/acceptance/remove_repo_spec.rb
index d22d9db..d5646b3 100644
--- a/spec/acceptance/remove_repo_spec.rb
+++ b/spec/acceptance/remove_repo_spec.rb
@@ -25,6 +25,6 @@ describe 'remove a repo' do
end
describe file("#{tmpdir}/testrepo_deleted") do
- it { should_not be_directory }
+ it { is_expected.not_to be_directory }
end
end
diff --git a/spec/acceptance/remove_repo_spec_noop.rb b/spec/acceptance/remove_repo_spec_noop.rb
index 154f25a..f6bd86e 100644
--- a/spec/acceptance/remove_repo_spec_noop.rb
+++ b/spec/acceptance/remove_repo_spec_noop.rb
@@ -26,6 +26,6 @@ describe 'does not remove a repo if noop' do
end
describe file("#{tmpdir}/testrepo_noop_deleted") do
- it { should be_directory }
+ it { is_expected.to be_directory }
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index acfae0c..ccd305b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,10 +1,13 @@
require 'puppetlabs_spec_helper/module_spec_helper'
-require 'simplecov'
require 'support/filesystem_helpers'
require 'support/fixture_helpers'
-SimpleCov.start do
- add_filter "/spec/"
+# SimpleCov does not run on Ruby 1.8.7
+unless RUBY_VERSION.to_f < 1.9
+ require 'simplecov'
+ SimpleCov.start do
+ add_filter '/spec/'
+ end
end
RSpec.configure do |c|
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index d37c169..9ef826a 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -1,12 +1,14 @@
require 'beaker-rspec'
unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
+ # This will install the latest available package on el and deb based
+ # systems fail on windows and osx, and install via gem on other *nixes
+ foss_opts = { :default_action => 'gem_install' }
+
+ if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
+
hosts.each do |host|
- # Install Puppet
- if host.is_pe?
- install_pe
- else
- install_puppet
+ unless host.is_pe?
on hosts, "mkdir -p #{hosts.first['distmoduledir']}"
end
@@ -18,6 +20,7 @@ unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
end
end
+
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
@@ -27,16 +30,27 @@ RSpec.configure do |c|
# Configure all nodes in nodeset
c.before :suite do
- # Install module and dependencies on all hosts
- puppet_module_install(:source => proj_root, :module_name => 'vcsrepo')
# ensure test dependencies are available on all hosts
hosts.each do |host|
+ copy_module_to(host, :source => proj_root, :module_name => 'vcsrepo')
case fact_on(host, 'osfamily')
when 'RedHat'
+ if fact_on(host, 'operatingsystemmajrelease') == '5'
+ will_install_git = on(host, 'which git', :acceptable_exit_codes => [0,1]).exit_code == 1
+
+ if will_install_git
+ on host, puppet('module install stahnma-epel')
+ apply_manifest_on( host, 'include epel' )
+ end
+
+ end
+
install_package(host, 'git')
+
when 'Debian'
install_package(host, 'git-core')
+
else
if !check_for_package(host, 'git')
puts "Git package is required for this module"
diff --git a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb
index 488ddc0..b5e2f73 100644
--- a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb
@@ -67,14 +67,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:bzr_provider) do
it "should return the ref" do
resource[:revision] = '2634'
provider.expects(:bzr).with('revision-info', '2634').returns("2634 menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n")
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
context "when its revid is different than the current revid" do
it "should return the current revid" do
resource[:revision] = '2636'
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n")
- provider.revision.should == @current_revid
+ expect(provider.revision).to eq(@current_revid)
end
end
end
@@ -84,14 +84,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:bzr_provider) do
it "should return it" do
resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n")
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
context "when it is not the same as the current revid" do
it "should return the current revid" do
resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n")
- provider.revision.should == @current_revid
+ expect(provider.revision).to eq(@current_revid)
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
index efa4b33..f5eebd9 100644
--- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
@@ -86,7 +86,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do
end
it "should read CVS/Tag" do
File.expects(:read).with(@tag_file).returns("T#{@tag}")
- provider.revision.should == @tag
+ expect(provider.revision).to eq(@tag)
end
end
@@ -95,7 +95,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do
File.expects(:exist?).with(@tag_file).returns(false)
end
it "assumes HEAD" do
- provider.revision.should == 'HEAD'
+ expect(provider.revision).to eq('HEAD')
end
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index 3f81cc8..122eb62 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -134,7 +134,7 @@ branches
it "should raise an exception" do
provider.expects(:path_exists?).returns(true)
provider.expects(:path_empty?).returns(false)
- proc { provider.create }.should raise_error(Puppet::Error)
+ expect { provider.create }.to raise_error(Puppet::Error)
end
end
end
@@ -204,7 +204,7 @@ branches
provider.expects(:path_exists?).returns(true)
provider.expects(:path_empty?).returns(false)
provider.expects(:working_copy_exists?).returns(false)
- proc { provider.create }.should raise_error(Puppet::Error)
+ expect { provider.create }.to raise_error(Puppet::Error)
end
end
end
@@ -233,14 +233,14 @@ branches
context "when its SHA is not different than the current SHA" do
it "should return the ref" do
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
context "when its SHA is different than the current SHA" do
it "should return the current SHA" do
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha')
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
@@ -248,7 +248,7 @@ branches
it "should return the revision" do
provider.stubs(:git).with('branch', '-a').returns(" remotes/origin/#{resource.value(:revision)}")
provider.expects(:git).with('rev-parse', "origin/#{resource.value(:revision)}").returns("newsha")
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
@@ -267,7 +267,7 @@ branches
provider.expects(:git).with('config', 'remote.origin.url').returns('old')
provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
end
@@ -329,13 +329,13 @@ branches
context "when it's listed in 'git branch -a'" do
it "should return true" do
resource[:revision] = 'feature/foo'
- provider.should be_local_branch_revision
+ expect(provider).to be_local_branch_revision
end
end
context "when it's not listed in 'git branch -a'" do
it "should return false" do
resource[:revision] = 'feature/notexist'
- provider.should_not be_local_branch_revision
+ expect(provider).not_to be_local_branch_revision
end
end
end
@@ -343,13 +343,13 @@ branches
context "when it's listed in 'git branch -a' with an 'origin/' prefix" do
it "should return true" do
resource[:revision] = 'only/remote'
- provider.should be_remote_branch_revision
+ expect(provider).to be_remote_branch_revision
end
end
context "when it's not listed in 'git branch -a' with an 'origin/' prefix" do
it "should return false" do
resource[:revision] = 'only/local'
- provider.should_not be_remote_branch_revision
+ expect(provider).not_to be_remote_branch_revision
end
end
end
@@ -360,14 +360,14 @@ branches
it do
provider.expects(:revision).returns('testrev')
provider.expects(:latest_revision).returns('testrev')
- provider.latest?.should be_true
+ expect(provider.latest?).to be_truthy
end
end
context 'when false' do
it do
provider.expects(:revision).returns('master')
provider.expects(:latest_revision).returns('testrev')
- provider.latest?.should be_false
+ expect(provider.latest?).to be_falsey
end
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
index 6b21c1c..65d820d 100644
--- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb
@@ -88,14 +88,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) 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'
+ expect(provider.revision).to eq('0.6')
end
end
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'
+ expect(provider.revision).to eq('34e6012c783a')
end
end
end
@@ -108,7 +108,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) do
it "should return it" do
resource[:revision] = '34e6012c783a'
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
- provider.revision.should == resource.value(:revision)
+ expect(provider.revision).to eq(resource.value(:revision))
end
end
@@ -116,7 +116,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) 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'
+ expect(provider.revision).to eq('34e6012c783a')
end
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb
index abbd9ec..e331cae 100644
--- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb
@@ -26,7 +26,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do
resource[:source] = 'something'
resource[:revision] = '1'
ENV['P4CLIENT'] = 'client_ws1'
-
+
provider.expects(:p4).with(['client', '-o', 'client_ws1']).returns({})
provider.expects(:p4).with(['client', '-i'], spec)
provider.expects(:p4).with(['sync', resource.value(:source) + "@" + resource.value(:revision)])
@@ -38,7 +38,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do
it "should just execute 'p4 sync' without a revision" do
resource[:source] = 'something'
ENV['P4CLIENT'] = 'client_ws2'
-
+
provider.expects(:p4).with(['client', '-o', 'client_ws2']).returns({})
provider.expects(:p4).with(['client', '-i'], spec)
provider.expects(:p4).with(['sync', resource.value(:source)])
@@ -49,11 +49,11 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do
context "when a client and source are not given" do
it "should execute 'p4 client'" do
ENV['P4CLIENT'] = nil
-
+
path = resource.value(:path)
host = Facter.value('hostname')
default = "puppet-" + Digest::MD5.hexdigest(path + host)
-
+
provider.expects(:p4).with(['client', '-o', default]).returns({})
provider.expects(:p4).with(['client', '-i'], spec)
provider.create
@@ -64,7 +64,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do
describe 'destroying' do
it "it should remove the directory" do
ENV['P4CLIENT'] = 'test_client'
-
+
provider.expects(:p4).with(['client', '-d', '-f', 'test_client'])
expects_rm_rf
provider.destroy
diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
index f44e314..494da52 100644
--- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
@@ -75,7 +75,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do
end
it "should use 'svn info'" do
expects_chdir
- provider.revision.should == '4' # From 'Revision', not 'Last Changed Rev'
+ expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev'
end
end