vagrant-serverspec 1.2 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/WINDOWS_README.md +6 -0
- data/lib/vagrant-serverspec/config.rb +23 -1
- data/lib/vagrant-serverspec/error.rb +6 -0
- data/lib/vagrant-serverspec/provisioner.rb +28 -3
- data/lib/vagrant-serverspec/version.rb +1 -1
- data/locales/en.yml +6 -0
- data/vagrant-serverspec.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65483a9e7c94f56f1c4f258cd9cd769e0b1b2e4a
|
4
|
+
data.tar.gz: 8c26e878a228aed6398d33aa803e2ff9d60d31dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a241aa690d2ff2148aa21500195e700cc7febbe1d74baad959f091d7e2ed76a4bd3eaae9d4b3ba1007bf8718eb1a86731e63ac9f124f9b3e87b3898a0f22af
|
7
|
+
data.tar.gz: 18b81cb4445213f3f99ac3d7596aa2919859d6ef87cfd4a25973914bfcb94bb65a761845a68d66115a69e8415c396d334924c8fb90276220dc5dffe69e952676
|
data/README.md
CHANGED
@@ -42,7 +42,12 @@ Vagrant.configure('2') do |config|
|
|
42
42
|
EOF
|
43
43
|
|
44
44
|
config.vm.provision :serverspec do |spec|
|
45
|
+
# pattern for specfiles to search
|
45
46
|
spec.pattern = '*_spec.rb'
|
47
|
+
# disable error if no specfile was found ( usefull with dynamic specfile retrieving through another provisionner like Ansible Galaxy => specfiles can be saved into ansible role repository for example ). Default: true
|
48
|
+
spec.error_no_spec_files = false
|
49
|
+
# save result into html an report, saved into a 'rspec_html_reports' directory. Default: false
|
50
|
+
spec.html_output = true
|
46
51
|
end
|
47
52
|
end
|
48
53
|
```
|
data/WINDOWS_README.md
CHANGED
@@ -34,7 +34,13 @@ Vagrant.configure("2") do |config|
|
|
34
34
|
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
|
35
35
|
|
36
36
|
config.vm.provision :serverspec do |spec|
|
37
|
+
# pattern for specfiles to search
|
37
38
|
spec.pattern = '*_spec.rb'
|
39
|
+
# disable error if no specfile was found ( usefull with dynamic specfile retrieving through another provisionner like Ansible Galaxy => specfiles can be saved into ansible role repository for example ). Default: true
|
40
|
+
spec.error_no_spec_files = false
|
41
|
+
# save result into html an report, saved into a 'rspec_html_reports' directory. Default: false
|
42
|
+
spec.html_output = true
|
43
|
+
|
38
44
|
end
|
39
45
|
|
40
46
|
end
|
@@ -2,18 +2,38 @@ module VagrantPlugins
|
|
2
2
|
module ServerSpec
|
3
3
|
class Config < Vagrant.plugin('2', :config)
|
4
4
|
attr_accessor :spec_files
|
5
|
+
attr_accessor :spec_pattern
|
6
|
+
attr_accessor :error_no_spec_files_found
|
7
|
+
attr_accessor :html_output_format
|
5
8
|
|
6
9
|
def initialize
|
7
10
|
super
|
8
11
|
@spec_files = UNSET_VALUE
|
12
|
+
@html_output_format = UNSET_VALUE
|
13
|
+
@error_no_spec_files_found = UNSET_VALUE
|
9
14
|
end
|
10
15
|
|
11
16
|
def pattern=(pat)
|
12
17
|
@spec_files = Dir.glob(pat)
|
18
|
+
@spec_pattern = pat
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_no_spec_files=(warn_spec)
|
22
|
+
if [true, false].include? warn_spec
|
23
|
+
@error_no_spec_files_found = warn_spec
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def html_output=(html_out)
|
28
|
+
if [true, false].include? html_out
|
29
|
+
@html_output_format = html_out
|
30
|
+
end
|
13
31
|
end
|
14
32
|
|
15
33
|
def finalize!
|
16
34
|
@spec_files = [] if @spec_files == UNSET_VALUE
|
35
|
+
@html_output_format = false if @html_output_format == UNSET_VALUE
|
36
|
+
@error_no_spec_files_found = true if @error_no_spec_files_found == UNSET_VALUE
|
17
37
|
end
|
18
38
|
|
19
39
|
def validate(machine)
|
@@ -28,7 +48,9 @@ module VagrantPlugins
|
|
28
48
|
errors << I18n.t('vagrant.config.serverspec.missing_spec_files', files: missing_files.join(', '))
|
29
49
|
end
|
30
50
|
|
31
|
-
|
51
|
+
if @error_no_spec_files_found
|
52
|
+
{ 'serverspec provisioner' => errors }
|
53
|
+
end
|
32
54
|
end
|
33
55
|
end
|
34
56
|
end
|
@@ -3,5 +3,11 @@ module Vagrant
|
|
3
3
|
class ServerSpecFailed < VagrantError
|
4
4
|
error_key(:serverspec_failed)
|
5
5
|
end
|
6
|
+
class ServerSpecFailedHtml < VagrantError
|
7
|
+
error_key(:serverspec_failed_html)
|
8
|
+
end
|
9
|
+
class ServerSpecFilesNotFound < VagrantError
|
10
|
+
error_key(:serverspec_filesnotfound)
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
@@ -7,6 +7,8 @@ module VagrantPlugins
|
|
7
7
|
def initialize(machine, config)
|
8
8
|
super
|
9
9
|
@spec_files = config.spec_files
|
10
|
+
@spec_pattern = config.spec_pattern
|
11
|
+
@error_no_spec_files_found = config.error_no_spec_files_found
|
10
12
|
end
|
11
13
|
|
12
14
|
def provision
|
@@ -66,9 +68,32 @@ module VagrantPlugins
|
|
66
68
|
# same process
|
67
69
|
RSpec.clear_examples
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
@spec_files = Dir.glob(@spec_pattern)
|
72
|
+
raise Vagrant::Errors::ServerSpecFilesNotFound if @spec_files.length == 0 and @error_no_spec_files_found
|
73
|
+
|
74
|
+
if config.html_output_format
|
75
|
+
require 'json'
|
76
|
+
require 'rspec'
|
77
|
+
require 'rspec_html_formatter'
|
78
|
+
config_rspec = RSpec.configuration
|
79
|
+
formatter = RspecHtmlFormatter.new(config_rspec.output_stream)
|
80
|
+
|
81
|
+
# create reporter with RspecHtmlFormatter
|
82
|
+
reporter = RSpec::Core::Reporter.new(config_rspec)
|
83
|
+
config_rspec.instance_variable_set(:@reporter, reporter)
|
84
|
+
|
85
|
+
# api may not be stable, make sure lock down Rspec version
|
86
|
+
loader = config_rspec.send(:formatter_loader)
|
87
|
+
notifications = loader.send(:notifications_for, RspecHtmlFormatter)
|
88
|
+
reporter.register_listener(formatter, *notifications)
|
89
|
+
|
90
|
+
status = RSpec::Core::Runner.run(@spec_files)
|
91
|
+
raise Vagrant::Errors::ServerSpecFailedHtml if status != 0
|
92
|
+
else
|
93
|
+
status = RSpec::Core::Runner.run(@spec_files)
|
94
|
+
raise Vagrant::Errors::ServerSpecFailed if status != 0
|
95
|
+
end
|
96
|
+
|
72
97
|
end
|
73
98
|
|
74
99
|
private
|
data/locales/en.yml
CHANGED
@@ -11,3 +11,9 @@ en:
|
|
11
11
|
serverspec_failed: |-
|
12
12
|
ServerSpec failed to complete successfully. Any error output should be
|
13
13
|
visible above. Please fix these errors and try again.
|
14
|
+
serverspec_failed_html: |-
|
15
|
+
ServerSpec failed to complete successfully. Any error output should be
|
16
|
+
visible above. Please fix these errors and try again. Please look into 'rspec_html_reports'
|
17
|
+
directory to see errors into 'overview.html' file
|
18
|
+
serverspec_filesnotfound: |-
|
19
|
+
ServerSpec failed to find any spec files.
|
data/vagrant-serverspec.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
#add onlly dependencies for winrm without nokogiri
|
22
22
|
gem.add_runtime_dependency 'winrm', '~> 2.1', '>= 2.1'
|
23
23
|
gem.add_runtime_dependency 'os', '~> 0.9.6'
|
24
|
+
gem.add_runtime_dependency 'rspec_html_formatter', '~> 0.3', '>= 0.3.1'
|
24
25
|
|
25
26
|
gem.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.2'
|
26
27
|
gem.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Voorhis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serverspec
|
@@ -64,6 +64,26 @@ dependencies:
|
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 0.9.6
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec_html_formatter
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.3'
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.3.1
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.3'
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.3.1
|
67
87
|
- !ruby/object:Gem::Dependency
|
68
88
|
name: bundler
|
69
89
|
requirement: !ruby/object:Gem::Requirement
|