infra-testing-helpers 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +47 -0
- data/README.md +66 -0
- data/Rakefile +10 -0
- data/Vagrantfile +9 -0
- data/infra-testing-helpers.gemspec +24 -0
- data/lib/infra_testing_helpers.rb +41 -0
- data/lib/infra_testing_helpers/box.rb +30 -0
- data/lib/infra_testing_helpers/helper.rb +33 -0
- data/lib/infra_testing_helpers/site.rb +21 -0
- data/spec/functional/modules/test2_manifest/manifests/init.pp +3 -0
- data/spec/functional/modules/test_manifest/manifests/init.pp +3 -0
- data/spec/functional/sample2_spec.rb +7 -0
- data/spec/functional/sample_spec.rb +12 -0
- data/spec/functional_spec_helper.rb +26 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/puppet_vagrant/box_spec.rb +96 -0
- data/spec/unit/puppet_vagrant/helper_spec.rb +50 -0
- data/spec/unit/puppet_vagrant/site_spec.rb +34 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de94109a3f6ebcd8bb5baa59cb2e3c2e41bca81c
|
4
|
+
data.tar.gz: 950e518c5011359ea20d9afca7d15efba8c74203
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9471040c69fe8765545396325bef988e625f23bf1591a6210a4fca0185d6dbf6e43052e5a4d4584ad6b43bafcab36d3c9fe7e16d71406fbf0a46532fd5c2ac4c
|
7
|
+
data.tar.gz: ba8b44264e4758e553518d2849d3be4caee55437469e3d228818b642fdc32e5e6a8a8d2bece6f620ee3a4f25e7724e9fe6a4068705720d41897de869d13eee30
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
infra-testing-helpers (0.0.1)
|
5
|
+
rspec (~> 3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
multi_json (1.11.0)
|
12
|
+
net-scp (1.2.1)
|
13
|
+
net-ssh (>= 2.6.5)
|
14
|
+
net-ssh (2.9.2)
|
15
|
+
rake (10.3.2)
|
16
|
+
rspec (3.2.0)
|
17
|
+
rspec-core (~> 3.2.0)
|
18
|
+
rspec-expectations (~> 3.2.0)
|
19
|
+
rspec-mocks (~> 3.2.0)
|
20
|
+
rspec-core (3.2.2)
|
21
|
+
rspec-support (~> 3.2.0)
|
22
|
+
rspec-expectations (3.2.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.2.0)
|
25
|
+
rspec-its (1.2.0)
|
26
|
+
rspec-core (>= 3.0.0)
|
27
|
+
rspec-expectations (>= 3.0.0)
|
28
|
+
rspec-mocks (3.2.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.2.0)
|
31
|
+
rspec-support (3.2.2)
|
32
|
+
serverspec (2.10.1)
|
33
|
+
multi_json
|
34
|
+
rspec (~> 3.0)
|
35
|
+
rspec-its
|
36
|
+
specinfra (~> 2.15)
|
37
|
+
specinfra (2.19.3)
|
38
|
+
net-scp
|
39
|
+
net-ssh
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
infra-testing-helpers!
|
46
|
+
rake (~> 10)
|
47
|
+
serverspec (~> 2)
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# InfraTestingHelpers
|
2
|
+
> Your helping hand for infrastructure code testing
|
3
|
+
|
4
|
+
InfraTestingHelpers provides integrations with Vagrant, Puppet and Serverspec to make infrastructure code testing easy! I'll show you around to see how it can help you too. There is some assumed knowledge of Serverspec so have a read of the [tutorial] if you haven't done so already
|
5
|
+
|
6
|
+
## Serverspec integraton
|
7
|
+
Lets say you've written some tests for Serverspec that test your Puppet modules. InfraTestingHelpers provide a way to run your Puppet code against a Vagrant box before validating with Serverspec
|
8
|
+
### Setup
|
9
|
+
Install with `gem install infra-testing-helpers`
|
10
|
+
|
11
|
+
Next, lets have a look at your `spec_helper.rb` (probably generated by Serverspec) and add the parts we need in for InfraTestingHelpers.
|
12
|
+
```ruby
|
13
|
+
...
|
14
|
+
require 'infra_testing_helpers'
|
15
|
+
InfraTestingHelpers.module_path = 'modules/:another_module_path/'
|
16
|
+
InfraTestingHelpers.site_pp = 'Exec { path => "/sbin:/usr/sbin:/bin:/usr/bin" }'
|
17
|
+
InfraTestingHelpers.vagrant_shared_folder = '/etc/puppet'
|
18
|
+
...
|
19
|
+
```
|
20
|
+
- `require 'infra_testing_helpers'` mixes in the functions we will use later in our specs as well as sets up a global `before` hook in RSpec.
|
21
|
+
- `InfraTestingHelpers.module_path` is the location of your modules. This defaults to just `modules/` if nothing is specified.
|
22
|
+
- `InfraTestingHelpers.site_pp` is the contents of your own `site.pp` file. If yours is rather large, you might want to dynamically populate this (`File.read`). Again, this is optional.
|
23
|
+
- `InfraTestingHelpers.vagrant_shared_folder` reflects where your shared folder is in your `Vagrantfile`. This defaults to `/vagrant`.
|
24
|
+
|
25
|
+
### Specs
|
26
|
+
Lets look at an example spec `modules/apache/spec/default/apache_spec.rb`.
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
require 'spec_helper'
|
30
|
+
apply_manifest 'include apache'
|
31
|
+
|
32
|
+
describe 'apache' do
|
33
|
+
|
34
|
+
describe 'its default MPM mode is perfork' do
|
35
|
+
describe process('httpd') do
|
36
|
+
it { should be_running }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'worker mode' do
|
41
|
+
before do
|
42
|
+
apply_manifest 'class {"apache": mpm => "worker"}'
|
43
|
+
describe process('httpd.woker') do
|
44
|
+
it { should be_running }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Lets apply the manifest with `rspec modules/apache/spec/default/apache_spec.rb`.
|
53
|
+
|
54
|
+
```
|
55
|
+
Notice: Compiled catalog for vagrant-ubuntu-trusty-64.local in environment production in 0.05 seconds
|
56
|
+
Notice: Finished catalog run in 0.03 seconds
|
57
|
+
.Notice: Compiled catalog for vagrant-ubuntu-trusty-64.local in environment production in 0.04 seconds
|
58
|
+
Notice: Finished catalog run in 0.01 seconds
|
59
|
+
.
|
60
|
+
Finished in 6.92 seconds (files took 5.05 seconds to load)
|
61
|
+
2 examples, 0 failures
|
62
|
+
```
|
63
|
+
|
64
|
+
`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.
|
65
|
+
|
66
|
+
When `apply_manifests` is run within a `before` block it is applied instantly. This is useful for testing manifests that can not co-exist with others or for testing different arguments to the same manifest.
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "infra-testing-helpers"
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["Ryan Doyle"]
|
9
|
+
spec.email = ["ryan@doylenet.net"]
|
10
|
+
spec.summary = %q{Integrations with RSpec, Puppet and Vagrant to help infrastructure testing}
|
11
|
+
spec.description = %q{RSpec helper functions to run Puppet code as part of Serverspec tests}
|
12
|
+
spec.homepage = "https://github.com/ryandoyle/infra-testing-helpers"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "rspec", '~> 3'
|
20
|
+
|
21
|
+
spec.add_development_dependency "serverspec", '~> 2'
|
22
|
+
spec.add_development_dependency "rake", '~> 10'
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'infra_testing_helpers/helper'
|
2
|
+
|
3
|
+
module InfraTestingHelpers
|
4
|
+
|
5
|
+
@settings = {
|
6
|
+
:module_path => 'modules/',
|
7
|
+
:site_pp => '',
|
8
|
+
:vagrant_shared_folder => '/vagrant'
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.vagrant_shared_folder
|
12
|
+
@settings[:vagrant_shared_folder]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.vagrant_shared_folder=(mount_point)
|
16
|
+
@settings[:vagrant_shared_folder] = mount_point
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.site_pp
|
20
|
+
@settings[:site_pp]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.site_pp=(puppet_code)
|
24
|
+
@settings[:site_pp] = puppet_code
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.module_path
|
28
|
+
@settings[:module_path]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.module_path=(path)
|
32
|
+
@settings[:module_path] = path
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
include InfraTestingHelpers::Helper
|
38
|
+
|
39
|
+
RSpec.configure do |c|
|
40
|
+
c.before(:suite) { apply_all_manifests }
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module InfraTestingHelpers
|
2
|
+
class PuppetApplyFailed < StandardError; end
|
3
|
+
class Box
|
4
|
+
def initialize(name, project_mount_point)
|
5
|
+
@name = name
|
6
|
+
@project_mount_point = project_mount_point
|
7
|
+
@applied = false
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :name
|
11
|
+
|
12
|
+
def apply(manifest)
|
13
|
+
exit_code = run_command("sudo puppet apply --detailed-exitcode --modulepath #{@project_mount_point}/#{manifest.module_path}", :stdin => manifest.puppet_code)
|
14
|
+
raise PuppetApplyFailed unless exit_code == 0 or exit_code == 2
|
15
|
+
@applied = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def applied?
|
19
|
+
@applied
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def run_command(command, opts = {})
|
24
|
+
stdin = opts[:stdin] ? " << EOF\n#{opts[:stdin]}\nEOF" : ""
|
25
|
+
system "vagrant ssh #{@name} --command \"#{command}\"#{stdin}"
|
26
|
+
$?.exitstatus
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'infra_testing_helpers/box'
|
2
|
+
require 'infra_testing_helpers/site'
|
3
|
+
|
4
|
+
module InfraTestingHelpers
|
5
|
+
module Helper
|
6
|
+
|
7
|
+
def apply_manifest(manifest_code)
|
8
|
+
if box.applied?
|
9
|
+
local_site = InfraTestingHelpers::Site.new(InfraTestingHelpers.site_pp, InfraTestingHelpers.module_path)
|
10
|
+
local_site.add_manifest(manifest_code)
|
11
|
+
box.apply(local_site)
|
12
|
+
else
|
13
|
+
global_site.add_manifest(manifest_code)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply_all_manifests
|
19
|
+
box.apply(global_site)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def global_site
|
25
|
+
@@global_site ||= InfraTestingHelpers::Site.new(InfraTestingHelpers.site_pp, InfraTestingHelpers.module_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def box
|
29
|
+
@@box ||= InfraTestingHelpers::Box.new('default', InfraTestingHelpers.vagrant_shared_folder)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module InfraTestingHelpers
|
2
|
+
class Site
|
3
|
+
|
4
|
+
def initialize(site_code, module_path)
|
5
|
+
@site_code = site_code
|
6
|
+
@module_path = module_path
|
7
|
+
@manifest_code = ""
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :module_path
|
11
|
+
|
12
|
+
def add_manifest(manifest)
|
13
|
+
@manifest_code << "#{manifest}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def puppet_code
|
17
|
+
"#{@site_code}\n#{@manifest_code}"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'serverspec'
|
4
|
+
require 'net/ssh'
|
5
|
+
require 'tempfile'
|
6
|
+
require 'infra_testing_helpers'
|
7
|
+
|
8
|
+
InfraTestingHelpers.module_path = 'spec/functional/modules/'
|
9
|
+
InfraTestingHelpers.site_pp = "notify {'This is my site.pp':}"
|
10
|
+
|
11
|
+
set :backend, :ssh
|
12
|
+
|
13
|
+
host = 'default'
|
14
|
+
|
15
|
+
`vagrant up #{host}`
|
16
|
+
|
17
|
+
config = Tempfile.new('', Dir.tmpdir)
|
18
|
+
config.write(`vagrant ssh-config #{host}`)
|
19
|
+
config.close
|
20
|
+
|
21
|
+
options = Net::SSH::Config.for(host, [config.path])
|
22
|
+
|
23
|
+
options[:user] ||= Etc.getlogin
|
24
|
+
|
25
|
+
set :host, options[:host_name] || host
|
26
|
+
set :ssh_options, options
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/')
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'infra_testing_helpers/box'
|
4
|
+
|
5
|
+
describe InfraTestingHelpers::Box do
|
6
|
+
|
7
|
+
let(:manifest) { double('Manifest') }
|
8
|
+
let(:box) { described_class.new('default', '/vagrant') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow_message_expectations_on_nil
|
12
|
+
allow($?).to receive(:exitstatus).and_return(0)
|
13
|
+
allow(manifest).to receive(:module_path).and_return('modules/')
|
14
|
+
allow(manifest).to receive(:puppet_code).and_return('include some_manifest')
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#apply' do
|
18
|
+
|
19
|
+
it 'successfully applies a manifest to the box' do
|
20
|
+
expect(box).to receive(:run_command).with('sudo puppet apply --detailed-exitcode --modulepath /vagrant/modules/', {:stdin=>"include some_manifest"}).and_return(0)
|
21
|
+
box.apply(manifest)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'successfully applies a manifest to the box and deals with weird exit codes' do
|
25
|
+
expect(box).to receive(:run_command).with('sudo puppet apply --detailed-exitcode --modulepath /vagrant/modules/', {:stdin=>"include some_manifest"}).and_return(2)
|
26
|
+
box.apply(manifest)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
it 'raises a InfraTestingHelpers::PuppetApplyFailed error if the puppet apply fails' do
|
31
|
+
allow(box).to receive(:run_command).with('sudo puppet apply --detailed-exitcode --modulepath /vagrant/modules/', {:stdin=>"include some_manifest"}).and_return(1)
|
32
|
+
|
33
|
+
expect{box.apply(manifest)}.to raise_error(InfraTestingHelpers::PuppetApplyFailed)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#applied?' do
|
40
|
+
|
41
|
+
it 'is false if a manifest has not been applied' do
|
42
|
+
expect(box.applied?).to be false
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'is true when a manifest is applied successfully' do
|
46
|
+
allow(box).to receive(:run_command).and_return(0)
|
47
|
+
box.apply(manifest)
|
48
|
+
|
49
|
+
expect(box.applied?).to be true
|
50
|
+
end
|
51
|
+
it 'is false when a manifest is not applied successfully' do
|
52
|
+
allow(box).to receive(:run_command).with('sudo puppet apply --detailed-exitcode --modulepath /vagrant/modules/', {:stdin=>"include some_manifest"}).and_return(1)
|
53
|
+
expect{box.apply(manifest)}.to raise_error(InfraTestingHelpers::PuppetApplyFailed)
|
54
|
+
|
55
|
+
expect(box.applied?).to be false
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#run_command' do
|
61
|
+
it 'runs the command on the box' do
|
62
|
+
expect(box).to receive(:system).with('vagrant ssh default --command "some_command"')
|
63
|
+
box.run_command('some_command')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'runs the command on the box with the box name' do
|
67
|
+
box = described_class.new('somebox', '/vagrant')
|
68
|
+
expect(box).to receive(:system).with('vagrant ssh somebox --command "some_command"')
|
69
|
+
box.run_command('some_command')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns the exit status of the command that ran' do
|
73
|
+
allow(box).to receive(:system)
|
74
|
+
allow($?).to receive(:exitstatus).and_return(1)
|
75
|
+
|
76
|
+
expect(box.run_command('foo')).to eql(1)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'pipes stdin to the command if given' do
|
80
|
+
expect(box).to receive(:system).with("vagrant ssh default --command \"some_command\" << EOF\nsomething\nEOF")
|
81
|
+
box.run_command('some_command', :stdin => "something")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#name' do
|
86
|
+
it 'defaults to the "default" box name if not specified' do
|
87
|
+
expect(box.name).to eql 'default'
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'has a name if specified' do
|
91
|
+
box = described_class.new('somebox', '/vagrant')
|
92
|
+
expect(box.name).to eql 'somebox'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'infra_testing_helpers/helper'
|
4
|
+
|
5
|
+
class TestInfraTestingHelper
|
6
|
+
include InfraTestingHelpers::Helper
|
7
|
+
end
|
8
|
+
|
9
|
+
describe InfraTestingHelpers::Helper do
|
10
|
+
|
11
|
+
let(:helper) { TestInfraTestingHelper.new }
|
12
|
+
let(:global_site) { double('Global Site') }
|
13
|
+
let(:local_site) { double('Local Site') }
|
14
|
+
let(:box) { double('InfraTestingHelpers::Box') }
|
15
|
+
|
16
|
+
|
17
|
+
before do
|
18
|
+
allow(helper).to receive(:global_site).and_return global_site
|
19
|
+
allow(helper).to receive(:box).and_return box
|
20
|
+
allow(box).to receive(:applied?).and_return false
|
21
|
+
allow(InfraTestingHelpers).to receive(:module_path)
|
22
|
+
allow(InfraTestingHelpers).to receive(:site_pp)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#apply_manifest' do
|
26
|
+
it 'adds the manifest to the site to be applied' do
|
27
|
+
expect(global_site).to receive(:add_manifest).with 'include ntp'
|
28
|
+
|
29
|
+
helper.apply_manifest('include ntp')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'applies the manifest straight away if it was previously applied' do
|
33
|
+
allow(box).to receive(:applied?).and_return true
|
34
|
+
allow(InfraTestingHelpers::Site).to receive(:new).and_return local_site
|
35
|
+
allow(local_site).to receive(:add_manifest)
|
36
|
+
|
37
|
+
expect(box).to receive(:apply).with(local_site)
|
38
|
+
|
39
|
+
helper.apply_manifest('include ntp')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#apply_all_manifests' do
|
44
|
+
it 'applies all manifests for a site' do
|
45
|
+
expect(box).to receive(:apply).with(global_site)
|
46
|
+
|
47
|
+
helper.apply_all_manifests
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'infra_testing_helpers/site'
|
4
|
+
|
5
|
+
describe InfraTestingHelpers::Site do
|
6
|
+
|
7
|
+
let(:site) { described_class.new('site.pp code', '/some/module/path') }
|
8
|
+
|
9
|
+
describe '#puppet_code' do
|
10
|
+
it 'should contain the site.pp code' do
|
11
|
+
expect(site.puppet_code).to include 'site.pp code'
|
12
|
+
end
|
13
|
+
it 'should have a new line between the site code and the manifest code' do
|
14
|
+
site.add_manifest 'include ntp'
|
15
|
+
|
16
|
+
expect(site.puppet_code).to include "site.pp code\ninclude ntp"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#add_manifest' do
|
21
|
+
it 'should add the manifest to the puppet code' do
|
22
|
+
site.add_manifest('include ntp')
|
23
|
+
|
24
|
+
expect(site.puppet_code).to include 'include ntp'
|
25
|
+
end
|
26
|
+
it 'should add a new line after each manifest' do
|
27
|
+
site.add_manifest('include ntp')
|
28
|
+
site.add_manifest('include apache')
|
29
|
+
|
30
|
+
expect(site.puppet_code).to include "include ntp\ninclude apache"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: infra-testing-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Doyle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: serverspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10'
|
55
|
+
description: RSpec helper functions to run Puppet code as part of Serverspec tests
|
56
|
+
email:
|
57
|
+
- ryan@doylenet.net
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- Vagrantfile
|
68
|
+
- infra-testing-helpers.gemspec
|
69
|
+
- lib/infra_testing_helpers.rb
|
70
|
+
- lib/infra_testing_helpers/box.rb
|
71
|
+
- lib/infra_testing_helpers/helper.rb
|
72
|
+
- lib/infra_testing_helpers/site.rb
|
73
|
+
- spec/functional/modules/test2_manifest/manifests/init.pp
|
74
|
+
- spec/functional/modules/test_manifest/manifests/init.pp
|
75
|
+
- spec/functional/sample2_spec.rb
|
76
|
+
- spec/functional/sample_spec.rb
|
77
|
+
- spec/functional_spec_helper.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/unit/puppet_vagrant/box_spec.rb
|
80
|
+
- spec/unit/puppet_vagrant/helper_spec.rb
|
81
|
+
- spec/unit/puppet_vagrant/site_spec.rb
|
82
|
+
homepage: https://github.com/ryandoyle/infra-testing-helpers
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.2.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Integrations with RSpec, Puppet and Vagrant to help infrastructure testing
|
106
|
+
test_files:
|
107
|
+
- spec/functional/modules/test2_manifest/manifests/init.pp
|
108
|
+
- spec/functional/modules/test_manifest/manifests/init.pp
|
109
|
+
- spec/functional/sample2_spec.rb
|
110
|
+
- spec/functional/sample_spec.rb
|
111
|
+
- spec/functional_spec_helper.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- spec/unit/puppet_vagrant/box_spec.rb
|
114
|
+
- spec/unit/puppet_vagrant/helper_spec.rb
|
115
|
+
- spec/unit/puppet_vagrant/site_spec.rb
|