vagrant_spec 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -2
- data/README.md +15 -36
- data/Vagrantfile +5 -4
- data/lib/vagrant_spec/command/init.rb +0 -2
- data/lib/vagrant_spec/templates/init_help +0 -4
- data/lib/vagrant_spec/test_plan.rb +28 -6
- data/lib/vagrant_spec/version.rb +1 -1
- data/scripts/poor_mans_smoke_test.sh +1 -1
- data/serverspec/ansible_spec.rb +6 -0
- data/serverspec/pansible_spec.rb +6 -0
- data/spec/unit/spec_helper.rb +5 -0
- data/spec/unit/vagrant_spec_test/command_spec/init_spec.rb +0 -10
- data/spec/unit/vagrant_spec_test/test_plan_spec.rb +32 -4
- metadata +3 -7
- data/lib/vagrant_spec/spec_helper.rb +0 -42
- data/lib/vagrant_spec/templates/spec_helper.erb +0 -19
- data/serverspec/fail_spec.rb +0 -7
- data/serverspec/ssh_spec.rb +0 -10
- data/spec/unit/vagrant_spec_test/spec_helper_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb07a53bcd6698b0ad2af73417b1fb2235489274
|
4
|
+
data.tar.gz: 776a3dfe81a097b90e4c2a6ab68bf7803ec7c1a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed91f539ff20534a965e36b6300dc7c90c2ef10d0e2e189031cae58bbaa66cfc56068e3b9b815850b38bdf4b69d2a23b2f29413cee16313581cdac084b737cb
|
7
|
+
data.tar.gz: b44fb0bbe52e6223e5bfb97a0c6af652a8106fd0285f5c41e84f4b2644449d55e711958e0410fd4b513e30cab71a7a8277f50695c44eb189c57524bb87049ecf
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v0.0.5](https://github.com/miroswan/vagrant_spec/tree/v0.0.5) (2016-08-10)
|
4
|
+
[Full Changelog](https://github.com/miroswan/vagrant_spec/compare/v0.0.4...v0.0.5)
|
4
5
|
|
5
|
-
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- SSH Issue [\#14](https://github.com/miroswan/vagrant_spec/issues/14)
|
9
|
+
- Fix spelling and grammatical issues in the documentation [\#7](https://github.com/miroswan/vagrant_spec/issues/7)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Fixing SSH [\#13](https://github.com/miroswan/vagrant_spec/pull/13) ([miroswan](https://github.com/miroswan))
|
14
|
+
|
15
|
+
## [v0.0.4](https://github.com/miroswan/vagrant_spec/tree/v0.0.4) (2016-08-10)
|
16
|
+
[Full Changelog](https://github.com/miroswan/vagrant_spec/compare/v0.0.3...v0.0.4)
|
6
17
|
|
7
18
|
**Implemented enhancements:**
|
8
19
|
|
@@ -12,9 +23,20 @@
|
|
12
23
|
|
13
24
|
- License info needs to be added to the gemspec [\#4](https://github.com/miroswan/vagrant_spec/issues/4)
|
14
25
|
|
26
|
+
**Merged pull requests:**
|
27
|
+
|
28
|
+
- Preparation for v0.0.4 [\#12](https://github.com/miroswan/vagrant_spec/pull/12) ([miroswan](https://github.com/miroswan))
|
29
|
+
- Updating the documentation [\#11](https://github.com/miroswan/vagrant_spec/pull/11) ([miroswan](https://github.com/miroswan))
|
30
|
+
- Adding version sub-command [\#10](https://github.com/miroswan/vagrant_spec/pull/10) ([miroswan](https://github.com/miroswan))
|
31
|
+
|
15
32
|
## [v0.0.3](https://github.com/miroswan/vagrant_spec/tree/v0.0.3) (2016-08-09)
|
16
33
|
[Full Changelog](https://github.com/miroswan/vagrant_spec/compare/v0.0.2...v0.0.3)
|
17
34
|
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- Prepping for a v0.0.3 release [\#6](https://github.com/miroswan/vagrant_spec/pull/6) ([miroswan](https://github.com/miroswan))
|
38
|
+
- Feature/machine data [\#5](https://github.com/miroswan/vagrant_spec/pull/5) ([miroswan](https://github.com/miroswan))
|
39
|
+
|
18
40
|
## [v0.0.2](https://github.com/miroswan/vagrant_spec/tree/v0.0.2) (2016-08-06)
|
19
41
|
[Full Changelog](https://github.com/miroswan/vagrant_spec/compare/v0.0.1...v0.0.2)
|
20
42
|
|
@@ -23,6 +45,10 @@
|
|
23
45
|
- Help output for init needs to be updated [\#2](https://github.com/miroswan/vagrant_spec/issues/2)
|
24
46
|
- Needs tests [\#1](https://github.com/miroswan/vagrant_spec/issues/1)
|
25
47
|
|
48
|
+
**Merged pull requests:**
|
49
|
+
|
50
|
+
- Updates [\#3](https://github.com/miroswan/vagrant_spec/pull/3) ([miroswan](https://github.com/miroswan))
|
51
|
+
|
26
52
|
## [v0.0.1](https://github.com/miroswan/vagrant_spec/tree/v0.0.1) (2016-08-06)
|
27
53
|
|
28
54
|
|
data/README.md
CHANGED
@@ -92,9 +92,11 @@ your cluster of nodes.
|
|
92
92
|
|
93
93
|
* version: Print the current version of vagrant_spec
|
94
94
|
|
95
|
-
* init: This will generate your
|
96
|
-
|
97
|
-
|
95
|
+
* init: This will generate your ansible inventory file if you've configured your
|
96
|
+
config.spec.ansible_inventory directive. Additionally, it'll generate your
|
97
|
+
.vagrantspec_machine_data file if set to enabled via
|
98
|
+
config.spec.generate_machine_data. You'll typically want to run this after a
|
99
|
+
vagrant up and before your deployment and testing tasks.
|
98
100
|
|
99
101
|
* test: This will run the tests specified in your Vagrantfile. Tests are
|
100
102
|
executed against each node in your fleet and the exit code is stored if an error
|
@@ -104,9 +106,9 @@ to the shell. Otherwise, it will return zero.
|
|
104
106
|
## Sample Output
|
105
107
|
|
106
108
|
```
|
107
|
-
>
|
109
|
+
> vagrant spec init
|
108
110
|
|
109
|
-
>
|
111
|
+
> vagrant spec test
|
110
112
|
|
111
113
|
*******************************************************
|
112
114
|
***************** ServerSpec Test Run *****************
|
@@ -114,45 +116,22 @@ to the shell. Otherwise, it will return zero.
|
|
114
116
|
|
115
117
|
[test_ansible]
|
116
118
|
|
117
|
-
|
118
|
-
|
119
|
+
Test Hostname
|
120
|
+
hostname is test_ansible
|
119
121
|
|
120
|
-
Finished in 0.
|
122
|
+
Finished in 0.43356 seconds (files took 1.61 seconds to load)
|
121
123
|
1 example, 0 failures
|
122
124
|
|
123
125
|
[test_pansible]
|
124
126
|
|
125
|
-
|
126
|
-
|
127
|
+
Test Hostname
|
128
|
+
hostname is test_pansible
|
127
129
|
|
128
|
-
|
129
|
-
|
130
|
-
1) Thing that fails dumb_service totally fails
|
131
|
-
On host `127.0.0.1'
|
132
|
-
Failure/Error: expect(service('dumb_service')).to be_running
|
133
|
-
expected Service "dumb_service" to be running
|
134
|
-
sudo -p 'Password: ' /bin/sh -c ps\ aux\ \|\ grep\ -w\ --\ dumb_service\ \|\ grep\ -qv\ grep
|
135
|
-
|
136
|
-
# ./serverspec/fail_spec.rb:5:in `block (2 levels) in <top (required)>'
|
137
|
-
# ./lib/vagrant_spec/test_plan.rb:62:in `execute_plan_tests'
|
138
|
-
# ./lib/vagrant_spec/test_plan.rb:31:in `block (2 levels) in run'
|
139
|
-
# ./lib/vagrant_spec/test_plan.rb:31:in `each'
|
140
|
-
# ./lib/vagrant_spec/test_plan.rb:31:in `block in run'
|
141
|
-
# ./lib/vagrant_spec/test_plan.rb:30:in `each'
|
142
|
-
# ./lib/vagrant_spec/test_plan.rb:30:in `run'
|
143
|
-
# ./lib/vagrant_spec/command/test.rb:18:in `execute'
|
144
|
-
# ./lib/vagrant_spec/command/base.rb:61:in `parse_subcommand'
|
145
|
-
# ./lib/vagrant_spec/command/base.rb:25:in `execute'
|
146
|
-
|
147
|
-
Finished in 0.05726 seconds (files took 0.58135 seconds to load)
|
148
|
-
1 example, 1 failure
|
149
|
-
|
150
|
-
Failed examples:
|
151
|
-
|
152
|
-
rspec ./serverspec/fail_spec.rb:4 # Thing that fails dumb_service totally fails
|
130
|
+
Finished in 0.22762 seconds (files took 0.59837 seconds to load)
|
131
|
+
1 example, 0 failures
|
153
132
|
|
154
133
|
> echo $?
|
155
|
-
|
134
|
+
0
|
156
135
|
```
|
157
136
|
|
158
137
|
## Testing Resources
|
data/Vagrantfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
|
2
2
|
Vagrant.configure(2) do |config|
|
3
|
+
config.vm.box = 'ubuntu/trusty64'
|
3
4
|
config.vm.define 'test_ansible' do |b|
|
4
|
-
b.vm.
|
5
|
+
b.vm.hostname = 'ansible'
|
5
6
|
end
|
6
7
|
|
7
8
|
config.vm.define 'test_pansible' do |b|
|
8
|
-
b.vm.
|
9
|
+
b.vm.hostname = 'pansible'
|
9
10
|
end
|
10
11
|
|
11
12
|
# key: Ansible Group Name
|
@@ -17,11 +18,11 @@ Vagrant.configure(2) do |config|
|
|
17
18
|
config.spec.test_plan = [
|
18
19
|
{
|
19
20
|
'nodes' => /test_ansi/,
|
20
|
-
'flags' => '--format documentation --color --pattern serverspec/
|
21
|
+
'flags' => '--format documentation --color --pattern serverspec/ansi*'
|
21
22
|
},
|
22
23
|
{
|
23
24
|
'nodes' => /test_pansi/,
|
24
|
-
'flags' => '--format documentation --color --pattern serverspec/
|
25
|
+
'flags' => '--format documentation --color --pattern serverspec/pansi*'
|
25
26
|
}
|
26
27
|
]
|
27
28
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vagrant_spec/ansible_inventory'
|
4
|
-
require 'vagrant_spec/spec_helper'
|
5
4
|
require 'vagrant_spec/machine_data'
|
6
5
|
require 'vagrant_spec/config'
|
7
6
|
|
@@ -31,7 +30,6 @@ module VagrantSpec
|
|
31
30
|
|
32
31
|
def execute
|
33
32
|
return unless parse_opts
|
34
|
-
VagrantSpec::SpecHelper.new(@env).generate
|
35
33
|
unless @ansible_inventory == DEFAULTS['ansible_inventory']
|
36
34
|
VagrantSpec::AnsibleInventory.new(@env).generate
|
37
35
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
The init subcommand initializes state-based configuration for vagrant_spec.
|
2
2
|
|
3
|
-
It creates a spec_helper.rb file under the configured ServerSpec directory. This
|
4
|
-
file is used to setup ServerSpec backend configuration and ease ServerSpec
|
5
|
-
testing.
|
6
|
-
|
7
3
|
If the config.spec.ansible_inventory configuration directive is used within the
|
8
4
|
Vagrantfile, then init will generate a test inventory file
|
9
5
|
vagrantspec_inventory. This file can be used for ansible orchestration against
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'rspec'
|
4
|
+
require 'serverspec'
|
5
|
+
require 'specinfra'
|
6
|
+
require 'specinfra/backend'
|
4
7
|
|
5
8
|
require 'vagrant_spec/config'
|
6
9
|
require 'vagrant_spec/machine_finder'
|
@@ -47,18 +50,37 @@ module VagrantSpec
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
53
|
+
# Close existing SSH
|
54
|
+
def close_ssh
|
55
|
+
if ::Specinfra::Backend::Ssh.instance.get_config(:ssh)
|
56
|
+
::Specinfra::Backend::Ssh.instance.get_config(:ssh).close
|
57
|
+
::Specinfra::Backend::Ssh.instance.set_config(:ssh, nil)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Configures ServerSpec
|
62
|
+
#
|
63
|
+
# node [Vagrant::Machine]
|
64
|
+
def configure_serverspec(node)
|
65
|
+
set :backend, :ssh
|
66
|
+
host = node.ssh_info[:host].to_s
|
67
|
+
options = Net::SSH::Config.for(host)
|
68
|
+
options[:user] = node.ssh_info[:username].to_s
|
69
|
+
options[:keys] = node.ssh_info[:private_key_path][0].to_s
|
70
|
+
options[:port] = node.ssh_info[:port].to_s
|
71
|
+
|
72
|
+
set :host, host
|
73
|
+
set :ssh_options, options
|
74
|
+
end
|
75
|
+
|
50
76
|
# Execute a test_suite and return the code
|
51
77
|
#
|
52
78
|
# node [Vagrant::Machine]
|
53
79
|
# plan [Hash] item in the @config.spec.test_plan
|
54
|
-
#
|
55
|
-
# return [@ret_code]
|
56
80
|
def execute_plan_tests(node, plan)
|
57
81
|
@env.ui.info("[#{node.name}]")
|
58
|
-
|
59
|
-
|
60
|
-
ENV['VAGRANT_KEY'] = node.ssh_info[:private_key_path][0].to_s
|
61
|
-
ENV['VAGRANT_USER'] = node.ssh_info[:username].to_s
|
82
|
+
close_ssh
|
83
|
+
configure_serverspec(node)
|
62
84
|
plan['flags'].prepend "-I #{@config.spec.directory} "
|
63
85
|
ret_code = RSpec::Core::Runner.run(plan['flags'].split, $stderr, $stdout)
|
64
86
|
RSpec.clear_examples
|
data/lib/vagrant_spec/version.rb
CHANGED
data/spec/unit/spec_helper.rb
CHANGED
@@ -21,6 +21,8 @@ require 'vagrant_spec'
|
|
21
21
|
require 'unit/support/shared/base_context'
|
22
22
|
require 'unit/support/shared/virtualbox_context'
|
23
23
|
|
24
|
+
require 'serverspec'
|
25
|
+
|
24
26
|
# Build methods to retrieve plugins against VagrantSpec::Plugin.
|
25
27
|
#
|
26
28
|
# Example: get_commands(VagrantSpec::Plugin)
|
@@ -54,6 +56,9 @@ RSpec.shared_examples 'shared_mocks' do
|
|
54
56
|
EOF
|
55
57
|
end
|
56
58
|
|
59
|
+
# Silence ServerSpec
|
60
|
+
set :backend, :ssh
|
61
|
+
|
57
62
|
let(:mock_vf_obj) { double(Vagrant::Vagrantfile) }
|
58
63
|
let(:mock_ui) { double(Vagrant::UI) }
|
59
64
|
let(:mock_config) { double(Vagrant::Config) }
|
@@ -7,10 +7,6 @@ describe VagrantSpec::Command::Init do
|
|
7
7
|
include_context 'unit'
|
8
8
|
include_examples 'shared_mocks'
|
9
9
|
|
10
|
-
let(:mock_spec_helper) do
|
11
|
-
double(VagrantSpec::SpecHelper)
|
12
|
-
end
|
13
|
-
|
14
10
|
let(:mock_ansible_inventory) do
|
15
11
|
double(VagrantSpec::AnsibleInventory)
|
16
12
|
end
|
@@ -32,10 +28,8 @@ describe VagrantSpec::Command::Init do
|
|
32
28
|
|
33
29
|
def execute_proc
|
34
30
|
proc do
|
35
|
-
allow_any_instance_of(VagrantSpec::SpecHelper).to receive(:generate)
|
36
31
|
allow_any_instance_of(VagrantSpec::AnsibleInventory).to receive(:generate)
|
37
32
|
allow_any_instance_of(VagrantSpec::MachineData).to receive(:generate)
|
38
|
-
allow(mock_spec_helper).to receive(:generate)
|
39
33
|
allow(mock_ansible_inventory).to receive(:generate)
|
40
34
|
allow(mock_machine_data).to receive(:generate)
|
41
35
|
end
|
@@ -53,7 +47,6 @@ describe VagrantSpec::Command::Init do
|
|
53
47
|
def execute_protection_proc
|
54
48
|
proc do
|
55
49
|
allow(subject).to receive(:parse_opts) { 'not_nil' }
|
56
|
-
allow(VagrantSpec::SpecHelper).to receive(:new) { mock_spec_helper }
|
57
50
|
allow(VagrantSpec::AnsibleInventory).to receive(:new) do
|
58
51
|
mock_ansible_inventory
|
59
52
|
end
|
@@ -66,8 +59,6 @@ describe VagrantSpec::Command::Init do
|
|
66
59
|
it '#execute creates an instance of VagrantSpec::SpecHelper' do
|
67
60
|
execute_protection_proc.call
|
68
61
|
subject.ansible_inventory = {}
|
69
|
-
|
70
|
-
expect(mock_spec_helper).to receive(:generate)
|
71
62
|
expect(mock_ansible_inventory).to_not receive(:generate)
|
72
63
|
subject.execute
|
73
64
|
end
|
@@ -78,7 +69,6 @@ describe VagrantSpec::Command::Init do
|
|
78
69
|
execute_protection_proc.call
|
79
70
|
subject.ansible_inventory = { 'all' => /node/ }
|
80
71
|
|
81
|
-
expect(mock_spec_helper).to receive(:generate)
|
82
72
|
expect(mock_ansible_inventory).to receive(:generate)
|
83
73
|
subject.execute
|
84
74
|
end
|
@@ -38,6 +38,8 @@ describe VagrantSpec::TestPlan do
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
let(:mock_ssh_backend) { double(Specinfra::Backend::Ssh) }
|
42
|
+
|
41
43
|
##############################################################################
|
42
44
|
# Stubs
|
43
45
|
|
@@ -47,6 +49,8 @@ describe VagrantSpec::TestPlan do
|
|
47
49
|
allow_any_instance_of(VagrantSpec::MachineFinder)
|
48
50
|
.to receive(:machine) { double(Vagrant::Machine) }
|
49
51
|
|
52
|
+
allow(::Specinfra::Backend::Ssh).to receive(:instance) { mock_ssh_backend }
|
53
|
+
|
50
54
|
allow(RSpec::Core::Runner).to receive(:run) { 0 }
|
51
55
|
allow(iso_env).to receive(:ui)
|
52
56
|
allow(mock_node).to receive(:name)
|
@@ -59,9 +63,6 @@ describe VagrantSpec::TestPlan do
|
|
59
63
|
|
60
64
|
subject { VagrantSpec::TestPlan.new(iso_env) }
|
61
65
|
|
62
|
-
##############################################################################
|
63
|
-
# Testing #nodes
|
64
|
-
|
65
66
|
context 'when passing a Regexp object' do
|
66
67
|
it '#nodes calls match_nodes on a machine_finder instance' do
|
67
68
|
expect(subject.m_finder).to receive(:match_nodes)
|
@@ -81,6 +82,17 @@ describe VagrantSpec::TestPlan do
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
85
|
+
context 'when ssh config is truthy' do
|
86
|
+
it '#close_ssh closes the pre-existing SSH connection' do
|
87
|
+
ssh_obj = double(Object.new)
|
88
|
+
allow(mock_ssh_backend).to receive(:get_config).with(:ssh) { ssh_obj }
|
89
|
+
allow(mock_ssh_backend).to receive(:set_config)
|
90
|
+
expect(ssh_obj).to receive(:close)
|
91
|
+
expect(mock_ssh_backend).to receive(:set_config)
|
92
|
+
subject.close_ssh
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
84
96
|
##############################################################################
|
85
97
|
# Testing #execute_plan_tests
|
86
98
|
#
|
@@ -88,8 +100,16 @@ describe VagrantSpec::TestPlan do
|
|
88
100
|
# executes clear_examples. clear_examples modifies global state, so we must
|
89
101
|
# contain it.
|
90
102
|
|
103
|
+
def execute_plan_tests_proc
|
104
|
+
proc do
|
105
|
+
allow(subject).to receive(:close_ssh)
|
106
|
+
allow(subject).to receive(:configure_serverspec)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
91
110
|
it '#execute_plan_tests runs the RSPec tests' do
|
92
111
|
in_sub_process do
|
112
|
+
execute_plan_tests_proc.call
|
93
113
|
expect(RSpec::Core::Runner).to receive(:run)
|
94
114
|
subject.execute_plan_tests(mock_node, mock_plan[0])
|
95
115
|
end
|
@@ -97,8 +117,16 @@ describe VagrantSpec::TestPlan do
|
|
97
117
|
|
98
118
|
it '#execute adds the spec.directory to the load path' do
|
99
119
|
in_sub_process do
|
120
|
+
execute_plan_tests_proc.call
|
100
121
|
subject.execute_plan_tests(mock_node, mock_plan[0])
|
101
|
-
expect(subject.test_plan[0]['flags']).to
|
122
|
+
expect(subject.test_plan[0]['flags']).to match(/-I serverspec/)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it '#execute calls close_ssh and configure_serverspec' do
|
127
|
+
in_sub_process do
|
128
|
+
expect(subject).to receive(:close_ssh)
|
129
|
+
expect(subject).to receive(:configure_serverspec)
|
102
130
|
end
|
103
131
|
end
|
104
132
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant_spec
|
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
|
- Demitri
|
@@ -127,17 +127,15 @@ files:
|
|
127
127
|
- lib/vagrant_spec/config/base.rb
|
128
128
|
- lib/vagrant_spec/machine_data.rb
|
129
129
|
- lib/vagrant_spec/machine_finder.rb
|
130
|
-
- lib/vagrant_spec/spec_helper.rb
|
131
130
|
- lib/vagrant_spec/templates/init_help
|
132
|
-
- lib/vagrant_spec/templates/spec_helper.erb
|
133
131
|
- lib/vagrant_spec/templates/test_help
|
134
132
|
- lib/vagrant_spec/templates/vagrantspec_inventory.erb
|
135
133
|
- lib/vagrant_spec/test_plan.rb
|
136
134
|
- lib/vagrant_spec/utils.rb
|
137
135
|
- lib/vagrant_spec/version.rb
|
138
136
|
- scripts/poor_mans_smoke_test.sh
|
139
|
-
- serverspec/
|
140
|
-
- serverspec/
|
137
|
+
- serverspec/ansible_spec.rb
|
138
|
+
- serverspec/pansible_spec.rb
|
141
139
|
- site.yml
|
142
140
|
- spec/unit/spec_helper.rb
|
143
141
|
- spec/unit/vagrant_spec_spec.rb
|
@@ -150,7 +148,6 @@ files:
|
|
150
148
|
- spec/unit/vagrant_spec_test/config_spec/base_spec.rb
|
151
149
|
- spec/unit/vagrant_spec_test/machine_data_spec.rb
|
152
150
|
- spec/unit/vagrant_spec_test/machine_finder_spec.rb
|
153
|
-
- spec/unit/vagrant_spec_test/spec_helper_spec.rb
|
154
151
|
- spec/unit/vagrant_spec_test/test_plan_spec.rb
|
155
152
|
- spec/unit/vagrant_spec_test/utils_spec.rb
|
156
153
|
- vagrant_spec.gemspec
|
@@ -190,6 +187,5 @@ test_files:
|
|
190
187
|
- spec/unit/vagrant_spec_test/config_spec/base_spec.rb
|
191
188
|
- spec/unit/vagrant_spec_test/machine_data_spec.rb
|
192
189
|
- spec/unit/vagrant_spec_test/machine_finder_spec.rb
|
193
|
-
- spec/unit/vagrant_spec_test/spec_helper_spec.rb
|
194
190
|
- spec/unit/vagrant_spec_test/test_plan_spec.rb
|
195
191
|
- spec/unit/vagrant_spec_test/utils_spec.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'erb'
|
4
|
-
|
5
|
-
require 'vagrant_spec/config'
|
6
|
-
require 'vagrant_spec/utils'
|
7
|
-
|
8
|
-
module VagrantSpec
|
9
|
-
# Generates a spec_helper.rb for integration testing
|
10
|
-
#
|
11
|
-
# env [Vagrant::Environment]
|
12
|
-
class SpecHelper
|
13
|
-
include VagrantSpec::Utils
|
14
|
-
def initialize(env)
|
15
|
-
@env = env
|
16
|
-
@directory = VagrantSpec::Config.load(env).spec.directory
|
17
|
-
end
|
18
|
-
|
19
|
-
# Generate the spec_helper.rb
|
20
|
-
def generate
|
21
|
-
create_directory
|
22
|
-
return if File.exist? spec_helper_path
|
23
|
-
sh = ERB.new(IO.read(spec_helper_template), 0, '<>').result binding
|
24
|
-
IO.write(spec_helper_path, sh)
|
25
|
-
end
|
26
|
-
|
27
|
-
# return [String]
|
28
|
-
def create_directory
|
29
|
-
Dir.mkdir @directory unless Dir.exist? @directory
|
30
|
-
end
|
31
|
-
|
32
|
-
# return [String]
|
33
|
-
def spec_helper_path
|
34
|
-
File.join(@directory, 'spec_helper.rb')
|
35
|
-
end
|
36
|
-
|
37
|
-
# return [String]
|
38
|
-
def spec_helper_template
|
39
|
-
File.join(template_dir, 'spec_helper.erb')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'serverspec'
|
4
|
-
require 'net/ssh'
|
5
|
-
require 'rspec'
|
6
|
-
|
7
|
-
###################
|
8
|
-
# Serverspec Config
|
9
|
-
|
10
|
-
set :backend, :ssh
|
11
|
-
|
12
|
-
host = ENV['VAGRANT_HOST']
|
13
|
-
options = Net::SSH::Config.for(host)
|
14
|
-
options[:user] = ENV['VAGRANT_USER']
|
15
|
-
options[:keys] = ENV['VAGRANT_KEY']
|
16
|
-
options[:port] = ENV['VAGRANT_PORT']
|
17
|
-
|
18
|
-
set :host, host
|
19
|
-
set :ssh_options, options
|
data/serverspec/fail_spec.rb
DELETED
data/serverspec/ssh_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'vagrant_spec/spec_helper'
|
5
|
-
require 'vagrant_spec/utils'
|
6
|
-
|
7
|
-
describe VagrantSpec::SpecHelper do
|
8
|
-
include_context 'unit'
|
9
|
-
include_examples 'shared_mocks'
|
10
|
-
|
11
|
-
subject { VagrantSpec::SpecHelper.new(iso_env) }
|
12
|
-
|
13
|
-
context 'when @directory does not exist' do
|
14
|
-
it '#create_directory creates the directory' do
|
15
|
-
allow(Dir).to receive(:exist?) { false }
|
16
|
-
allow(Dir).to receive(:mkdir)
|
17
|
-
expect(Dir).to receive(:mkdir)
|
18
|
-
|
19
|
-
subject.create_directory
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when @directory does exist' do
|
24
|
-
it '#create_directory does not create the directory' do
|
25
|
-
allow(Dir).to receive(:exist?) { true }
|
26
|
-
allow(Dir).to receive(:mkdir)
|
27
|
-
expect(Dir).not_to receive(:mkdir)
|
28
|
-
|
29
|
-
subject.create_directory
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it '#spec_helper_path returns serverspec/spec_helper.rb' do
|
34
|
-
expect(subject.spec_helper_path).to eq('serverspec/spec_helper.rb')
|
35
|
-
end
|
36
|
-
|
37
|
-
it '#spec_helper_template includes vagrant_spec/templates/spec_helper.erb' do
|
38
|
-
result = subject.spec_helper_template
|
39
|
-
expect(result).to match(%r{vagrant_spec/templates/spec_helper.erb})
|
40
|
-
end
|
41
|
-
end
|