From 1ebe52ef9963391f13b406c843c8f475668f173c Mon Sep 17 00:00:00 2001 From: Phil Pham Date: Fri, 14 Feb 2014 11:16:15 -0800 Subject: add beaker-rspec support This adds support for beaker-rspec as well as basic test coverage for git --- spec/acceptance/create_repo_spec.rb | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 spec/acceptance/create_repo_spec.rb (limited to 'spec/acceptance/create_repo_spec.rb') diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb new file mode 100644 index 0000000..675517e --- /dev/null +++ b/spec/acceptance/create_repo_spec.rb @@ -0,0 +1,77 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'create a repo' do + context 'without a source' do + it 'creates a blank repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_blank_repo": + ensure => present, + provider => git, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_blank_repo/") do + it 'should have zero files' do + shell("ls -1 #{tmpdir}/testrepo_blank_repo | wc -l") do |r| + expect(r.stdout).to match(/^0\n$/) + end + end + end + + describe file("#{tmpdir}/testrepo_blank_repo/.git") do + it { should be_directory } + end + end + + context 'bare repo' do + it 'creates a bare repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_bare_repo": + ensure => bare, + provider => git, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_bare_repo/config") do + it { should contain 'bare = true' } + end + + describe file("#{tmpdir}/testrepo_bare_repo/.git") do + it { should_not be_directory } + end + end + + context 'bare repo with a revision' do + it 'creates a bare repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev": + ensure => bare, + provider => git, + revision => 'master', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{tmpdir}/testrepo_bare_repo_rev/config") do + it { should contain 'bare = true' } + end + + describe file("#{tmpdir}/testrepo_bare_repo_rev/.git") do + it { should_not be_directory } + end + end +end -- cgit v1.2.3 From d11fb1c90a115e7dd27cf32ad0bfdb65700c5eab Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 22 May 2014 08:07:57 -0700 Subject: Set git bare with revision test to fail When the revision attribute is defined in conjunction with the bare attribute when using the git provider, the repo should fail to be written to disk. See: FM-1361 --- spec/acceptance/create_repo_spec.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'spec/acceptance/create_repo_spec.rb') diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index 675517e..1b46449 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -54,7 +54,7 @@ describe 'create a repo' do end context 'bare repo with a revision' do - it 'creates a bare repo' do + it 'does not create a bare repo when a revision is defined' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev": ensure => bare, @@ -63,14 +63,10 @@ describe 'create a repo' do } EOS - apply_manifest(pp, :catch_failures => true) - end - - describe file("#{tmpdir}/testrepo_bare_repo_rev/config") do - it { should contain 'bare = true' } + apply_manifest(pp, :expect_failures => true) end - describe file("#{tmpdir}/testrepo_bare_repo_rev/.git") do + describe file("#{tmpdir}/testrepo_bare_repo_rev") do it { should_not be_directory } end end -- cgit v1.2.3 From 1df5570580c1d429a8fed25033a19333fcaffbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 29 Sep 2014 19:19:21 +0200 Subject: Convert specs to RSpec 2.99.2 syntax with Transpec This conversion is done by Transpec 2.3.7 with the following command: transpec * 22 conversions from: it { should ... } to: it { is_expected.to ... } * 19 conversions from: obj.should to: expect(obj).to * 15 conversions from: == expected to: eq(expected) * 5 conversions from: it { should_not ... } to: it { is_expected.not_to ... } * 2 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 2 conversions from: obj.should_not to: expect(obj).not_to * 2 conversions from: proc { }.should to: expect { }.to * 1 conversion from: be_false to: be_falsey * 1 conversion from: be_true to: be_truthy For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/acceptance/create_repo_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/acceptance/create_repo_spec.rb') 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 -- cgit v1.2.3 From 14c05f5d6c589bebc9f93eb117105c14ce7be6f1 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 13 Aug 2015 16:02:22 -0700 Subject: MODULES-2125 - Allow revision to be passed without source Will also work with empty repositories. --- spec/acceptance/create_repo_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec/acceptance/create_repo_spec.rb') diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index db0cd29..53a93c9 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -30,6 +30,22 @@ describe 'create a repo' do end end + context 'no source but revision provided' do + it 'should not fail (MODULES-2125)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_blank_with_revision_repo": + ensure => present, + provider => git, + revision => 'master' + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + end + context 'bare repo' do it 'creates a bare repo' do pp = <<-EOS -- cgit v1.2.3