guard-kitchen 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +18 -6
- data/guard-kitchen.gemspec +4 -4
- data/lib/guard/kitchen.rb +20 -17
- data/lib/guard/kitchen/version.rb +3 -3
- data/spec/unit/guard/kitchen_spec.rb +43 -10
- metadata +22 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dfeb795d12e08f8e17ddd8f1cfcfd5184fbc4561be41748102141da8bb0b3b9c
|
4
|
+
data.tar.gz: 75c0f96231f369a7da283caa2f23d4786450f174e968736a7907f94ec25119a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bad773e7416e6a7f4f63f2c7746cc289f4d3bad1eef1d5d3087b2faf41734df1d67531d05580772c66aa62b1efdb5e465ccbc66767f507b8075b1ad9ac95c287
|
7
|
+
data.tar.gz: 9a73daacb4ddb78de78d3fcaf4945570807e7d63bf121e43ebb562c7473d4c03d36ce0a546cca89769be68afdf5284a7763b4f1efb18723ef2545df4e3c2864b
|
data/README.md
CHANGED
@@ -22,10 +22,22 @@ From within a cookbook:
|
|
22
22
|
|
23
23
|
$ guard init kitchen
|
24
24
|
|
25
|
-
##
|
25
|
+
## Status
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
This software project is no longer under active development as it has no active maintainers. The software may continue to work for some or all use cases, but issues filed in GitHub will most likely not be triaged. If a new maintainer is interested in working on this project please come chat with us in #test-kitchen on Chef Community Slack.
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
```
|
32
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
33
|
+
you may not use this file except in compliance with the License.
|
34
|
+
You may obtain a copy of the License at
|
35
|
+
|
36
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
37
|
+
|
38
|
+
Unless required by applicable law or agreed to in writing, software
|
39
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
40
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
41
|
+
See the License for the specific language governing permissions and
|
42
|
+
limitations under the License.
|
43
|
+
```
|
data/guard-kitchen.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "guard-kitchen"
|
8
8
|
spec.version = Guard::Kitchen::VERSION
|
9
9
|
spec.authors = ["Adam Jacob"]
|
10
|
-
spec.email = ["adam@
|
10
|
+
spec.email = ["adam@chef.io"]
|
11
11
|
spec.description = %q{Guard plugin for test kitchen}
|
12
12
|
spec.summary = %q{Guard plugin for test kitchen}
|
13
|
-
spec.homepage = "http://github.com/
|
13
|
+
spec.homepage = "http://github.com/test-kitchen/guard-kitchen"
|
14
14
|
spec.license = "Apache 2"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "guard"
|
21
|
+
spec.add_dependency "guard", "> 2.0.0"
|
22
22
|
spec.add_dependency "mixlib-shellout"
|
23
|
-
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/guard/kitchen.rb
CHANGED
@@ -15,11 +15,17 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require "guard"
|
18
|
-
require "guard/
|
18
|
+
require "guard/plugin"
|
19
19
|
require "mixlib/shellout"
|
20
20
|
|
21
21
|
module Guard
|
22
|
-
class Kitchen <
|
22
|
+
class Kitchen < Plugin
|
23
|
+
def initialize(options = {})
|
24
|
+
super
|
25
|
+
# you can still access the watchers with options[:watchers]
|
26
|
+
# rest of the implementation...
|
27
|
+
end
|
28
|
+
|
23
29
|
def start
|
24
30
|
::Guard::UI.info("Guard::Kitchen is starting")
|
25
31
|
cmd = Mixlib::ShellOut.new("kitchen create", :timeout => 10800)
|
@@ -36,21 +42,18 @@ module Guard
|
|
36
42
|
end
|
37
43
|
|
38
44
|
def stop
|
39
|
-
::Guard::UI.
|
40
|
-
::
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# # Sometimes, we leave the occasional shell process unreaped!
|
52
|
-
# Process.waitall
|
53
|
-
#end
|
45
|
+
::Guard::UI.info("Guard::Kitchen is stopping")
|
46
|
+
cmd = Mixlib::ShellOut.new("kitchen destroy", :timeout => 10800)
|
47
|
+
cmd.live_stream = STDOUT
|
48
|
+
cmd.run_command
|
49
|
+
begin
|
50
|
+
cmd.error!
|
51
|
+
Notifier.notify('Kitchen destroyed', :title => 'test-kitchen', :image => :success)
|
52
|
+
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
53
|
+
Notifier.notify('Kitchen destroy failed', :title => 'test-kitchen', :image => :failed)
|
54
|
+
::Guard::UI.info("Kitchen failed with #{e.to_s}")
|
55
|
+
throw :task_has_failed
|
56
|
+
end
|
54
57
|
end
|
55
58
|
|
56
59
|
def reload
|
@@ -1,6 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'guard/kitchen'
|
3
3
|
|
4
|
+
# Breaking change in guard 2.x for RSPEC caused by the fact
|
5
|
+
# we didn't initialize guard's internals before Guard::Kitchen.new()
|
6
|
+
# See https://github.com/guard/guard/issues/693
|
7
|
+
#
|
8
|
+
# The recommended way fix it is to install guard-compat and use that
|
9
|
+
# instead of real guard for testing. That adds a development dependency,
|
10
|
+
# so for now just monkey patch to stub out Guard::Plugin#initialize
|
11
|
+
module Guard
|
12
|
+
class Plugin
|
13
|
+
def initialize(options={})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# End of Monkey Patch
|
18
|
+
|
4
19
|
describe "Guard::Kitchen" do
|
5
20
|
let(:kitchen) do
|
6
21
|
Guard::Kitchen.new
|
@@ -13,11 +28,11 @@ describe "Guard::Kitchen" do
|
|
13
28
|
@shellout.stub(:run_command)
|
14
29
|
@shellout.stub(:error!)
|
15
30
|
Guard::UI.stub(:info).with('Guard::Kitchen is starting')
|
16
|
-
Mixlib::ShellOut.stub(:new).with("kitchen create").and_return(@shellout)
|
31
|
+
Mixlib::ShellOut.stub(:new).with("kitchen create", :timeout => 10800).and_return(@shellout)
|
17
32
|
end
|
18
33
|
|
19
34
|
it "runs kitchen create" do
|
20
|
-
Mixlib::ShellOut.should_receive(:new).with("kitchen create").and_return(@shellout)
|
35
|
+
Mixlib::ShellOut.should_receive(:new).with("kitchen create", :timeout => 10800).and_return(@shellout)
|
21
36
|
Guard::UI.should_receive(:info).with('Guard::Kitchen is starting')
|
22
37
|
Guard::Notifier.should_receive(:notify).with('Kitchen created', :title => 'test-kitchen', :image => :success)
|
23
38
|
kitchen.start
|
@@ -33,11 +48,29 @@ describe "Guard::Kitchen" do
|
|
33
48
|
end
|
34
49
|
|
35
50
|
describe "stop" do
|
36
|
-
|
37
|
-
|
38
|
-
|
51
|
+
before(:each) do
|
52
|
+
@shellout = double('shellout')
|
53
|
+
@shellout.stub(:live_stream=).with(STDOUT)
|
54
|
+
@shellout.stub(:run_command)
|
55
|
+
@shellout.stub(:error!)
|
56
|
+
Guard::UI.stub(:info).with('Guard::Kitchen is stopping')
|
57
|
+
Mixlib::ShellOut.stub(:new).with("kitchen destroy", :timeout => 10800).and_return(@shellout)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "runs kitchen destroy" do
|
61
|
+
Mixlib::ShellOut.should_receive(:new).with("kitchen destroy", :timeout => 10800).and_return(@shellout)
|
62
|
+
Guard::UI.should_receive(:info).with('Guard::Kitchen is stopping')
|
63
|
+
Guard::Notifier.should_receive(:notify).with('Kitchen destroyed', :title => 'test-kitchen', :image => :success)
|
39
64
|
kitchen.stop
|
40
65
|
end
|
66
|
+
|
67
|
+
it "notifies on failure" do
|
68
|
+
@shellout.should_receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
69
|
+
Guard::UI.should_receive(:info).with('Guard::Kitchen is stopping')
|
70
|
+
Guard::Notifier.should_receive(:notify).with('Kitchen destroy failed', :title => 'test-kitchen', :image => :failed)
|
71
|
+
Guard::UI.should_receive(:info).with('Kitchen failed with Mixlib::ShellOut::ShellCommandFailed')
|
72
|
+
expect { kitchen.stop }.to throw_symbol(:task_has_failed)
|
73
|
+
end
|
41
74
|
end
|
42
75
|
|
43
76
|
describe "reload" do
|
@@ -56,14 +89,14 @@ describe "Guard::Kitchen" do
|
|
56
89
|
@shellout.stub(:error!)
|
57
90
|
Guard::UI.stub(:info).with('Guard::Kitchen is running all tests')
|
58
91
|
Guard::Notifier.stub(:notify)
|
59
|
-
Mixlib::ShellOut.stub(:new).with("kitchen verify").and_return(@shellout)
|
92
|
+
Mixlib::ShellOut.stub(:new).with("kitchen verify", :timeout => 10800).and_return(@shellout)
|
60
93
|
end
|
61
94
|
|
62
95
|
it "runs kitchen verify" do
|
63
96
|
Guard::UI.should_receive(:info).with('Guard::Kitchen is running all tests')
|
64
97
|
Guard::UI.should_receive(:info).with('Kitchen verify succeeded')
|
65
98
|
Guard::Notifier.should_receive(:notify).with('Kitchen verify succeeded', :title => 'test-kitchen', :image => :success)
|
66
|
-
Mixlib::ShellOut.should_receive(:new).with("kitchen verify").and_return(@shellout)
|
99
|
+
Mixlib::ShellOut.should_receive(:new).with("kitchen verify", :timeout => 10800).and_return(@shellout)
|
67
100
|
kitchen.run_all
|
68
101
|
end
|
69
102
|
|
@@ -89,7 +122,7 @@ describe "Guard::Kitchen" do
|
|
89
122
|
Guard::UI.should_receive(:info).with("Guard::Kitchen is running suites: default")
|
90
123
|
Guard::UI.should_receive(:info).with("Kitchen verify succeeded for: default")
|
91
124
|
Guard::Notifier.stub(:notify).with("Kitchen verify succeeded for: default", :title => 'test-kitchen', :image => :success)
|
92
|
-
Mixlib::ShellOut.should_receive(:new).with("kitchen verify '(default)-.+' -p").and_return(@shellout)
|
125
|
+
Mixlib::ShellOut.should_receive(:new).with("kitchen verify '(default)-.+' -p", :timeout=>10800).and_return(@shellout)
|
93
126
|
kitchen.run_on_changes(["test/integration/default/bats/foo.bats"])
|
94
127
|
end
|
95
128
|
|
@@ -97,7 +130,7 @@ describe "Guard::Kitchen" do
|
|
97
130
|
Guard::UI.should_receive(:info).with("Guard::Kitchen is running suites: default, monkey")
|
98
131
|
Guard::UI.should_receive(:info).with("Kitchen verify succeeded for: default, monkey")
|
99
132
|
Guard::Notifier.stub(:notify).with("Kitchen verify succeeded for: default, monkey", :title => 'test-kitchen', :image => :success)
|
100
|
-
Mixlib::ShellOut.should_receive(:new).with("kitchen verify '(default|monkey)-.+' -p").and_return(@shellout)
|
133
|
+
Mixlib::ShellOut.should_receive(:new).with("kitchen verify '(default|monkey)-.+' -p", :timeout=>10800).and_return(@shellout)
|
101
134
|
kitchen.run_on_changes(["test/integration/default/bats/foo.bats","test/integration/monkey/bats/foo.bats"])
|
102
135
|
end
|
103
136
|
end
|
@@ -115,7 +148,7 @@ describe "Guard::Kitchen" do
|
|
115
148
|
Guard::UI.should_receive(:info).with("Guard::Kitchen is running converge for all suites")
|
116
149
|
Guard::UI.should_receive(:info).with("Kitchen converge succeeded")
|
117
150
|
Guard::Notifier.stub(:notify).with("Kitchen converge succeeded", :title => 'test-kitchen', :image => :success)
|
118
|
-
Mixlib::ShellOut.should_receive(:new).with('kitchen converge').and_return(@shellout)
|
151
|
+
Mixlib::ShellOut.should_receive(:new).with('kitchen converge', :timeout => 10800).and_return(@shellout)
|
119
152
|
kitchen.run_on_changes(["recipes/default.rb"])
|
120
153
|
end
|
121
154
|
end
|
metadata
CHANGED
@@ -1,88 +1,79 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Jacob
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: guard
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 2.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 2.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mixlib-shellout
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Guard plugin for test kitchen
|
79
70
|
email:
|
80
|
-
- adam@
|
71
|
+
- adam@chef.io
|
81
72
|
executables: []
|
82
73
|
extensions: []
|
83
74
|
extra_rdoc_files: []
|
84
75
|
files:
|
85
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
86
77
|
- Gemfile
|
87
78
|
- Guardfile
|
88
79
|
- LICENSE
|
@@ -94,36 +85,28 @@ files:
|
|
94
85
|
- lib/guard/kitchen/version.rb
|
95
86
|
- spec/spec_helper.rb
|
96
87
|
- spec/unit/guard/kitchen_spec.rb
|
97
|
-
homepage: http://github.com/
|
88
|
+
homepage: http://github.com/test-kitchen/guard-kitchen
|
98
89
|
licenses:
|
99
90
|
- Apache 2
|
91
|
+
metadata: {}
|
100
92
|
post_install_message:
|
101
93
|
rdoc_options: []
|
102
94
|
require_paths:
|
103
95
|
- lib
|
104
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
97
|
requirements:
|
107
|
-
- -
|
98
|
+
- - ">="
|
108
99
|
- !ruby/object:Gem::Version
|
109
100
|
version: '0'
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
hash: -4378409848140944374
|
113
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
102
|
requirements:
|
116
|
-
- -
|
103
|
+
- - ">="
|
117
104
|
- !ruby/object:Gem::Version
|
118
105
|
version: '0'
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
hash: -4378409848140944374
|
122
106
|
requirements: []
|
123
|
-
|
124
|
-
rubygems_version: 1.8.25
|
107
|
+
rubygems_version: 3.0.2
|
125
108
|
signing_key:
|
126
|
-
specification_version:
|
109
|
+
specification_version: 4
|
127
110
|
summary: Guard plugin for test kitchen
|
128
111
|
test_files:
|
129
112
|
- spec/spec_helper.rb
|