control_spec_helper 0.0.2 → 0.0.3.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +57 -26
- data/Guardfile +1 -0
- data/Rakefile +141 -48
- data/bin/csh-generate +7 -0
- data/config/Guardfile +24 -0
- data/control_spec_helper.gemspec +9 -5
- data/ext/Rakefile.sample +0 -2
- data/ext/spec_helper_control.rb +2 -1
- data/lib/control_spec_helper/control_spec_helper.rb +22 -21
- data/lib/control_spec_helper/debug.rb +7 -0
- data/lib/control_spec_helper/generate.rb +79 -0
- data/lib/control_spec_helper/rake_tasks.rb +0 -1
- data/lib/{slalom.rb → control_spec_helper/util.rb} +22 -7
- data/lib/control_spec_helper/version.rb +1 -1
- data/lib/control_spec_helper.rb +2 -0
- data/lib/tasks/apply.rake +1 -1
- data/lib/tasks/lint.rake +2 -1
- data/lib/tasks/r10k.rake +1 -1
- data/lib/tasks/spec_prep.rake +0 -1
- data/lib/tasks/unit.rake +15 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/shared_contexts/rake.rb +1 -1
- data/spec/tasks/apply_debug_spec.rb +72 -0
- data/spec/tasks/apply_spec.rb +72 -0
- data/spec/tasks/apply_standalone_spec.rb +73 -0
- data/spec/tasks/help_spec.rb +54 -0
- data/spec/tasks/lint_spec.rb +69 -0
- data/spec/tasks/puppet_cmd_spec.rb +55 -0
- data/spec/tasks/r10k_spec.rb +69 -0
- data/spec/tasks/spec_clean_spec.rb +61 -0
- data/spec/tasks/spec_prep_spec.rb +69 -0
- data/spec/tasks/unit_spec.rb +70 -0
- data/spec/tasks/vplugins_spec.rb +18 -25
- data/spec/unit/control_spec_helper_spec.rb +3 -3
- data/spec/unit/debug_spec.rb +2 -2
- data/spec/unit/profile_fixtures_spec.rb +111 -125
- data/spec/unit/r10k_spec.rb +7 -0
- metadata +106 -48
- data/lib/tasks/git.rake +0 -9
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe :spec_prep 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 ; bundle exec rake spec_prep')
|
35
|
+
end
|
36
|
+
|
37
|
+
after(:each) do
|
38
|
+
$stderr = original_stderr
|
39
|
+
$stdout = original_stdout
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should return success' do
|
43
|
+
expect(@prep_return[2]).to eq(0)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should run r10k' do
|
47
|
+
r10k_success = ssh_exec!(@connection,
|
48
|
+
'ls /vagrant/modules/vcsrepo')
|
49
|
+
expect(r10k_success[2]).to eq(0)
|
50
|
+
end
|
51
|
+
it 'should create the fixtures/modules directory' do
|
52
|
+
dir_success = ssh_exec!(@connection,
|
53
|
+
'ls /vagrant/site/profile/spec/fixtures/modules')
|
54
|
+
expect(dir_success[2]).to eq(0)
|
55
|
+
end
|
56
|
+
it 'should link the profile path to its link directory' do
|
57
|
+
path_link_success = ssh_exec!(@connection,
|
58
|
+
'file /vagrant/site/profile/spec/fixtures/'\
|
59
|
+
'modules/profile')
|
60
|
+
expect(path_link_success[0]).to match(/(?!broken) symbolic link/)
|
61
|
+
end
|
62
|
+
it 'should link each module into the link directory' do
|
63
|
+
path_link_success = ssh_exec!(@connection,
|
64
|
+
'file /vagrant/site/profile/spec/fixtures/'\
|
65
|
+
'modules/vcsrepo')
|
66
|
+
expect(path_link_success[0]).to match(/(?!broken) symbolic link/)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe :unit 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
|
+
@connection = build_vagrant_connection(vagrant_ssh_config)
|
24
|
+
ssh_exec!(@connection, 'cp /vagrant/fixtures/bashrc ~/.bashrc')
|
25
|
+
$stderr = File.open(File::NULL, 'w')
|
26
|
+
$stdout = File.open(File::NULL, 'w')
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:each) do
|
30
|
+
$stderr = original_stderr
|
31
|
+
$stdout = original_stdout
|
32
|
+
end
|
33
|
+
|
34
|
+
repo = "#{File.dirname(__FILE__)}/../../fixtures/puppet-control"
|
35
|
+
|
36
|
+
context 'when all tests pass' do
|
37
|
+
before(:each) do
|
38
|
+
Git.open(repo).checkout('unit_pass')
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:each) do
|
42
|
+
Git.open(repo).checkout('fixture')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should run rspec and return successfully' do
|
46
|
+
cmd = 'cd /vagrant ; bundle exec rake unit'
|
47
|
+
_, _, exit_code, = ssh_exec!(@connection, cmd)
|
48
|
+
expect(exit_code).to eq(0)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when at least one test fails' do
|
53
|
+
before(:context) do
|
54
|
+
Git.open(repo).checkout('unit_fail')
|
55
|
+
end
|
56
|
+
|
57
|
+
after(:context) do
|
58
|
+
Git.open(repo).checkout('fixture')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should run rspec and return an error code & message' do
|
62
|
+
cmd = 'cd /vagrant ; bundle exec rake unit'
|
63
|
+
msg, _, exit_code, = ssh_exec!(@connection, cmd)
|
64
|
+
expect(exit_code).to_not eq(0)
|
65
|
+
expect(msg).to match(/Failed examples:/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
data/spec/tasks/vplugins_spec.rb
CHANGED
@@ -18,13 +18,22 @@ describe :vplugins do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when run on CentOS 7' do
|
21
|
+
# rubocop:disable Lint/UselessAssignment
|
21
22
|
cached_env_debug = ''
|
23
|
+
# rubocop:enable Lint/UselessAssignment
|
22
24
|
original_stderr = $stderr
|
23
25
|
original_stdout = $stdout
|
24
26
|
|
25
27
|
let(:conf) { ssh_config }
|
26
28
|
|
27
29
|
before(:each) do
|
30
|
+
conf = ssh_config
|
31
|
+
@connection = Net::SSH.start(
|
32
|
+
conf['HostName'],
|
33
|
+
conf['User'],
|
34
|
+
port: conf['Port'],
|
35
|
+
password: 'vagrant'
|
36
|
+
)
|
28
37
|
$stderr = File.open(File::NULL, 'w')
|
29
38
|
$stdout = File.open(File::NULL, 'w')
|
30
39
|
end
|
@@ -32,40 +41,24 @@ describe :vplugins do
|
|
32
41
|
after(:each) do
|
33
42
|
$stderr = original_stderr
|
34
43
|
$stdout = original_stdout
|
44
|
+
@connection.close
|
35
45
|
end
|
36
46
|
|
37
47
|
it 'should install successfully' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
port: conf['Port'],
|
42
|
-
password: 'vagrant'
|
43
|
-
) do |ssh|
|
44
|
-
ssh_exec!(ssh,
|
45
|
-
'cd /vagrant && unset RUBYLIB ; bundle exec rake vplugins')
|
46
|
-
end[2]).to eq(0)
|
48
|
+
response = ssh_exec!(@connection,
|
49
|
+
'cd /vagrant ; bundle exec rake vplugins')
|
50
|
+
expect(response[2]).to eq(0)
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'should install the vagrant-auto_network plugin' do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
port: conf['Port'],
|
54
|
-
password: 'vagrant'
|
55
|
-
) do |ssh|
|
56
|
-
ssh_exec!(ssh, 'unset RUBYLIB ; vagrant plugin list')
|
57
|
-
end[0].split("\n")).to include(/vagrant-auto_network/)
|
54
|
+
response = ssh_exec!(@connection, 'unset RUBYLIB ; vagrant plugin list')
|
55
|
+
puts response
|
56
|
+
expect(response[0].split("\n")).to include(/vagrant-auto_network/)
|
58
57
|
end
|
59
58
|
|
60
59
|
it 'should install the vagrant-hosts plugin' do
|
61
|
-
|
62
|
-
|
63
|
-
conf['User'],
|
64
|
-
port: conf['Port'],
|
65
|
-
password: 'vagrant'
|
66
|
-
) do |ssh|
|
67
|
-
ssh_exec!(ssh, 'unset RUBYLIB ; vagrant plugin list')
|
68
|
-
end[0].split("\n")).to include(/vagrant-hosts/)
|
60
|
+
response = ssh_exec!(@connection, 'unset RUBYLIB ; vagrant plugin list')
|
61
|
+
expect(response[0].split("\n")).to include(/vagrant-hosts/)
|
69
62
|
end
|
70
63
|
end
|
71
64
|
end
|
@@ -31,7 +31,7 @@ describe 'control_spec_helper' do
|
|
31
31
|
it 'should print properly-formatted debugging messages' do
|
32
32
|
cached_env_debug = ENV['debug']
|
33
33
|
ENV['debug'] = 'true'
|
34
|
-
expect {
|
34
|
+
expect { debug('spec') }.to output("DEBUG: spec\n").to_stderr
|
35
35
|
ENV['debug'] = cached_env_debug
|
36
36
|
end
|
37
37
|
end
|
@@ -40,14 +40,14 @@ describe 'control_spec_helper' do
|
|
40
40
|
it 'should suppress debugging messages' do
|
41
41
|
cached_env_debug = ENV['debug']
|
42
42
|
ENV.delete('debug')
|
43
|
-
expect {
|
43
|
+
expect { debug('spec') }.to_not output('DEBUG: spec')
|
44
44
|
.to_stderr
|
45
45
|
ENV['debug'] = cached_env_debug
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should print the puppet command' do
|
50
|
-
cmd = "puppet apply manifests/site.pp \\\n --modulepath " \
|
50
|
+
cmd = "sudo puppet apply manifests/site.pp \\\n --modulepath " \
|
51
51
|
'$(echo `pwd`/modules:`pwd`/site) --hiera_config hiera.yaml'
|
52
52
|
expect(@dummy_class.puppet_cmd).to eq(cmd)
|
53
53
|
end
|
data/spec/unit/debug_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'control_spec_helper' do
|
|
13
13
|
it 'should print properly-formatted debugging messages' do
|
14
14
|
cached_env_debug = ENV['debug']
|
15
15
|
ENV['debug'] = 'true'
|
16
|
-
expect {
|
16
|
+
expect { debug('spec') }.to output("DEBUG: spec\n").to_stderr
|
17
17
|
ENV['debug'] = cached_env_debug
|
18
18
|
end
|
19
19
|
end
|
@@ -22,7 +22,7 @@ describe 'control_spec_helper' do
|
|
22
22
|
it 'should suppress debugging messages' do
|
23
23
|
cached_env_debug = ENV['debug']
|
24
24
|
ENV.delete('debug')
|
25
|
-
expect {
|
25
|
+
expect { debug('spec') }.to_not output('DEBUG: spec')
|
26
26
|
.to_stderr
|
27
27
|
ENV['debug'] = cached_env_debug
|
28
28
|
end
|
@@ -5,177 +5,163 @@ class DummyClass
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe 'control_spec_helper' do
|
8
|
-
before do
|
8
|
+
before(:each) do
|
9
9
|
@dummy_class = DummyClass.new
|
10
|
+
@cached_env_debug = ''
|
11
|
+
@original_stderr = $stderr
|
12
|
+
@original_stdout = $stdout
|
13
|
+
$stderr = File.open(File::NULL, 'w')
|
14
|
+
$stdout = File.open(File::NULL, 'w')
|
15
|
+
allow(@dummy_class)
|
16
|
+
.to receive(:profile_path)
|
17
|
+
.and_return("#{Dir.pwd}/fixtures/puppet-control/site/profile")
|
18
|
+
FileUtils.rm_rf("#{Dir.pwd}/fixtures/puppet-control/site/profile/spec/"\
|
19
|
+
'fixtures/modules/profile')
|
20
|
+
end
|
21
|
+
after(:each) do
|
22
|
+
$stderr = @original_stderr
|
23
|
+
$stdout = @original_stdout
|
10
24
|
end
|
11
25
|
|
12
26
|
describe 'when profile_fixtures is called' do
|
13
27
|
describe 'when debug environmental variable is set' do
|
14
|
-
cached_env_debug = ''
|
15
|
-
|
16
28
|
before(:each) do
|
17
|
-
|
18
|
-
|
19
|
-
|
29
|
+
@cached_env_debug = ENV['debug']
|
30
|
+
ENV['debug'] = 'true'
|
31
|
+
allow(Dir)
|
32
|
+
.to receive(:glob)
|
33
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/../../modules"\
|
34
|
+
'/*')
|
35
|
+
.and_return(["#{Dir.pwd}/fixtures/puppet-control/site/profile/../../"\
|
36
|
+
'modules/concat',
|
37
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/profile/../../"\
|
38
|
+
'modules/epel'])
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:each) do
|
42
|
+
ENV['debug'] = @cached_env_debug
|
20
43
|
end
|
21
44
|
|
22
45
|
context 'if a profile link already exists' do
|
23
46
|
it 'should not try to symlink the profile path' do
|
24
|
-
allow(
|
25
|
-
.
|
26
|
-
|
27
|
-
.
|
47
|
+
allow(File).to receive(:exist?)
|
48
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/"\
|
49
|
+
'spec/fixtures/modules/profile')
|
50
|
+
.and_return(true)
|
28
51
|
expect(File).to_not receive(:symlink)
|
29
|
-
.with(
|
30
|
-
|
31
|
-
|
32
|
-
|
52
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile",
|
53
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/profile/spec/"\
|
54
|
+
'fixtures/modules/profile')
|
55
|
+
@dummy_class.profile_fixtures
|
33
56
|
end
|
34
57
|
end
|
35
58
|
|
36
59
|
context 'if a profile link does not already exist' do
|
37
60
|
it 'should symlink the profile path' do
|
38
|
-
allow(
|
39
|
-
.
|
40
|
-
|
41
|
-
.
|
42
|
-
allow(@dummy_class).to receive(:file_name).and_return('/tmp/foo.rb')
|
61
|
+
allow(File).to receive(:exist?)
|
62
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/"\
|
63
|
+
'spec/fixtures/modules/profile')
|
64
|
+
.and_return(false)
|
43
65
|
expect(File).to receive(:symlink)
|
44
|
-
.with(
|
45
|
-
|
46
|
-
|
66
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile",
|
67
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/profile/"\
|
68
|
+
'spec/fixtures/modules/profile')
|
47
69
|
@dummy_class.profile_fixtures
|
48
70
|
end
|
49
71
|
end
|
50
72
|
|
51
73
|
context 'when iterating through available modules' do
|
52
74
|
before(:each) do
|
53
|
-
allow(Dir).to receive(:glob)
|
54
|
-
.
|
55
|
-
|
56
|
-
.
|
75
|
+
allow(Dir).to receive(:glob)
|
76
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/../"\
|
77
|
+
'../modules/*')
|
78
|
+
.and_return([
|
79
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/"\
|
80
|
+
'profile/../../modules/concat',
|
81
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/"\
|
82
|
+
'profile/../../modules/epel'
|
83
|
+
])
|
57
84
|
end
|
58
|
-
|
59
85
|
context 'if discovered file is not a directory' do
|
60
|
-
|
86
|
+
before(:each) do
|
61
87
|
allow(File).to receive(:directory?)
|
62
|
-
.with(
|
63
|
-
|
64
|
-
allow(File).to receive(:directory?)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
expect(File).to_not receive(:symlink)
|
69
|
-
.with(
|
70
|
-
|
88
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/modules/concat")
|
89
|
+
.and_return(false)
|
90
|
+
allow(File).to receive(:directory?)
|
91
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/modules/epel")
|
92
|
+
end
|
93
|
+
it 'should not try to perform module operations on that file' do
|
94
|
+
expect(File).to_not receive(:symlink?)
|
95
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile"\
|
96
|
+
'/../../modules/concat')
|
71
97
|
end
|
72
98
|
end
|
73
99
|
|
74
100
|
context 'if discovered file is a directory' do
|
101
|
+
before(:each) do
|
102
|
+
allow(FileUtils)
|
103
|
+
.to receive(:mkpath)
|
104
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/spec/"\
|
105
|
+
'fixtures/modules/')
|
106
|
+
.and_return(true)
|
107
|
+
allow(File).to receive(:directory?)
|
108
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile"\
|
109
|
+
'/../../modules/concat')
|
110
|
+
.and_return(true)
|
111
|
+
allow(File).to receive(:directory?)
|
112
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile"\
|
113
|
+
'/../../modules/epel')
|
114
|
+
end
|
75
115
|
context 'if modules directories already are symlinks' do
|
76
|
-
|
77
|
-
allow(File).to receive(:directory?)
|
78
|
-
.with('/tmp/spec/fixtures/modules').and_return(true)
|
79
|
-
allow(File).to receive(:directory?).with('foo').and_return(true)
|
80
|
-
allow(File).to receive(:directory?).with('bar').and_return(true)
|
81
|
-
allow(@dummy_class).to receive(:file_name)
|
82
|
-
.and_return('/tmp/foo.rb')
|
83
|
-
allow(File).to receive(:symlink?)
|
84
|
-
.with('/tmp/spec/fixtures/modules/foo').and_return(true)
|
116
|
+
before(:each) do
|
85
117
|
allow(File).to receive(:symlink?)
|
86
|
-
.with(
|
118
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/"\
|
119
|
+
'profile/../../modules/concat')
|
120
|
+
.and_return(true)
|
121
|
+
allow(File).to receive(:symlink?).at_least(2).times
|
122
|
+
end
|
123
|
+
it 'should not try to symlink the module path' do
|
124
|
+
expect(File).to_not receive(:symlink)
|
125
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/"\
|
126
|
+
'profile/../../modules/concat',
|
127
|
+
"#{Dir.pwd}/spec/fixtures/modules/concat")
|
87
128
|
@dummy_class.profile_fixtures
|
88
129
|
end
|
89
130
|
end
|
90
131
|
|
91
132
|
context 'if modules directories do not already have symlinks' do
|
92
|
-
|
93
|
-
allow(
|
94
|
-
.
|
95
|
-
|
96
|
-
.
|
133
|
+
before(:each) do
|
134
|
+
allow(File).to receive(:symlink?)
|
135
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/"\
|
136
|
+
'profile/spec/fixtures/modules/concat')
|
137
|
+
.and_return(false)
|
97
138
|
allow(File).to receive(:directory?)
|
98
|
-
.with(
|
139
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/"\
|
140
|
+
'profile/../../modules/concat')
|
141
|
+
.and_return(true)
|
99
142
|
allow(File).to receive(:directory?)
|
100
|
-
.with(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
.with('/tmp/spec/fixtures/modules/bar').and_return(false)
|
143
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/"\
|
144
|
+
'../../modules/epel')
|
145
|
+
end
|
146
|
+
it 'should symlink the module path' do
|
105
147
|
expect(File).to receive(:symlink)
|
106
|
-
.with(
|
148
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile",
|
149
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/"\
|
150
|
+
'profile/spec/fixtures/modules/profile')
|
107
151
|
expect(File).to receive(:symlink)
|
108
|
-
.with(
|
152
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/"\
|
153
|
+
'profile/../../modules/concat',
|
154
|
+
"#{Dir.pwd}/fixtures/puppet-control/site/"\
|
155
|
+
'profile/spec/fixtures/modules/concat')
|
109
156
|
@dummy_class.profile_fixtures
|
110
157
|
end
|
111
158
|
end
|
112
159
|
|
113
|
-
describe 'when debug environmental variable is set' do
|
114
|
-
before(:each) do
|
115
|
-
allow(@dummy_class).to receive(:profile_path).and_return('/')
|
116
|
-
allow(@dummy_class).to receive(:file_name)
|
117
|
-
.and_return('/tmp/foo.rb')
|
118
|
-
allow(Dir).to receive(:glob).with('/tmp/../../modules/*')
|
119
|
-
.and_return([])
|
120
|
-
allow(Dir).to receive(:pwd).and_return('/foo')
|
121
|
-
allow(File).to receive(:exists?)
|
122
|
-
.with('/tmp/spec/fixtures/modules/profile').and_return(true)
|
123
|
-
allow(FileUtils).to receive(:mkpath)
|
124
|
-
.with('/tmp/spec/fixtures/modules/')
|
125
|
-
cached_env_debug = ENV['debug']
|
126
|
-
ENV['debug'] = 'true'
|
127
|
-
end
|
128
|
-
|
129
|
-
after(:each) do
|
130
|
-
ENV['debug'] = cached_env_debug
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should print its current profile_path directory' do
|
134
|
-
expect { @dummy_class.profile_fixtures }
|
135
|
-
.to output(%r{DEBUG: cd to /}).to_stderr
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should print its actual working directory' do
|
139
|
-
expect { @dummy_class.profile_fixtures }
|
140
|
-
.to output(%r{DEBUG: cd to /foo}).to_stderr
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
context 'when debug environmental variable is not set' do
|
145
|
-
before(:each) do
|
146
|
-
allow(@dummy_class).to receive(:profile_path).and_return('/')
|
147
|
-
allow(@dummy_class).to receive(:file_name)
|
148
|
-
.and_return('/tmp/foo.rb')
|
149
|
-
allow(Dir).to receive(:glob).with('/tmp/../../modules/*')
|
150
|
-
.and_return([])
|
151
|
-
allow(Dir).to receive(:pwd).and_return('/foo')
|
152
|
-
allow(File).to receive(:exists?)
|
153
|
-
.with('/tmp/spec/fixtures/modules/profile').and_return(true)
|
154
|
-
allow(FileUtils).to receive(:mkpath)
|
155
|
-
.with('/tmp/spec/fixtures/modules/')
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should not print its current profile_path directory' do
|
159
|
-
cached_env_debug = ENV['debug']
|
160
|
-
ENV.delete('debug')
|
161
|
-
expect { @dummy_class.profile_fixtures }
|
162
|
-
.to_not output(%r{DEBUG: cd to /}).to_stderr
|
163
|
-
ENV['debug'] = cached_env_debug
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'should not print its actual working directory' do
|
167
|
-
cached_env_debug = ENV['debug']
|
168
|
-
ENV.delete('debug')
|
169
|
-
expect { @dummy_class.profile_fixtures }
|
170
|
-
.to_not output(%r{DEBUG: cd to /foo}).to_stderr
|
171
|
-
ENV['debug'] = cached_env_debug
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
160
|
it 'should create a modules directory inside fixtures' do
|
176
|
-
|
177
|
-
|
178
|
-
.with(
|
161
|
+
expect(FileUtils)
|
162
|
+
.to receive(:mkpath)
|
163
|
+
.with("#{Dir.pwd}/fixtures/puppet-control/site/profile/spec/"\
|
164
|
+
'fixtures/modules/')
|
179
165
|
@dummy_class.profile_fixtures
|
180
166
|
end
|
181
167
|
end
|
data/spec/unit/r10k_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'git'
|
2
3
|
|
3
4
|
class DummyClass
|
4
5
|
include ControlSpecHelper
|
@@ -53,6 +54,12 @@ describe 'control_spec_helper' do
|
|
53
54
|
allow(Dir).to receive(:pwd).and_return('/tmp')
|
54
55
|
expect { @dummy_class.r10k }.to output(%r{cd to /tmp}).to_stderr
|
55
56
|
end
|
57
|
+
|
58
|
+
context 'when Puppetfile is valid' do
|
59
|
+
it 'should return a success code' do
|
60
|
+
expect(@dummy_class.r10k[2]).to eq(0)
|
61
|
+
end
|
62
|
+
end
|
56
63
|
end
|
57
64
|
end
|
58
65
|
end
|