diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/clone_repo_spec.rb | 49 | ||||
-rw-r--r-- | spec/acceptance/create_repo_spec.rb | 8 | ||||
-rw-r--r-- | spec/acceptance/remove_repo_spec.rb | 2 | ||||
-rw-r--r-- | spec/acceptance/remove_repo_spec_noop.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 9 | ||||
-rw-r--r-- | spec/spec_helper_acceptance.rb | 28 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/bzr_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/git_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 2 |
12 files changed, 89 insertions, 65 deletions
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 |