kitchen-pester 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6dd5d95959debd9b11eda6ae7c8f64743caa746
4
+ data.tar.gz: 9687d3a142d76fefca803a16a9e36448213fe323
5
+ SHA512:
6
+ metadata.gz: e0c655e48af2bc3a07d488c54a43c109ce0b7f4a7839c13bd9edb6674536fb323340e5bcb03ff36ad3a53ccbf170c85a5de7f2e2e14d89250736706338f8f956
7
+ data.tar.gz: fdefaf5b33370b7a32fdbe3902cf1b8b791f944f9adc069abdbba91f2ed96bd6b131a08dfec2ea7d24708a474f53dcd76a43c85a8df44520ce67f21545b47eec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kitchen-pester.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Steven Murawski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Kitchen::Pester
2
+
3
+ Execute [Pester](https://github.com/pester/Pester) tests right from Test-Kitchen, without having to transit the Busser layer.
4
+
5
+ ## Usage
6
+
7
+ Either
8
+ ```
9
+ gem install kitchen-pester
10
+ ```
11
+ or include
12
+ ```
13
+ gem 'kitchen-pester'
14
+ ```
15
+ in your Gemfile.
16
+
17
+ In your .kitchen.yml include
18
+ ```
19
+ verifier:
20
+ name: pester
21
+ ```
22
+ This can be a top-level declaration, a per-node declaration, or a per-suite declaration.
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it ( https://github.com/[my-github-username]/kitchen-pester/fork )
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -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
+ require 'kitchen/verifier/pester_version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kitchen-pester"
8
+ spec.version = Kitchen::Verifier::PESTER_VERSION
9
+ spec.authors = ["Steven Murawski"]
10
+ spec.email = ["steven.murawski@gmail.com"]
11
+ spec.summary = 'Test-Kitchen verifier for Pester.'
12
+ spec.description = 'Skip all that Busser stuff and jump right into Pester.'
13
+ spec.homepage = "https://github.com/smurawski/kitchen-pester"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "test-kitchen", "> 1.4.0.rc"
24
+ end
@@ -0,0 +1,157 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Steven Murawski (<steven.murawski@gmail.com>)
4
+ #
5
+ # Copyright (C) 2015, Steven Murawski
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require "kitchen/verifier/base"
20
+ require 'kitchen/verifier/pester_version'
21
+ require 'pry'
22
+
23
+ module Kitchen
24
+
25
+ module Verifier
26
+
27
+ class Pester < Kitchen::Verifier::Base
28
+
29
+ kitchen_verifier_api_version 1
30
+
31
+ plugin_version Kitchen::Verifier::PESTER_VERSION
32
+
33
+ # Creates a new Verifier object using the provided configuration data
34
+ # which will be merged with any default configuration.
35
+ #
36
+ # @param config [Hash] provided verifier configuration
37
+ def initialize(config = {})
38
+ init_config(config)
39
+ end
40
+
41
+ # Creates a temporary directory on the local workstation into which
42
+ # verifier related files and directories can be copied or created. The
43
+ # contents of this directory will be copied over to the instance before
44
+ # invoking the verifier's run command. After this method completes, it
45
+ # is expected that the contents of the sandbox is complete and ready for
46
+ # copy to the remote instance.
47
+ #
48
+ # **Note:** any subclasses would be well advised to call super first when
49
+ # overriding this method, for example:
50
+ #
51
+ # @example overriding `#create_sandbox`
52
+ #
53
+ # class MyVerifier < Kitchen::Verifier::Base
54
+ # def create_sandbox
55
+ # super
56
+ # # any further file copies, preparations, etc.
57
+ # end
58
+ # end
59
+ def create_sandbox
60
+ super
61
+ #binding.pry
62
+ prepare_pester_tests
63
+ #stage test scripts
64
+ end
65
+
66
+ # Generates a command string which will install and configure the
67
+ # verifier software on an instance. If no work is required, then `nil`
68
+ # will be returned.
69
+ #
70
+ # @return [String] a command string
71
+ def install_command
72
+ return if local_suite_files.empty?
73
+
74
+ cmd = <<-CMD
75
+ cd #{File.join(config[:root_path],'suites/pester' )}
76
+ if (-not (get-module -list pester)) {
77
+ if (-not (get-module PsGet)){
78
+ iex (new-object Net.WebClient).DownloadString('http://bit.ly/GetPsGet')
79
+ }
80
+ Import-Module PsGet
81
+ Install-Module Pester
82
+ }
83
+ CMD
84
+ wrap_shell_code(Util.outdent!(cmd))
85
+ end
86
+
87
+ # Generates a command string which will perform any data initialization
88
+ # or configuration required after the verifier software is installed
89
+ # but before the sandbox has been transferred to the instance. If no work
90
+ # is required, then `nil` will be returned.
91
+ #
92
+ # @return [String] a command string
93
+ def init_command
94
+ end
95
+
96
+ # Generates a command string which will perform any commands or
97
+ # configuration required just before the main verifier run command but
98
+ # after the sandbox has been transferred to the instance. If no work is
99
+ # required, then `nil` will be returned.
100
+ #
101
+ # @return [String] a command string
102
+ def prepare_command
103
+ end
104
+
105
+ # Generates a command string which will invoke the main verifier
106
+ # command on the prepared instance. If no work is required, then `nil`
107
+ # will be returned.
108
+ #
109
+ # @return [String] a command string
110
+ def run_command
111
+ return if local_suite_files.empty?
112
+
113
+ wrap_shell_code(Util.outdent!(<<-CMD))
114
+ cd #{File.join(config[:root_path],'suites/pester' )}
115
+ invoke-pester
116
+ CMD
117
+ end
118
+
119
+ #private
120
+
121
+ # Returns an Array of test suite filenames for the related suite currently
122
+ # residing on the local workstation. Any special provisioner-specific
123
+ # directories (such as a Chef roles/ directory) are excluded.
124
+ #
125
+ # @return [Array<String>] array of suite files
126
+ # @api private
127
+
128
+ def local_suite_files
129
+ base = File.join(config[:test_base_path], config[:suite_name])
130
+ glob = File.join(base, "pester/**/*")
131
+ Dir.glob(glob).reject do |f|
132
+ File.directory?(f)
133
+ end
134
+ end
135
+
136
+ # Copies all test suite files into the suites directory in the sandbox.
137
+ #
138
+ # @api private
139
+ def prepare_pester_tests
140
+ base = File.join(config[:test_base_path], config[:suite_name])
141
+
142
+ local_suite_files.each do |src|
143
+ dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ""))
144
+ FileUtils.mkdir_p(File.dirname(dest))
145
+ FileUtils.cp(src, dest, :preserve => true)
146
+ end
147
+ end
148
+
149
+ # @return [String] path to suites directory under sandbox path
150
+ # @api private
151
+ def sandbox_suites_dir
152
+ File.join(sandbox_path, "suites")
153
+ end
154
+
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,5 @@
1
+ module Kitchen
2
+ module Verifier
3
+ PESTER_VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-pester
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Murawski
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: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-kitchen
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>'
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.0.rc
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>'
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.0.rc
55
+ description: Skip all that Busser stuff and jump right into Pester.
56
+ email:
57
+ - steven.murawski@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - kitchen-pester.gemspec
67
+ - lib/kitchen/verifier/pester.rb
68
+ - lib/kitchen/verifier/pester_version.rb
69
+ homepage: https://github.com/smurawski/kitchen-pester
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.4
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Test-Kitchen verifier for Pester.
93
+ test_files: []
94
+ has_rdoc: