control_spec_helper 0.0.2 → 0.0.3.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +57 -26
  5. data/Guardfile +1 -0
  6. data/Rakefile +141 -48
  7. data/bin/csh-generate +7 -0
  8. data/config/Guardfile +24 -0
  9. data/control_spec_helper.gemspec +9 -5
  10. data/ext/Rakefile.sample +0 -2
  11. data/ext/spec_helper_control.rb +2 -1
  12. data/lib/control_spec_helper/control_spec_helper.rb +22 -21
  13. data/lib/control_spec_helper/debug.rb +7 -0
  14. data/lib/control_spec_helper/generate.rb +79 -0
  15. data/lib/control_spec_helper/rake_tasks.rb +0 -1
  16. data/lib/{slalom.rb → control_spec_helper/util.rb} +22 -7
  17. data/lib/control_spec_helper/version.rb +1 -1
  18. data/lib/control_spec_helper.rb +2 -0
  19. data/lib/tasks/apply.rake +1 -1
  20. data/lib/tasks/lint.rake +2 -1
  21. data/lib/tasks/r10k.rake +1 -1
  22. data/lib/tasks/spec_prep.rake +0 -1
  23. data/lib/tasks/unit.rake +15 -0
  24. data/spec/spec_helper.rb +2 -2
  25. data/spec/support/shared_contexts/rake.rb +1 -1
  26. data/spec/tasks/apply_debug_spec.rb +72 -0
  27. data/spec/tasks/apply_spec.rb +72 -0
  28. data/spec/tasks/apply_standalone_spec.rb +73 -0
  29. data/spec/tasks/help_spec.rb +54 -0
  30. data/spec/tasks/lint_spec.rb +69 -0
  31. data/spec/tasks/puppet_cmd_spec.rb +55 -0
  32. data/spec/tasks/r10k_spec.rb +69 -0
  33. data/spec/tasks/spec_clean_spec.rb +61 -0
  34. data/spec/tasks/spec_prep_spec.rb +69 -0
  35. data/spec/tasks/unit_spec.rb +70 -0
  36. data/spec/tasks/vplugins_spec.rb +18 -25
  37. data/spec/unit/control_spec_helper_spec.rb +3 -3
  38. data/spec/unit/debug_spec.rb +2 -2
  39. data/spec/unit/profile_fixtures_spec.rb +111 -125
  40. data/spec/unit/r10k_spec.rb +7 -0
  41. metadata +106 -48
  42. data/lib/tasks/git.rake +0 -9
@@ -1,2 +1 @@
1
- require 'puppet-lint/tasks/puppet-lint'
2
1
  Dir.glob("#{File.dirname(__FILE__)}/../tasks/**/*.rake").each { |f| import f }
@@ -1,15 +1,29 @@
1
1
  require 'net/ssh'
2
2
  require 'etc'
3
3
 
4
+ def debug(msg)
5
+ $stderr.puts "DEBUG: #{msg}" unless ENV['debug'].nil?
6
+ end
7
+
4
8
  def vagrant_ssh_config
5
- config = {}
6
- `unset RUBYLIB ; vagrant ssh-config --machine-readable`.split(',')[7]
7
- .split('\n')[0..9].collect(&:lstrip)
8
- .each do |element|
9
- key, value = element.split(' ')
10
- config[key] = value
9
+ out = `unset RUBYLIB ; vagrant ssh-config --machine-readable`
10
+ out.split("\n")[1]
11
+ .split(',').last
12
+ .split('\n')
13
+ .map(&:strip)
14
+ .reduce({}) do |a, e|
15
+ key, value = e.split
16
+ a.merge(key => value)
11
17
  end
12
- config
18
+ end
19
+
20
+ def build_vagrant_connection(config)
21
+ Net::SSH.start(
22
+ config['HostName'],
23
+ config['User'],
24
+ port: config['Port'],
25
+ password: 'vagrant'
26
+ )
13
27
  end
14
28
 
15
29
  # Helper method to separate ssh output into streams and error code
@@ -58,3 +72,4 @@ def ssh_exec!(ssh, command)
58
72
  end
59
73
  # rubocop:enable Metrics/MethodLength
60
74
  # rubocop:enable Metrics/AbcSize
75
+
@@ -1,5 +1,5 @@
1
1
  module ControlSpecHelper
2
2
  module Version
3
- STRING = '0.0.2'.freeze
3
+ STRING = '0.0.3.pre'.freeze
4
4
  end
5
5
  end
@@ -1 +1,3 @@
1
+ require 'control_spec_helper/util'
2
+ require 'control_spec_helper/debug'
1
3
  require 'control_spec_helper/control_spec_helper'
data/lib/tasks/apply.rake CHANGED
@@ -1,7 +1,7 @@
1
1
  # lib/tasks/apply.rb
2
2
 
3
3
  desc 'run puppet apply (enforce mode)'
4
- task apply: [:git, :r10k] do
4
+ task apply: [:r10k] do
5
5
  puts "Running 'puppet apply'"
6
6
  exec puppet_cmd
7
7
  end
data/lib/tasks/lint.rake CHANGED
@@ -5,7 +5,7 @@
5
5
  # we require to import for the PuppetLint::RakeTask
6
6
  require 'puppet-lint/tasks/puppet-lint'
7
7
 
8
- Rake::Task[:lint].clear
8
+ Rake::Task[:lint].clear if Rake::Task.task_defined? :lint
9
9
  # Relative is not able to be set within the context of PuppetLint::RakeTask
10
10
  PuppetLint.configuration.relative = true
11
11
  PuppetLint::RakeTask.new(:lint) do |config|
@@ -22,5 +22,6 @@ PuppetLint::RakeTask.new(:lint) do |config|
22
22
  examples/**/*.pp
23
23
  spec/**/*.pp
24
24
  pkg/**/*.pp
25
+ modules/**/**/*.pp
25
26
  )
26
27
  end
data/lib/tasks/r10k.rake CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  desc 'install all modules from the Puppetfile (idempotent)'
4
4
  task :r10k do
5
- r10k
5
+ abort if r10k != 0
6
6
  end
@@ -5,6 +5,5 @@ include ControlSpecHelper
5
5
  desc 'prep for spec tests'
6
6
  task :spec_prep do
7
7
  r10k
8
- puts "====== #{project_root}"
9
8
  profile_fixtures
10
9
  end
@@ -0,0 +1,15 @@
1
+ # lib/tasks/spec.rb
2
+
3
+ desc 'run profile unit tests'
4
+ task :unit do
5
+ success = false
6
+ Rake::Task['spec_prep'].invoke
7
+ Dir.chdir(profile_path) do
8
+ rspec = 'bundle exec rspec'
9
+ spec_pattern = 'spec/**/*_spec.rb'
10
+ exclude = 'spec/{fixtures,acceptance}/*_spec.rb'
11
+ success = system "#{rspec} -P \"#{spec_pattern}\" --exclude-pattern \"#{exclude}\""
12
+ end
13
+ Rake::Task['spec_clean'].invoke
14
+ abort unless success
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,9 +4,9 @@ require 'control_spec_helper'
4
4
  require 'rspec/core/rake_task'
5
5
  require 'puppet-lint/tasks/puppet-lint'
6
6
  require 'puppet-syntax/tasks/puppet-syntax'
7
+ require 'fakefs/spec_helpers'
8
+ require 'git'
7
9
 
8
- # Dir.glob("#{File.dirname(__FILE__)}/../lib/tasks/**/*.rake")
9
- # .each { |f| require f }
10
10
  Dir.glob("#{File.dirname(__FILE__)}/support/shared_contexts/**/*.rb")
11
11
  .each { |f| require f }
12
12
 
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'English'
3
- require './lib/slalom'
3
+ require 'control_spec_helper/util'
4
4
 
5
5
  shared_context 'rake' do
6
6
  Dir.chdir('fixtures/puppet-control') do
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe :apply_debug do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ end
34
+
35
+ after(:each) do
36
+ $stderr = original_stderr
37
+ $stdout = original_stdout
38
+ end
39
+
40
+ context 'it should run puppet apply in debug mode' do
41
+ before(:each) do
42
+ @puppet_return = ssh_exec!(@connection,
43
+ 'cd /vagrant ; bundle exec rake apply_debug')
44
+ end
45
+ it 'should return successfully' do
46
+ expect(@puppet_return[2]).to eq(0)
47
+ end
48
+ it 'should apply a catalog' do
49
+ expect(@puppet_return[0]).to match(/Notice: Applied catalog/)
50
+ end
51
+ it 'should include debugging information' do
52
+ expect(@puppet_return[0]).to match(/Debug: Runtime environment/)
53
+ end
54
+ it 'should activate the ntp service' do
55
+ @ntp_return = ssh_exec!(@connection,
56
+ 'systemctl status ntpd')
57
+ expect(@ntp_return[2]).to eq(0)
58
+ end
59
+ context 'the newly deployed ntp.conf' do
60
+ before(:each) do
61
+ @conf_content = ssh_exec!(@connection, 'cat /etc/ntp.conf')
62
+ end
63
+ it 'should contain the correct ntp servers' do
64
+ expect(@conf_content[0]).to match(/server 0.pool.ntp.org/)
65
+ end
66
+ it 'should not contain additional ntp servers' do
67
+ expect(@conf_content[0]).to_not match(/server 1.pool.ntp.org/)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe :apply do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ end
34
+
35
+ after(:each) do
36
+ $stderr = original_stderr
37
+ $stdout = original_stdout
38
+ end
39
+
40
+ context 'it should run puppet apply' do
41
+ before(:each) do
42
+ @puppet_return = ssh_exec!(@connection,
43
+ 'cd /vagrant ; bundle exec rake apply')
44
+ end
45
+ it 'should return successfully' do
46
+ expect(@puppet_return[2]).to eq(0)
47
+ end
48
+ it 'should run r10k' do
49
+ expect(@puppet_return[0]).to match(/Installing modules with r10k/)
50
+ end
51
+ it 'should apply a catalog' do
52
+ expect(@puppet_return[0]).to match(/Notice: Applied catalog/)
53
+ end
54
+ it 'should activate the ntp service' do
55
+ @ntp_return = ssh_exec!(@connection,
56
+ 'systemctl status ntpd')
57
+ expect(@ntp_return[2]).to eq(0)
58
+ end
59
+ context 'the newly deployed ntp.conf' do
60
+ before(:each) do
61
+ @conf_content = ssh_exec!(@connection, 'cat /etc/ntp.conf')
62
+ end
63
+ it 'should contain the correct ntp servers' do
64
+ expect(@conf_content[0]).to match(/server 0.pool.ntp.org/)
65
+ end
66
+ it 'should not contain additional ntp servers' do
67
+ expect(@conf_content[0]).to_not match(/server 1.pool.ntp.org/)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe :apply_standalone do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ end
34
+
35
+ after(:each) do
36
+ $stderr = original_stderr
37
+ $stdout = original_stdout
38
+ end
39
+
40
+ context 'it should run puppet apply' do
41
+ before(:each) do
42
+ @puppet_return = ssh_exec!(@connection,
43
+ 'cd /vagrant ;'\
44
+ 'bundle exec rake apply_standalone')
45
+ end
46
+ it 'should return successfully' do
47
+ expect(@puppet_return[2]).to eq(0)
48
+ end
49
+ it 'should apply a catalog' do
50
+ expect(@puppet_return[0]).to match(/Notice: Applied catalog/)
51
+ end
52
+ it 'should not run r10k' do
53
+ expect(@puppet_return[0]).to_not match(/Installing modules with r10k/)
54
+ end
55
+ it 'should activate the ntp service' do
56
+ @ntp_return = ssh_exec!(@connection,
57
+ 'systemctl status ntpd')
58
+ expect(@ntp_return[2]).to eq(0)
59
+ end
60
+ context 'the newly deployed ntp.conf' do
61
+ before(:each) do
62
+ @conf_content = ssh_exec!(@connection, 'cat /etc/ntp.conf')
63
+ end
64
+ it 'should contain the correct ntp servers' do
65
+ expect(@conf_content[0]).to match(/server 0.pool.ntp.org/)
66
+ end
67
+ it 'should not contain additional ntp servers' do
68
+ expect(@conf_content[0]).to_not match(/server 1.pool.ntp.org/)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe :help do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ @prep_return = ssh_exec!(@connection,
34
+ 'cd /vagrant ;'\
35
+ 'bundle exec rake help')
36
+ end
37
+
38
+ after(:each) do
39
+ $stderr = original_stderr
40
+ $stdout = original_stdout
41
+ end
42
+
43
+ it 'should return success' do
44
+ expect(@prep_return[2]).to eq(0)
45
+ end
46
+
47
+ it 'should return help message' do
48
+ expect(@prep_return[0])
49
+ .to match(/Run acceptance tests for 1 or more roles/)
50
+ expect(@prep_return[0])
51
+ .to match(/install Vagrant plugins/)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe :lint do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ end
34
+
35
+ after(:each) do
36
+ $stderr = original_stderr
37
+ $stdout = original_stdout
38
+ end
39
+
40
+ context 'when all manifests are clean' do
41
+ it 'should run puppet-lint and return successfully' do
42
+ lint_return = ssh_exec!(@connection,
43
+ 'cd /vagrant ; bundle exec rake lint')
44
+ expect(lint_return[2]).to eq(0)
45
+ debug(lint_return)
46
+ end
47
+ end
48
+ context 'when manifests are not clean' do
49
+ before(:all) do
50
+ Git.open("#{File.dirname(__FILE__)}/../../fixtures/puppet-control")
51
+ .checkout('lint_errors')
52
+ end
53
+ after(:all) do
54
+ Git.open("#{File.dirname(__FILE__)}/../../fixtures/puppet-control")
55
+ .checkout('fixture')
56
+ end
57
+ it 'should run r10k and return an error code' do
58
+ lint_return = ssh_exec!(@connection,
59
+ 'cd /vagrant ; bundle exec rake lint')
60
+ expect(lint_return[2]).to_not eq(0)
61
+ end
62
+ it 'should run r10k and return an error message' do
63
+ lint_return = ssh_exec!(@connection,
64
+ 'cd /vagrant ; bundle exec rake lint')
65
+ expect(lint_return[0]).to match(/ERROR/)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe :puppet_cmd do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ @prep_return = ssh_exec!(@connection,
34
+ 'cd /vagrant ;'\
35
+ 'bundle exec rake puppet_cmd')
36
+ end
37
+
38
+ after(:each) do
39
+ $stderr = original_stderr
40
+ $stdout = original_stdout
41
+ end
42
+
43
+ it 'should return success' do
44
+ expect(@prep_return[2]).to eq(0)
45
+ end
46
+
47
+ it 'should return the correct puppet command' do
48
+ expect(@prep_return[0])
49
+ .to match(
50
+ "sudo puppet apply manifests/site.pp \\\n --modulepath "\
51
+ "$(echo `pwd`/modules:`pwd`/site) --hiera_config hiera.yaml\n"
52
+ )
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe :r10k do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ end
34
+
35
+ after(:each) do
36
+ $stderr = original_stderr
37
+ $stdout = original_stdout
38
+ end
39
+
40
+ context 'when Puppetfile is valid' do
41
+ it 'should run r10k and return successfully' do
42
+ r10k_return = ssh_exec!(@connection,
43
+ 'cd /vagrant ; bundle exec rake r10k')
44
+ expect(r10k_return[2]).to eq(0)
45
+ debug(r10k_return)
46
+ end
47
+ end
48
+ context 'when Puppetfile is invalid' do
49
+ before(:all) do
50
+ Git.open("#{File.dirname(__FILE__)}/../../fixtures/puppet-control")
51
+ .checkout('bad_puppetfile')
52
+ end
53
+ after(:all) do
54
+ Git.open("#{File.dirname(__FILE__)}/../../fixtures/puppet-control")
55
+ .checkout('fixture')
56
+ end
57
+ it 'should run r10k and return an error code' do
58
+ r10k_return = ssh_exec!(@connection,
59
+ 'cd /vagrant ; bundle exec rake r10k')
60
+ expect(r10k_return[2]).to_not eq(0)
61
+ end
62
+ it 'should run r10k and return an error message' do
63
+ r10k_return = ssh_exec!(@connection,
64
+ 'cd /vagrant ; bundle exec rake r10k')
65
+ expect(r10k_return[1]).to match(/ERROR/)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe :spec_clean do
4
+ include_context 'rake'
5
+
6
+ before(:all) do
7
+ @original_dir = Dir.pwd
8
+ Dir.chdir('fixtures/puppet-control')
9
+ end
10
+
11
+ after(:all) do
12
+ Dir.chdir(@original_dir)
13
+ end
14
+
15
+ context 'when run on CentOS 7' do
16
+ # rubocop:disable Lint/UselessAssignment
17
+ cached_env_debug = ''
18
+ # rubocop:enable Lint/UselessAssignment
19
+ original_stderr = $stderr
20
+ original_stdout = $stdout
21
+
22
+ before(:each) do
23
+ conf = ssh_config
24
+ @connection = Net::SSH.start(
25
+ conf['HostName'],
26
+ conf['User'],
27
+ port: conf['Port'],
28
+ password: 'vagrant'
29
+ )
30
+ ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
31
+ $stderr = File.open(File::NULL, 'w')
32
+ $stdout = File.open(File::NULL, 'w')
33
+ @prep_return = ssh_exec!(@connection,
34
+ 'cd /vagrant ;'\
35
+ 'touch /vagrant/site/profile/spec/fixtures/'\
36
+ 'modules ;'\
37
+ 'touch /vagrant/modules ;'\
38
+ 'bundle exec rake spec_clean')
39
+ end
40
+
41
+ after(:each) do
42
+ $stderr = original_stderr
43
+ $stdout = original_stdout
44
+ end
45
+
46
+ it 'should return success' do
47
+ expect(@prep_return[2]).to eq(0)
48
+ end
49
+
50
+ it 'should remove the fixtures path' do
51
+ r10k_success = ssh_exec!(@connection,
52
+ 'ls /vagrant/site/profile/spec/fixtures/modules')
53
+ expect(r10k_success[2]).to eq(2)
54
+ end
55
+ it 'should remove the modules path' do
56
+ r10k_success = ssh_exec!(@connection,
57
+ 'ls /vagrant/modules')
58
+ expect(r10k_success[2]).to eq(2)
59
+ end
60
+ end
61
+ end