infra-testing-helpers 0.0.4 → 0.0.5
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/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/infra-testing-helpers.gemspec +1 -1
- data/lib/infra_testing_helpers/box.rb +9 -1
- data/spec/functional/failing_spec.rb +10 -0
- data/spec/functional/modules/test2_manifest/manifests/invalid.pp +3 -0
- data/spec/unit/{puppet_vagrant → infra_testing_helpers}/box_spec.rb +5 -4
- data/spec/unit/{puppet_vagrant → infra_testing_helpers}/helper_spec.rb +0 -0
- data/spec/unit/{puppet_vagrant → infra_testing_helpers}/site_spec.rb +0 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9003be0b1502fbe6c48b1a988ce89187837dee8b
|
4
|
+
data.tar.gz: 8e9cef21fc594ea5ff33cb482dfcf38dce216716
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0418830d842377c81ce1e97fb7a944471d1bdb8e995272b9d2ba40895e637a5e727fe2ed830b45a6f28df1533c89bb383dc2fd79e73bfdf62a7ddbf991be2a2d
|
7
|
+
data.tar.gz: b1eb8290e9b9525ad55ab6379e849eef93402289b746e40458e8ec9f0ac85f01729912e7880a2b4bfae3beef2bf86be2e8886aee9d187038b7276096cabec716
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Next, lets have a look at your `spec_helper.rb` (probably generated by Serverspe
|
|
13
13
|
...
|
14
14
|
require 'infra_testing_helpers'
|
15
15
|
InfraTestingHelpers.project_root = File.expand_path(File.dirname(__FILE__) + '/../')
|
16
|
-
InfraTestingHelpers.module_path = ['modules
|
16
|
+
InfraTestingHelpers.module_path = ['modules/', 'another_module_path/']
|
17
17
|
InfraTestingHelpers.site_pp = 'Exec { path => "/sbin:/usr/sbin:/bin:/usr/bin" }'
|
18
18
|
InfraTestingHelpers.vagrant_shared_folder = '/etc/puppet'
|
19
19
|
...
|
@@ -42,9 +42,9 @@ describe 'apache' do
|
|
42
42
|
describe 'worker mode' do
|
43
43
|
before do
|
44
44
|
apply_manifest 'class {"apache": mpm => "worker"}'
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
end
|
46
|
+
describe process('httpd.woker') do
|
47
|
+
it { should be_running }
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -65,4 +65,4 @@ Finished in 6.92 seconds (files took 5.05 seconds to load)
|
|
65
65
|
|
66
66
|
`apply_manifest` will apply Puppet code differently depending on the scope in which it is called. In the global rspec scope, it will apply the manifests before running any tests. If you have multiple specs with `apply_manifest` in the global scope, they are lazily evaluated and run as a single puppet apply. This helps speed up Puppet runs and can detect duplicate resource definitions.
|
67
67
|
|
68
|
-
When `apply_manifests` is run within a `before` block it is applied
|
68
|
+
When `apply_manifests` is run within a `before` block it is applied when the block is evaluated. This is useful for testing manifests that can not co-exist with others or for testing different arguments to the same manifest.
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "infra-testing-helpers"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.5'
|
8
8
|
spec.authors = ["Ryan Doyle"]
|
9
9
|
spec.email = ["ryan@doylenet.net"]
|
10
10
|
spec.summary = %q{Integrations with RSpec, Puppet and Vagrant to help infrastructure testing}
|
@@ -23,9 +23,17 @@ module InfraTestingHelpers
|
|
23
23
|
|
24
24
|
def run_command(command, opts = {})
|
25
25
|
stdin = opts[:stdin] ? " << EOF\n#{opts[:stdin]}\nEOF" : ""
|
26
|
-
|
26
|
+
run_in_clean_environment "vagrant ssh #{@name} --command \"#{command}\"#{stdin}"
|
27
27
|
$?.exitstatus
|
28
28
|
end
|
29
|
+
|
30
|
+
def run_in_clean_environment(command)
|
31
|
+
if ENV['BUNDLE_GEMFILE']
|
32
|
+
Bundler.clean_system command
|
33
|
+
else
|
34
|
+
system command
|
35
|
+
end
|
36
|
+
end
|
29
37
|
|
30
38
|
end
|
31
39
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'functional_spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'applying a manifest' do
|
5
|
+
|
6
|
+
it 'raises an error if it cannot apply the manifest' do
|
7
|
+
expect{ apply_manifest 'include test_manifest::invalid' }.to raise_error InfraTestingHelpers::PuppetApplyFailed
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -13,6 +13,8 @@ describe InfraTestingHelpers::Box do
|
|
13
13
|
allow(manifest).to receive(:module_path).and_return('/vagrant/modules/')
|
14
14
|
allow(manifest).to receive(:puppet_code).and_return('include some_manifest')
|
15
15
|
allow(manifest).to receive(:manifest_file).and_yield('/vagrant/tempfile_path.pp')
|
16
|
+
allow(box).to receive(:system)
|
17
|
+
allow(Bundler).to receive(:clean_system)
|
16
18
|
end
|
17
19
|
|
18
20
|
describe '#apply' do
|
@@ -60,25 +62,24 @@ describe InfraTestingHelpers::Box do
|
|
60
62
|
|
61
63
|
describe '#run_command' do
|
62
64
|
it 'runs the command on the box' do
|
63
|
-
expect(
|
65
|
+
expect(Bundler).to receive(:clean_system).with('vagrant ssh default --command "some_command"')
|
64
66
|
box.run_command('some_command')
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'runs the command on the box with the box name' do
|
68
70
|
box = described_class.new('somebox')
|
69
|
-
expect(
|
71
|
+
expect(Bundler).to receive(:clean_system).with('vagrant ssh somebox --command "some_command"')
|
70
72
|
box.run_command('some_command')
|
71
73
|
end
|
72
74
|
|
73
75
|
it 'returns the exit status of the command that ran' do
|
74
|
-
allow(box).to receive(:system)
|
75
76
|
allow($?).to receive(:exitstatus).and_return(1)
|
76
77
|
|
77
78
|
expect(box.run_command('foo')).to eql(1)
|
78
79
|
end
|
79
80
|
|
80
81
|
it 'pipes stdin to the command if given' do
|
81
|
-
expect(
|
82
|
+
expect(Bundler).to receive(:clean_system).with("vagrant ssh default --command \"some_command\" << EOF\nsomething\nEOF")
|
82
83
|
box.run_command('some_command', :stdin => "something")
|
83
84
|
end
|
84
85
|
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infra-testing-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -70,15 +70,17 @@ files:
|
|
70
70
|
- lib/infra_testing_helpers/box.rb
|
71
71
|
- lib/infra_testing_helpers/helper.rb
|
72
72
|
- lib/infra_testing_helpers/site.rb
|
73
|
+
- spec/functional/failing_spec.rb
|
73
74
|
- spec/functional/modules/test2_manifest/manifests/init.pp
|
75
|
+
- spec/functional/modules/test2_manifest/manifests/invalid.pp
|
74
76
|
- spec/functional/modules/test_manifest/manifests/init.pp
|
75
77
|
- spec/functional/sample2_spec.rb
|
76
78
|
- spec/functional/sample_spec.rb
|
77
79
|
- spec/functional_spec_helper.rb
|
78
80
|
- spec/spec_helper.rb
|
79
|
-
- spec/unit/
|
80
|
-
- spec/unit/
|
81
|
-
- spec/unit/
|
81
|
+
- spec/unit/infra_testing_helpers/box_spec.rb
|
82
|
+
- spec/unit/infra_testing_helpers/helper_spec.rb
|
83
|
+
- spec/unit/infra_testing_helpers/site_spec.rb
|
82
84
|
homepage: https://github.com/ryandoyle/infra-testing-helpers
|
83
85
|
licenses:
|
84
86
|
- MIT
|
@@ -104,13 +106,14 @@ signing_key:
|
|
104
106
|
specification_version: 4
|
105
107
|
summary: Integrations with RSpec, Puppet and Vagrant to help infrastructure testing
|
106
108
|
test_files:
|
109
|
+
- spec/functional/failing_spec.rb
|
107
110
|
- spec/functional/modules/test2_manifest/manifests/init.pp
|
111
|
+
- spec/functional/modules/test2_manifest/manifests/invalid.pp
|
108
112
|
- spec/functional/modules/test_manifest/manifests/init.pp
|
109
113
|
- spec/functional/sample2_spec.rb
|
110
114
|
- spec/functional/sample_spec.rb
|
111
115
|
- spec/functional_spec_helper.rb
|
112
116
|
- spec/spec_helper.rb
|
113
|
-
- spec/unit/
|
114
|
-
- spec/unit/
|
115
|
-
- spec/unit/
|
116
|
-
has_rdoc:
|
117
|
+
- spec/unit/infra_testing_helpers/box_spec.rb
|
118
|
+
- spec/unit/infra_testing_helpers/helper_spec.rb
|
119
|
+
- spec/unit/infra_testing_helpers/site_spec.rb
|