chef-apply 0.4.6 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -7
- data/chef-apply.gemspec +3 -3
- data/lib/chef_apply/version.rb +1 -1
- metadata +3 -38
- data/README.md +0 -62
- data/spec/fixtures/custom_config.toml +0 -2
- data/spec/integration/chef-run_spec.rb +0 -41
- data/spec/integration/fixtures/chef_help.out +0 -70
- data/spec/integration/fixtures/chef_version.out +0 -1
- data/spec/integration/spec_helper.rb +0 -55
- data/spec/spec_helper.rb +0 -154
- data/spec/support/matchers/output_to_terminal.rb +0 -36
- data/spec/unit/action/base_spec.rb +0 -60
- data/spec/unit/action/converge_target/ccr_failure_mapper_spec.rb +0 -106
- data/spec/unit/action/converge_target_spec.rb +0 -400
- data/spec/unit/action/generate_local_policy_spec.rb +0 -114
- data/spec/unit/action/generate_temp_cookbook/recipe_lookup_spec.rb +0 -122
- data/spec/unit/action/generate_temp_cookbook/temp_cookbook_spec.rb +0 -198
- data/spec/unit/action/generate_temp_cookbook_spec.rb +0 -73
- data/spec/unit/action/install_chef/minimum_chef_version_spec.rb +0 -90
- data/spec/unit/action/install_chef_spec.rb +0 -164
- data/spec/unit/cli/options_spec.rb +0 -75
- data/spec/unit/cli/validation_spec.rb +0 -81
- data/spec/unit/cli_spec.rb +0 -475
- data/spec/unit/config_spec.rb +0 -70
- data/spec/unit/file_fetcher_spec.rb +0 -40
- data/spec/unit/fixtures/multi-error.out +0 -2
- data/spec/unit/log_spec.rb +0 -37
- data/spec/unit/startup_spec.rb +0 -323
- data/spec/unit/target_host/linux_spec.rb +0 -57
- data/spec/unit/target_host/windows_spec.rb +0 -43
- data/spec/unit/target_host_spec.rb +0 -297
- data/spec/unit/target_resolver_spec.rb +0 -380
- data/spec/unit/telemeter/sender_spec.rb +0 -140
- data/spec/unit/telemeter_spec.rb +0 -191
- data/spec/unit/text/error_translation_spec.rb +0 -109
- data/spec/unit/ui/error_printer_spec.rb +0 -196
- data/spec/unit/ui/terminal_spec.rb +0 -119
- data/spec/unit/version_spec.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a188a9cccc61b37402d6850df1ffa3020d123b88b71d04788e14487f2f0e28b9
|
4
|
+
data.tar.gz: a9f619cb737762fd8c8e06c6152e714708c91b51e4a4de8cd373c20b81ccdb32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a790c11592c8e5e6d2abf3456513913cf9e0438a71dc74fb31946d3278ed1f167cb136d781d890db054cb2200794bc83cb3a9f3ed656e6e1d8d6e4624397403a
|
7
|
+
data.tar.gz: 24442c737983071f465757df9da2231c99dda4bbbfb0ab2999e60c1910e3c49bfb2cbaa4312bc091d46bf5998fa8483a9755c534edc0b8329f2a7e792046f042
|
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
source "https://rubygems.org"
|
19
19
|
gemspec
|
20
|
-
|
20
|
+
|
21
21
|
group :development do
|
22
22
|
gem "chefstyle"
|
23
23
|
gem "rake", ">= 10.1.0"
|
@@ -37,9 +37,3 @@ group :debug do
|
|
37
37
|
gem "pry-stack_explorer"
|
38
38
|
gem "rb-readline"
|
39
39
|
end
|
40
|
-
|
41
|
-
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
42
|
-
|
43
|
-
# If you want to load debugging tools into the bundle exec sandbox,
|
44
|
-
# add these additional dependencies into Gemfile.local
|
45
|
-
eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
|
data/chef-apply.gemspec
CHANGED
@@ -31,10 +31,10 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.license = "Apache-2.0"
|
32
32
|
spec.required_ruby_version = ">= 2.5.0"
|
33
33
|
|
34
|
-
spec.files = %w{Rakefile LICENSE
|
34
|
+
spec.files = %w{Rakefile LICENSE warning.txt} +
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
36
36
|
Dir.glob("*.gemspec") +
|
37
|
-
Dir.glob("{bin,i18n,lib
|
37
|
+
Dir.glob("{bin,i18n,lib}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
38
38
|
spec.bindir = "bin"
|
39
39
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
40
40
|
spec.require_paths = ["lib"]
|
@@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
# localization gem...
|
49
49
|
spec.add_dependency "toml-rb" # This isn't ideal because mixlib-config uses 'tomlrb'
|
50
50
|
# but that library does not support a dumper
|
51
|
-
spec.add_dependency "train", "~> 3.0" # remote connection management over ssh, winrm
|
51
|
+
spec.add_dependency "train-core", "~> 3.0" # remote connection management over ssh, winrm
|
52
52
|
spec.add_dependency "train-winrm" # winrm transports were pulled out into this plugin
|
53
53
|
spec.add_dependency "pastel" # A color library
|
54
54
|
spec.add_dependency "tty-spinner" # Pretty output for status updates in the CLI
|
data/lib/chef_apply/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-apply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: train
|
98
|
+
name: train-core
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
@@ -236,7 +236,6 @@ extra_rdoc_files: []
|
|
236
236
|
files:
|
237
237
|
- Gemfile
|
238
238
|
- LICENSE
|
239
|
-
- README.md
|
240
239
|
- Rakefile
|
241
240
|
- bin/chef-run
|
242
241
|
- chef-apply.gemspec
|
@@ -280,40 +279,6 @@ files:
|
|
280
279
|
- lib/chef_apply/ui/terminal.rb
|
281
280
|
- lib/chef_apply/ui/terminal/job.rb
|
282
281
|
- lib/chef_apply/version.rb
|
283
|
-
- spec/fixtures/custom_config.toml
|
284
|
-
- spec/integration/chef-run_spec.rb
|
285
|
-
- spec/integration/fixtures/chef_help.out
|
286
|
-
- spec/integration/fixtures/chef_version.out
|
287
|
-
- spec/integration/spec_helper.rb
|
288
|
-
- spec/spec_helper.rb
|
289
|
-
- spec/support/matchers/output_to_terminal.rb
|
290
|
-
- spec/unit/action/base_spec.rb
|
291
|
-
- spec/unit/action/converge_target/ccr_failure_mapper_spec.rb
|
292
|
-
- spec/unit/action/converge_target_spec.rb
|
293
|
-
- spec/unit/action/generate_local_policy_spec.rb
|
294
|
-
- spec/unit/action/generate_temp_cookbook/recipe_lookup_spec.rb
|
295
|
-
- spec/unit/action/generate_temp_cookbook/temp_cookbook_spec.rb
|
296
|
-
- spec/unit/action/generate_temp_cookbook_spec.rb
|
297
|
-
- spec/unit/action/install_chef/minimum_chef_version_spec.rb
|
298
|
-
- spec/unit/action/install_chef_spec.rb
|
299
|
-
- spec/unit/cli/options_spec.rb
|
300
|
-
- spec/unit/cli/validation_spec.rb
|
301
|
-
- spec/unit/cli_spec.rb
|
302
|
-
- spec/unit/config_spec.rb
|
303
|
-
- spec/unit/file_fetcher_spec.rb
|
304
|
-
- spec/unit/fixtures/multi-error.out
|
305
|
-
- spec/unit/log_spec.rb
|
306
|
-
- spec/unit/startup_spec.rb
|
307
|
-
- spec/unit/target_host/linux_spec.rb
|
308
|
-
- spec/unit/target_host/windows_spec.rb
|
309
|
-
- spec/unit/target_host_spec.rb
|
310
|
-
- spec/unit/target_resolver_spec.rb
|
311
|
-
- spec/unit/telemeter/sender_spec.rb
|
312
|
-
- spec/unit/telemeter_spec.rb
|
313
|
-
- spec/unit/text/error_translation_spec.rb
|
314
|
-
- spec/unit/ui/error_printer_spec.rb
|
315
|
-
- spec/unit/ui/terminal_spec.rb
|
316
|
-
- spec/unit/version_spec.rb
|
317
282
|
- warning.txt
|
318
283
|
homepage: https://github.com/chef/chef-apply
|
319
284
|
licenses:
|
data/README.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Chef Apply
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/chef-apply.svg)](https://badge.fury.io/rb/chef-apply)
|
3
|
-
|
4
|
-
The ad-hoc execution tool for the Chef ecosystem.
|
5
|
-
|
6
|
-
**Umbrella Project**: [Workstation](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-workstation.md)
|
7
|
-
|
8
|
-
* **[Project State](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** Active
|
9
|
-
* **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** 14 days
|
10
|
-
* **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** 14 days
|
11
|
-
|
12
|
-
## Installation
|
13
|
-
|
14
|
-
Add this line to your application's Gemfile:
|
15
|
-
|
16
|
-
```ruby
|
17
|
-
gem 'chef-apply'
|
18
|
-
```
|
19
|
-
|
20
|
-
And then execute:
|
21
|
-
|
22
|
-
$ bundle
|
23
|
-
|
24
|
-
Or install it yourself as:
|
25
|
-
|
26
|
-
$ gem install chef-apply
|
27
|
-
|
28
|
-
|
29
|
-
## Contributing/Development
|
30
|
-
|
31
|
-
Please read our [Community Contributions Guidelines](https://docs.chef.io/community_contributions.html), and ensure you are signing all your commits with DCO sign-off.
|
32
|
-
|
33
|
-
The general development process is:
|
34
|
-
|
35
|
-
1. Fork this repo and clone it to your workstation.
|
36
|
-
2. Create a feature branch for your change.
|
37
|
-
3. Write code and tests.
|
38
|
-
4. Push your feature branch to GitHub and open a pull request against master.
|
39
|
-
|
40
|
-
Once your repository is set up, you can start working on the code. We do utilize RSpec for test driven development, so you'll need to get a development environment running. Follow the above procedure ("Installing from Git") to get your local copy of the source running.
|
41
|
-
|
42
|
-
# License
|
43
|
-
|
44
|
-
| | |
|
45
|
-
|:---------------------|:-----------------------------------------|
|
46
|
-
| **Copyright:** | Copyright 2018, Chef Software, Inc.
|
47
|
-
| **License:** | Apache License, Version 2.0
|
48
|
-
|
49
|
-
```
|
50
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
51
|
-
you may not use this file except in compliance with the License.
|
52
|
-
You may obtain a copy of the License at
|
53
|
-
|
54
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
55
|
-
|
56
|
-
Unless required by applicable law or agreed to in writing, software
|
57
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
58
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
59
|
-
See the License for the specific language governing permissions and
|
60
|
-
limitations under the License.
|
61
|
-
```
|
62
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2018 Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "spec_helper"
|
19
|
-
require "integration/spec_helper"
|
20
|
-
require "chef_apply/cli"
|
21
|
-
require "chef_apply/version"
|
22
|
-
|
23
|
-
RSpec.describe "chef_appl" do
|
24
|
-
context "help output" do
|
25
|
-
context "at the top level" do
|
26
|
-
["-h", "--help", ""].each do |arg|
|
27
|
-
it "#{arg} displays correct help" do
|
28
|
-
expect { run_cli_with(arg) }.to output(fixture_content("chef_help")).to_stdout
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "version output" do
|
35
|
-
["-v", "--version"].each do |arg|
|
36
|
-
it "#{arg} displays correct version" do
|
37
|
-
expect { run_cli_with(arg) }.to output(fixture_content("chef_version")).to_stdout
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
Chef Run is a tool to execute ad-hoc tasks using Chef.
|
2
|
-
|
3
|
-
chef-run <TARGET[S]> <RESOURCE> <RESOURCE_NAME> [PROPERTIES] [FLAGS]
|
4
|
-
|
5
|
-
Runs a single <RESOURCE> on the specified <TARGET[S]>.
|
6
|
-
[PROPERTIES] should be specified as key=value.
|
7
|
-
|
8
|
-
For example:
|
9
|
-
|
10
|
-
chef-run web01 service nginx action=restart
|
11
|
-
chef-run web01,web02 service nginx action=restart
|
12
|
-
chef-run web0[1:2] service nginx action=restart
|
13
|
-
|
14
|
-
chef-run <TARGET[S]> <RECIPE> [FLAGS]
|
15
|
-
|
16
|
-
Runs a single recipe located at <RECIPE> on the specified <TARGET[S]>.
|
17
|
-
|
18
|
-
For example:
|
19
|
-
|
20
|
-
chef-run web01 path/to/cookbook/recipe.rb
|
21
|
-
chef-run web01,web02 path/to/cookbook
|
22
|
-
chef-run web0[1:2] cookbook_name
|
23
|
-
chef-run web01 cookbook_name::recipe_name
|
24
|
-
|
25
|
-
ARGUMENTS:
|
26
|
-
<TARGET[S]> The hosts or IPs to target. Can also be an SSH or WinRM URLs
|
27
|
-
in the form:
|
28
|
-
|
29
|
-
ssh://[USERNAME]@example.com[:PORT]
|
30
|
-
<RESOURCE> A Chef resource, such as 'user' or 'package'
|
31
|
-
<RESOURCE_NAME> The name, usually used to specify what 'thing' to set up with
|
32
|
-
the resource. For example, given resource 'user', 'name' would be
|
33
|
-
the name of the user you wanted to create.
|
34
|
-
<RECIPE> The recipe to converge. This can be provided as one of:
|
35
|
-
1. Full path to a recipe file
|
36
|
-
2. Cookbook name. First we check the working directory for this
|
37
|
-
cookbook, then we check in the chef repository path. If a
|
38
|
-
cookbook is found we run the default recipe.
|
39
|
-
3. This behaves similarly to 'cookbook name' above, but it also allows
|
40
|
-
you to specify which recipe to use from the cookbook.
|
41
|
-
|
42
|
-
FLAGS:
|
43
|
-
--chef-license ACCEPTANCE Accept the license for this product and any contained products ('accept', 'accept-no-persist', or 'accept-silent')
|
44
|
-
-c, --config PATH Location of config file. Default: $HOME/.chef-workstation/config.toml
|
45
|
-
--cookbook-repo-paths PATH Comma separated list of cookbook repository paths.
|
46
|
-
-h, --help Show help and usage for `chef-run`
|
47
|
-
-i, --identity-file PATH SSH identity file to use when connecting. Keys loaded into ssh-agent will also be used.
|
48
|
-
--[no-]install Install Chef client on the target host(s) if it is not installed.
|
49
|
-
This defaults to enabled - the installation will be performed
|
50
|
-
if there is no Chef client on the target(s).
|
51
|
-
--password <PASSWORD> Password to use for authentication to the target(s). The same
|
52
|
-
password will be used for all targets.
|
53
|
-
-p, --protocol <PROTOCOL> The protocol to use for connecting to targets.
|
54
|
-
The default is 'ssh', and it can be changed in config.toml by
|
55
|
-
setting 'connection.default_protocol' to a supported option.
|
56
|
-
--[no-]ssl Use SSL for WinRM. Current default: false
|
57
|
-
--[no-]ssl-verify Verify peer certificate when using SSL for WinRM
|
58
|
-
Use --ssl-no-verify when using SSL for WinRM and
|
59
|
-
the remote host is using a self-signed certificate.
|
60
|
-
Current default: true
|
61
|
-
--[no-]sudo Whether to use root permissions on the target. Default: true
|
62
|
-
--sudo-command <COMMAND> Command to use for administrative/root access. Defaults to 'sudo'.
|
63
|
-
--sudo-options 'OPTIONS...' Options to use with the sudo command. If there are multiple flags,
|
64
|
-
quote them. For example: --sudo-options '-H -P -s'
|
65
|
-
--sudo-password <PASSWORD> Password to use with the sudo command. This must be provided if
|
66
|
-
password is required for sudo on the target(s). The same sudo password
|
67
|
-
will be used for all targets.
|
68
|
-
--user <USER> Username to use for authentication to the target(s). The same
|
69
|
-
username will be used for all targets.
|
70
|
-
-v, --version Show the current version of Chef Run.
|
@@ -1 +0,0 @@
|
|
1
|
-
chef-run: $VERSION
|
@@ -1,55 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2018 Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "chef_apply/startup"
|
19
|
-
require "chef_apply/version"
|
20
|
-
|
21
|
-
# Create the chef configuration directory and touch the config
|
22
|
-
# file.
|
23
|
-
# this makes sure our output doesn't include
|
24
|
-
# an extra line telling us that it's created,
|
25
|
-
# causing the first integration test to execute to fail on
|
26
|
-
# CI.
|
27
|
-
# TODO this is not ideal... let's look at
|
28
|
-
# testing the output correctly in both cases,
|
29
|
-
# possible forcing a specific test that will also create
|
30
|
-
# the directory to run first.
|
31
|
-
dir = File.join(Dir.home, ".chef-workstation")
|
32
|
-
conf = File.join(dir, "config.toml")
|
33
|
-
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
34
|
-
FileUtils.touch(conf) unless File.exist?(conf)
|
35
|
-
|
36
|
-
# Simple wrapper that runs the CLI and prevents it
|
37
|
-
# from aborting all tests with a SystemExit.
|
38
|
-
# We could shell out, but this will run a little faster as we
|
39
|
-
# accumulate more things to test - and will work better to get
|
40
|
-
# accurate simplecov coverage reporting.
|
41
|
-
# usage:
|
42
|
-
# expect {run_with_cli("blah")}.to output("blah").to_stdout
|
43
|
-
def run_cli_with(args)
|
44
|
-
ChefApply::Startup.new(args.split(" ")).run
|
45
|
-
rescue SystemExit
|
46
|
-
end
|
47
|
-
|
48
|
-
def fixture_content(name)
|
49
|
-
content = File.read(File.join("spec/integration/fixtures", "#{name}.out"))
|
50
|
-
# Replace $VERSION if present - this is updated automatically, so we can't include
|
51
|
-
# the literal version value in the fixture without
|
52
|
-
# having expeditor update it there too...
|
53
|
-
content.gsub("$VERSION", ChefApply::VERSION)
|
54
|
-
.gsub("$HOME", Dir.home)
|
55
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2018 Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "bundler/setup"
|
19
|
-
require "simplecov"
|
20
|
-
require "rspec/expectations"
|
21
|
-
require "support/matchers/output_to_terminal"
|
22
|
-
|
23
|
-
# class << Kernel
|
24
|
-
# alias :_require :require
|
25
|
-
# def require(*args)
|
26
|
-
#
|
27
|
-
# show = false
|
28
|
-
# args.each do |a|
|
29
|
-
# if a =~ /chef_apply.*/
|
30
|
-
# show = true
|
31
|
-
# break
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# $stderr.puts "from #{File.basename(caller[1])}: require: %s" % [args.inspect] if show
|
36
|
-
# _require(*args)
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# alias :_load :load
|
40
|
-
# def load(*args)
|
41
|
-
# show = false
|
42
|
-
# args.each do |a|
|
43
|
-
# if a =~ /chef_apply.*/
|
44
|
-
# show = true
|
45
|
-
# break
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
# $stderr.puts "from #{File.basename(caller[1])}: load: %s" % [args.inspect] if show
|
49
|
-
# _load(*args)
|
50
|
-
# end
|
51
|
-
#
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# module Kernel
|
55
|
-
# def require(*args)
|
56
|
-
# Kernel.require(*args)
|
57
|
-
# end
|
58
|
-
# def load(*args)
|
59
|
-
# Kernel.load(*args)
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
|
63
|
-
RemoteExecResult = Struct.new(:exit_status, :stdout, :stderr)
|
64
|
-
|
65
|
-
class ChefApply::MockReporter
|
66
|
-
def update(msg); ChefApply::UI::Terminal.output msg; end
|
67
|
-
|
68
|
-
def success(msg); ChefApply::UI::Terminal.output "SUCCESS: #{msg}"; end
|
69
|
-
|
70
|
-
def error(msg); ChefApply::UI::Terminal.output "FAILURE: #{msg}"; end
|
71
|
-
end
|
72
|
-
|
73
|
-
RSpec::Matchers.define :exit_with_code do |expected_code|
|
74
|
-
actual_code = nil
|
75
|
-
match do |block|
|
76
|
-
begin
|
77
|
-
block.call
|
78
|
-
rescue SystemExit => e
|
79
|
-
actual_code = e.status
|
80
|
-
end
|
81
|
-
actual_code && actual_code == expected_code
|
82
|
-
end
|
83
|
-
|
84
|
-
failure_message do |block|
|
85
|
-
result = actual.nil? ? " did not call exit" : " called exit(#{actual_code})"
|
86
|
-
"expected exit(#{expected_code}) but it #{result}."
|
87
|
-
end
|
88
|
-
|
89
|
-
failure_message_when_negated do |block|
|
90
|
-
"expected exit(#{expected_code}) but it did."
|
91
|
-
end
|
92
|
-
|
93
|
-
description do
|
94
|
-
"expect exit(#{expected_code})"
|
95
|
-
end
|
96
|
-
|
97
|
-
supports_block_expectations do
|
98
|
-
true
|
99
|
-
end
|
100
|
-
end
|
101
|
-
# TODO would read better to make this a custom matcher.
|
102
|
-
# Simulates a recursive string lookup on the Text object
|
103
|
-
#
|
104
|
-
# assert_string_lookup("tree.tree.tree.leaf", "a returned string")
|
105
|
-
# TODO this can be more cleanly expressed as a custom matcher...
|
106
|
-
def assert_string_lookup(key, retval = "testvalue")
|
107
|
-
it "should look up string #{key}" do
|
108
|
-
top_level_method, *call_seq = key.split(".")
|
109
|
-
terminal_method = call_seq.pop
|
110
|
-
tmock = double
|
111
|
-
# Because ordering is important
|
112
|
-
# (eg calling errors.hello is different from hello.errors),
|
113
|
-
# we need to add this individually instead of using
|
114
|
-
# `receive_messages`, which doesn't appear to give a way to
|
115
|
-
# guarantee ordering
|
116
|
-
expect(ChefApply::Text).to receive(top_level_method)
|
117
|
-
.and_return(tmock)
|
118
|
-
call_seq.each do |m|
|
119
|
-
expect(tmock).to receive(m).ordered.and_return(tmock)
|
120
|
-
end
|
121
|
-
expect(tmock).to receive(terminal_method)
|
122
|
-
.ordered.and_return(retval)
|
123
|
-
subject.call
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
RSpec.configure do |config|
|
128
|
-
# Enable flags like --only-failures and --next-failure
|
129
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
130
|
-
config.run_all_when_everything_filtered = true
|
131
|
-
config.filter_run :focus
|
132
|
-
|
133
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
134
|
-
config.disable_monkey_patching!
|
135
|
-
|
136
|
-
config.expect_with :rspec do |c|
|
137
|
-
c.syntax = :expect
|
138
|
-
end
|
139
|
-
|
140
|
-
config.mock_with :rspec do |mocks|
|
141
|
-
mocks.verify_partial_doubles = true
|
142
|
-
end
|
143
|
-
|
144
|
-
config.before(:all) do
|
145
|
-
ChefApply::Log.setup File::NULL, :error
|
146
|
-
ChefApply::UI::Terminal.init(File.open(File::NULL, "w"))
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
if ENV["CIRCLE_ARTIFACTS"]
|
151
|
-
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
|
152
|
-
SimpleCov.coverage_dir(dir)
|
153
|
-
end
|
154
|
-
SimpleCov.start
|