diff options
author | Tim Smith <tsmith@chef.io> | 2019-12-02 10:58:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 10:58:57 -0800 |
commit | 6220bccff3a34b8fe29d286e8fb7918482d735f4 (patch) | |
tree | 73f34132c32d52f3973fa4f00b0a817d75d6ea29 | |
parent | e86091d683144669e0b8d24f4558821f318769ab (diff) | |
parent | 1fd65e645492f8ee386dbc324c4d2b400c74c194 (diff) | |
download | chef-6220bccff3a34b8fe29d286e8fb7918482d735f4.tar.gz |
Merge pull request #9128 from chef/testing
Boilerplate and testing backports from master
365 files changed, 2681 insertions, 3795 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b4eac50d28..ab9841707a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,5 @@ # Order is important. The last matching pattern has the most precedence. -* @chef/client-maintainers -.expeditor/** @chef/jex-team -README.md @chef/docs-team -RELEASE_NOTES.md @chef/docs-team +* @chef/chef-infra-reviewers @chef/chef-infra-approvers @chef/chef-infra-owners +.expeditor/ @chef/jex-team +*.md @chef/docs-team diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/BUG_TEMPLATE.md index c6f0984993..9b62551d8b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/BUG_TEMPLATE.md @@ -1,4 +1,10 @@ -<!--- +--- +name: 🐛 Bug Report +about: If something isn't working as expected 🤔. +labels: "Status: Untriaged" +--- + +<!--- !!!!!! NOTE: CHEF CLIENT BUGS ONLY !!!!!! This issue tracker is for the code contained within this repo -- `chef-client`, base `knife` functionality (not @@ -18,7 +24,7 @@ plugins), `chef-apply`, `chef-solo`, `chef-client -z`, etc. <!--- Tell us which version of chef-client you are using (see below for Server+ChefDK bugs). --> ## Platform Version -<!--- Tell us which Operating System distribution and version chef-client is running on. --> +<!--- Tell us which operating system distribution and version chef-client is running on. --> ## Replication Case <!--- Tell us what steps to take to replicate your problem. See [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) diff --git a/.github/ISSUE_TEMPLATE/DESIGN_PROPOSAL.md b/.github/ISSUE_TEMPLATE/DESIGN_PROPOSAL.md new file mode 100644 index 0000000000..9f4a958fea --- /dev/null +++ b/.github/ISSUE_TEMPLATE/DESIGN_PROPOSAL.md @@ -0,0 +1,40 @@ +--- +name: Design Proposal +about: I have a significant change I would like to propose and discuss before starting +labels: "Status: Untriaged" +--- + +### When a Change Needs a Design Proposal + +A design proposal should be opened any time a change meets one of the following qualifications: + +- Significantly changes the user experience of a project in a way that impacts users. +- Significantly changes the underlying architecture of the project in a way that impacts other developers. +- Changes the development or testing process of the project such as a change of CI systems or test frameworks. + +### Why We Use This Process + +- Allows all interested parties (including any community member) to discuss large impact changes to a project. +- Serves as a durable paper trail for discussions regarding project architecture. +- Forces design discussions to occur before PRs are created. +- Reduces PR refactoring and rejected PRs. + +--- + +<!--- Proposal description and rationale. --> + +## Motivation + +<!--- + As a <<user_profile>>, + I want to <<functionality>>, + so that <<benefit>>. + --> + +## Specification + +<!--- A detailed description of the planned implementation. --> + +## Downstream Impact + +<!--- Which other tools will be impacted by this work? --> diff --git a/.github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST_TEMPLATE.md b/.github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..65bf5a06b1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +--- +name: 🚀 Enhancement Request +about: I have a suggestion (and may want to implement it 🙂)! +labels: "Status: Untriaged" +--- + +### Describe the Enhancement: +<!--- What you are trying to achieve that you can't? --> + +### Describe the Need: +<!--- What kind of user do you believe would utilize this enhancement, and how many users might want this functionality --> + +### Current Alternative +<!--- Is there a current alternative that you can utilize to workaround the lack of this enhancement --> + +### Can We Help You Implement This?: +<!--- The best way to ensure your enhancement is built is to help implement the enhancement yourself. If you're interested in helping out we'd love to give you a hand to make this possible. Let us know if there's something you need. --> diff --git a/.github/ISSUE_TEMPLATE/RESOURCE_REQUEST.md b/.github/ISSUE_TEMPLATE/RESOURCE_REQUEST.md new file mode 100644 index 0000000000..50a8e2af0d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/RESOURCE_REQUEST.md @@ -0,0 +1,26 @@ +--- +name: 💪 Resource Request +about: I have a suggestion for a new resource in Chef (and may want to implement it 🙌)! +labels: "Status: Untriaged" +--- + +### Core Chef Resource Checklist + +Before suggesting a resource for inclusion please make sure your suggestion meets these criteria for resources built into Chef: + - [ ] Automates an operating system component that ships by default on systems such as authentication, raid, disk partitions, firewalls, containers, or virtualization systems. + - [ ] Does not attempt automate 3rd party applications such as database, web, or application servers, which are best suited for cookbooks due to their fast moving nature. + +### Describe the resource: +<!--- Tell us about the resource --> + +### Why should this be included out of the box?: +<!--- Why do you believe this is best suited to be included in the chef-client vs. a cookbook? --> + +### What operating systems would it run on? +<!--- Is this a general purpose resource that would run on every operating systems or is it specific to an OS such as Linux, macOS, or Windows? --> + +### Current cookbook implementation: +<!--- Is there currently a cookbook that ships with this resource? If so please let us know. We'll need full permission from the authors and a compatible license in order to move a resource from a cookbook. --> + +### Can We Help You Implement This?: +<!--- The best way to move a resource into Chef is to help move it yourself. If you're interested in helping out we'd love to give you a hand to make this possible. Let us know if there's something you need. --> diff --git a/.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md b/.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md new file mode 100644 index 0000000000..68c5664792 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md @@ -0,0 +1,12 @@ +--- +name: 🤗 Support Question +about: If you have a question 💬, please check out our Slack! +--- + +We use GitHub issues to track bugs and feature requests. If you need help please post to our Mailing List or join the Chef Community Slack. + + * Chef Community Slack at http://community-slack.chef.io/. + * Chef Mailing List https://discourse.chef.io/ + + + Support issues opened here will be closed and redirected to Slack or Discourse. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6abaccc467..0000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,15 +0,0 @@ -### Description - -[Please describe what this change achieves] - -### Issues Resolved - -[List any existing issues this PR resolves, or any Discourse or -StackOverflow discussion that's relevant] - -### Check List - -- [ ] New functionality includes tests -- [ ] All tests pass -- [ ] RELEASE\_NOTES.md has been updated if required (not required for bugfixes, required for API changes) -- [ ] All commits have been signed-off for the Developer Certificate of Origin. See <https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco> diff --git a/.github/lock.yml b/.github/lock.yml index 66d5d4962c..5edc4037bd 100644 --- a/.github/lock.yml +++ b/.github/lock.yml @@ -1 +1 @@ -daysUntilLock: 60 +daysUntilLock: 14 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a65f0d1c45..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,397 +0,0 @@ -language: ruby -cache: bundler -dist: trusty - -# Early warning system to catch if Rubygems breaks something -before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem --version - # travis may preinstall a bundler gem which is later than the one which we pin, which may totally hose us, so we preemtively - # uninstall anything they may have installed here. if they haven't installed anything then we have to ignore the failure - # to uninstall the default bundler that ships embedded in ruby itself. - - rvm @global do gem uninstall bundler -a -x || true - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - - bundle --version - - rm -f .bundle/config - -before_script: - # force all .rspec tests into progress display to reduce line count - - echo --color > .rspec - - echo -fp >> .rspec - # necessary for sudo: true tests, ingore failures on tests invoked with sudo: false - - sudo sed -i -e 's/^Defaults\tsecure_path.*$//' /etc/sudoers - -# do not run expensive spec tests on PRs, only on branches -branches: - only: - - master - - chef-14 - - chef-13 - -env: - global: - - FORCE_FFI_YAJL=ext - - CHEF_LICENSE=accept-no-persist - -matrix: - include: - - env: - INTEGRATION_SPECS_24: 1 - rvm: 2.4.5 - sudo: true - script: sudo -E $(which bundle) exec rake spec:integration; - bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - - env: - INTEGRATION_SPECS_25: 1 - rvm: 2.5.5 - sudo: true - script: sudo -E $(which bundle) exec rake spec:integration; - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - INTEGRATION_SPECS_26: 1 - rvm: 2.6.2 - sudo: true - script: sudo -E $(which bundle) exec rake spec:integration; - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - FUNCTIONAL_SPECS_24: 1 - rvm: 2.4.5 - sudo: true - # the travis apt proxy screws with our functional testing something fierce - script: sudo rm -f /etc/apt/apt.conf.d/99-travis-apt-proxy; sudo -E $(which bundle) exec rake spec:functional; - bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - - env: - FUNCTIONAL_SPECS_25: 1 - rvm: 2.5.5 - sudo: true - # the travis apt proxy screws with our functional testing something fierce - script: sudo rm -f /etc/apt/apt.conf.d/99-travis-apt-proxy; sudo -E $(which bundle) exec rake spec:functional; - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - FUNCTIONAL_SPECS_26: 1 - rvm: 2.6.2 - sudo: true - script: sudo rm -f /etc/apt/apt.conf.d/99-travis-apt-proxy; sudo -E $(which bundle) exec rake spec:functional; - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - UNIT_SPECS_24: 1 - rvm: 2.4.5 - sudo: true - script: - - sudo -E $(which bundle) exec rake spec:unit; - - sudo -E $(which bundle) exec rake component_specs - bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - - env: - UNIT_SPECS_25: 1 - rvm: 2.5.5 - sudo: true - script: - - sudo -E $(which bundle) exec rake spec:unit; - - sudo -E $(which bundle) exec rake component_specs - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - UNIT_SPECS_26: 1 - rvm: 2.6.2 - sudo: true - script: - - sudo -E $(which bundle) exec rake spec:unit; - - sudo -E $(which bundle) exec rake component_specs - bundler_args: --without ci docgen guard integration omnibus_package --frozen - - env: - CHEFSTYLE: 1 - rvm: 2.5.5 - script: bundle exec rake style - # also remove integration / external tests - bundler_args: --without ci docgen guard integration omnibus_package --frozen - # - # External tests - # - - env: - TEST_GEM: sethvargo/chef-sugar - script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake - rvm: 2.5.5 - - env: - - PEDANT_OPTS=--skip-oc_id - - TEST_GEM=chef/chef-zero - - CHEF_FS=true - script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake pedant - rvm: 2.5.5 - - env: - TEST_GEM: chef/cheffish - script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec - rvm: 2.5.5 - - env: - TEST_GEM: chefspec/chefspec - script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake - rvm: 2.5.5 - - env: - TEST_GEM: chef/knife-windows - script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake unit_spec - rvm: 2.5.5 - ### START TEST KITCHEN ONLY ### - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-amazonlinux-2 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - AMAZON=2 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-amazonlinux - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - AMAZON=201X - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-ubuntu-1604 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - UBUNTU=16.04 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-ubuntu-1804 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - UBUNTU=18.04 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-debian-8 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - DEBIAN=8 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-debian-9 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - DEBIAN=9 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-debian-10 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - DEBIAN=10 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-centos-6 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - CENTOS=6 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-centos-7 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - CENTOS=7 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-fedora-latest - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - FEDORA=latest - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test end-to-end-opensuse-leap - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - OPENSUSELEAP=42 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - sudo: required - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - rvm @global do gem uninstall bundler -a -x || true - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - - sudo apt-get update - - sudo apt-get -y install squid3 git curl - env: - - PROXY_TESTS_DIR=proxy_tests/files/default/scripts - - PROXY_TESTS_REPO=$PROXY_TESTS_DIR/repo - script: - - bundle exec chef-client --version - - git clone https://github.com/chef/proxy_tests.git - - rvmsudo -E bundle exec bash $PROXY_TESTS_DIR/run_tests.sh chef_client \* \* /tmp/out.txt - after_script: - - cat /tmp/out.txt - - sudo cat /var/log/squid3/cache.log - - sudo cat /var/log/squid3/access.log - # Use test-kitchen to launch a centos docker container to run the full rspec tests against. This catches - # errors in travis, before PRs are merged, hopefully before they become errors in jenkins. - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test rspec-centos-7 - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - RSPEC_CENTOS=7 - - KITCHEN_YAML=kitchen.yml - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test rspec-opensuse-leap - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - RSPEC_OPENSUSELEAP=42 - - KITCHEN_YAML=kitchen.yml - allow_failures: - - rvm: 2.5.5 - services: docker - sudo: required - gemfile: kitchen-tests/Gemfile - before_install: - - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) - - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2) - before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - cd kitchen-tests - script: - - bundle exec kitchen test rspec-opensuse-leap - after_failure: - - cat .kitchen/logs/kitchen.log - env: - - RSPEC_OPENSUSELEAP=42 - - KITCHEN_YAML=kitchen.yml - -notifications: - on_change: true - on_failure: true - on_success: change - on_pull_requests: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa154feb11..c0e82f5c18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ We have a 3 step process for contributions: Chef Projects are built to last. We strive to ensure high quality throughout the experience. In order to ensure this, we require that all pull requests to Chef projects meet these specifications: 1. **Tests:** To ensure high quality code and protect against future regressions, we require all the code in Chef Projects to have at least unit test coverage. We use [RSpec](http://rspec.info/) for unit testing. -2. **Green CI Tests:** We use [Travis CI](https://travis-ci.org/) and/or [AppVeyor](https://www.appveyor.com/) CI systems to test all pull requests. We require these test runs to succeed on every pull request before being merged. +2. **Green CI Tests:** We use [Buildkite](https://buildkite.com/chef-oss) to test all pull requests. We require these test runs to succeed on every pull request before being merged. ### Code Review Process @@ -33,7 +33,7 @@ Code review takes place in GitHub pull requests. See [this article](https://help Once you open a pull request, project maintainers will review your code and respond to your pull request with any feedback they might have. The process at this point is as follows: -1. Two thumbs-up (:+1:) are required from project maintainers. See the master maintainers document for Chef projects at <https://github.com/chef/chef/blob/master/MAINTAINERS.md>. +1. Two thumbs-up (:+1:) are required from project maintainers. See the master maintainers document for Chef projects at <https://github.com/chef/chef-oss-practices/blob/master/projects/chef-infra.md>. 2. Your change will be merged into the project's `master` branch 3. Our Expeditor bot will automatically update the project's changelog with your contribution. For projects such as Chef and Chef-DK the version will be automatically incremented and a build kicked off to the project's `current` channel. @@ -62,7 +62,7 @@ By making a contribution to this project, I certify that: (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open - source license and I have the right under that license to + source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as diff --git a/MAINTAINERS.md b/MAINTAINERS.md deleted file mode 100644 index 974ca27bad..0000000000 --- a/MAINTAINERS.md +++ /dev/null @@ -1,237 +0,0 @@ -<!-- This is a generated file. Please do not edit directly --> - -# Maintainers - -This file lists how the Chef project is maintained. When making changes to the system, this -file tells you who needs to review your patch - you need a simple majority of maintainers -for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need -to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Chef is Maintained](https://github.com/chef/chef-rfc/blob/master/rfc030-maintenance-policy.md#how-the-project-is-maintained) for details on the process, how to become -a maintainer, lieutenant, or the project lead. - -# Project Lead - -* [Adam Jacob](https://github.com/adamhjk) - -## Components - -## Chef Core - -Maintainers for the Chef client, Ohai, mixlibs, ChefDK, ChefSpec, Foodcritic, chefstyle, and sundry others. - -To mention the team, use @chef/client-core - -### Lieutenant - -* [Thom May](https://github.com/thommay) - -### Maintainers - -* [Adam Leff](https://github.com/adamleff) -* [Bryan McLellan](https://github.com/btm) -* [Noah Kantrowitz](https://github.com/coderanger) -* [Seth Thomas](https://github.com/cheeseplus) -* [Daniel DeLeo](https://github.com/danielsdeleo) -* [AJ Christensen](https://github.com/fujin) -* [Phil Dibowitz](https://github.com/jaymzh) -* [Jay Mundrawala](https://github.com/jaym) -* [John Keiser](https://github.com/jkeiser) -* [Jon Cowie](https://github.com/jonlives) -* [Joshua Timberman](https://github.com/jtimberman) -* [Lamont Granquist](https://github.com/lamont-granquist) -* [Ranjib Dey](https://github.com/ranjib) -* [Steven Murawski](https://github.com/smurawski) -* [Steven Danna](https://github.com/stevendanna) -* [Stuart Preston](https://github.com/stuartpreston) -* [Tim Smith](https://github.com/tas50) -* [Tom Duffield](https://github.com/tduffield) -* [Tyler Ball](https://github.com/tyler-ball) -* [Josh Hudson](https://github.com/itmustbejj) - -## Chef Provisioning - -Chef Provisioning and Drivers. Supported Drivers are listed in the [README](https://github.com/chef/chef-provisioning/blob/master/README.md#chef-provisioning). - -To mention the team, use @chef/provisioning - -### Lieutenant - -* [Tyler Ball](https://github.com/tyler-ball) - -### Maintainers - -* [John Keiser](https://github.com/jkeiser) -* [JJ Asghar](https://github.com/jjasghar) -* [Stuart Preston](https://github.com/stuartpreston) -* [Harley Alaniz](https://github.com/thehar) - -## Platform Specific Components - -The specific components of Chef related to a given platform - including (but not limited to) resources, providers, and the core DSL. - -## Enterprise Linux - -To mention the team, use @chef/client-enterprise-linux - -### Lieutenant - -* [Jon Cowie](https://github.com/jonlives) - -### Maintainers - -* [Phil Dibowitz](https://github.com/jaymzh) -* [Lamont Granquist](https://github.com/lamont-granquist) - -## Ubuntu - -To mention the team, use @chef/client-ubuntu - -### Lieutenant - -* [Ranjib Dey](https://github.com/ranjib) - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) - -## Windows - -To mention the team, use @chef/client-windows - -### Lieutenant - -* [Bryan McLellan](https://github.com/btm) - -### Maintainers - -* [Jay Mundrawala](https://github.com/jaym) -* [Kartik Cating-Subramanian](https://github.com/ksubrama) -* [Steven Murawski](https://github.com/smurawski) -* [Stuart Preston](https://github.com/stuartpreston) -* [Salim Alam](https://github.com/chefsalim) -* [Matt Wrock](https://github.com/mwrock) -* [Tim Smith](https://github.com/tas50) - -## Solaris - -To mention the team, use @chef/client-solaris - -### Lieutenant - -* [Thom May](https://github.com/thommay) - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## AIX - -To mention the team, use @chef/client-aix - -### Lieutenant - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## Mac OS X - -To mention the team, use @chef/client-os-x - -### Lieutenant - -* [Joshua Timberman](https://github.com/jtimberman) - -### Maintainers - -* [Tyler Ball](https://github.com/tyler-ball) -* [mikedodge04](https://github.com/mikedodge04) -* [Tim Smith](https://github.com/tas50) - -## Debian - -To mention the team, use @chef/client-debian - -### Lieutenant - -* [Thom May](https://github.com/thommay) - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) -* [Tim Smith](https://github.com/tas50) - -## Fedora - -To mention the team, use @chef/client-fedora - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## openSUSE - -To mention the team, use @chef/client-opensuse - -### Lieutenant - -* [Tim Smith](https://github.com/tas50) - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## SUSE Enterprise Linux Server - -To mention the team, use @chef/client-suse - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## FreeBSD - -To mention the team, use @chef/client-freebsd - -### Lieutenant - -* [Aaron Kalin](https://github.com/martinisoft) - -### Maintainers - -* [Cory Stephenson](https://github.com/Aevin1387) -* [David Aronsohn](https://github.com/OnlyHaveCans) - -## OpenBSD - -To mention the team, use @chef/client-openbsd - -### Lieutenant - -* [Joe Miller](https://github.com/joemiller) - -## Gentoo - -To mention the team, use @chef/client-gentoo - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) - -## OmniOS - -To mention the team, use @chef/client-omnios - -### Maintainers - -* [Thom May](https://github.com/thommay) - -## ArchLinux - -To mention the team, use @chef/client-archlinux - -### Maintainers - -* [Lamont Granquist](https://github.com/lamont-granquist) -* [Ryan Cragun](https://github.com/ryancragun) diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml deleted file mode 100644 index 407471e164..0000000000 --- a/MAINTAINERS.toml +++ /dev/null @@ -1,374 +0,0 @@ -# -# This file is structured to be consumed by both humans and computers. -# To update the generated Markdown, run `bundle exec rake maintainers:generate` -# To synchronize the maintainers with the github teams, run `bundle exec rake maintainers:synchronize` -# It is a TOML document containing Markdown -# -[Preamble] - title = "Maintainers" - text = """ -This file lists how the Chef project is maintained. When making changes to the system, this -file tells you who needs to review your patch - you need a simple majority of maintainers -for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need -to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Chef is Maintained](https://github.com/chef/chef-rfc/blob/master/rfc030-maintenance-policy.md#how-the-project-is-maintained) for details on the process, how to become -a maintainer, lieutenant, or the project lead. -""" - -[Org] - [Org.Lead] - title = "Project Lead" - person = "adamhjk" - - [Org.Components] - title = "Components" - - [Org.Components.Core] - title = "Chef Core" - team = "client-core" - text = """ -Maintainers for the Chef client, Ohai, mixlibs, ChefDK, ChefSpec, Foodcritic, chefstyle, and sundry others. -""" - - lieutenant = "thommay" - - maintainers = [ - "adamleff", - "btm", - "coderanger", - "cheeseplus", - "danielsdeleo", - "fujin", - "jaymzh", - "jaym", - "jkeiser", - "jonlives", - "jtimberman", - "lamont-granquist", - "ranjib", - "smurawski", - "stevendanna", - "stuartpreston", - "tas50", - "tduffield", - "tyler-ball", - "itmustbejj" - ] - - [Org.Components.Provisioning] - title = "Chef Provisioning" - team = "provisioning" - text = """ -Chef Provisioning and Drivers. Supported Drivers are listed in the [README](https://github.com/chef/chef-provisioning/blob/master/README.md#chef-provisioning). -""" - - lieutenant = "tyler-ball" - - maintainers = [ - "jkeiser", - "jjasghar", - "stuartpreston", - "thehar", - "jjlimepoint" - ] - - [Org.Components.Subsystems] - title = "Platform Specific Components" - text = """ -The specific components of Chef related to a given platform - including (but not limited to) resources, providers, and the core DSL. -""" - - [Org.Components.Subsystems."Enterprise Linux"] - title = "Enterprise Linux" - team = "client-enterprise-linux" - - lieutenant = "jonlives" - - maintainers = [ - "jaymzh", - "lamont-granquist" - ] - - [Org.Components.Subsystems.Ubuntu] - title = "Ubuntu" - team = "client-ubuntu" - - lieutenant = "ranjib" - - maintainers = [ - "lamont-granquist", - "tas50", - "thommay" - ] - - [Org.Components.Subsystems.Windows] - title = "Windows" - team = "client-windows" - - lieutenant = "btm" - maintainers = [ - "jaym", - "ksubrama", - "smurawski", - "stuartpreston", - "chefsalim", - "mwrock", - "tas50" - ] - - [Org.Components.Subsystems.Solaris] - title = "Solaris" - team = "client-solaris" - - lieutenant = "thommay" - - maintainers = [ - "lamont-granquist" - ] - - [Org.Components.Subsystems.AIX] - title = "AIX" - team = "client-aix" - - lieutenant = "lamont-granquist" - - [Org.Components.Subsystems."Mac OS X"] - title = "Mac OS X" - team = "client-os-x" - - lieutenant = "jtimberman" - - maintainers = [ - "tyler-ball", - "mikedodge04", - "tas50" - ] - - [Org.Components.Subsystems.Debian] - title = "Debian" - team = "client-debian" - - lieutenant = "thommay" - - maintainers = [ - "lamont-granquist", - "tas50" - ] - - [Org.Components.Subsystems.Fedora] - title = "Fedora" - team = "client-fedora" - - maintainers = [ - "lamont-granquist" - ] - - [Org.Components.Subsystems.openSUSE] - title = "openSUSE" - team = "client-opensuse" - - lieutenant = "tas50" - - maintainers = [ - "lamont-granquist" - ] - - [Org.Components.Subsystems."SUSE Enterprise Linux"] - title = "SUSE Enterprise Linux Server" - team = "client-suse" - - maintainers = [ - "lamont-granquist" - ] - - [Org.Components.Subsystems.FreeBSD] - title = "FreeBSD" - team = "client-freebsd" - - lieutenant = "martinisoft" - - maintainers = [ - "Aevin1387", - "OnlyHaveCans" - ] - - [Org.Components.Subsystems.OpenBSD] - title = "OpenBSD" - team = "client-openbsd" - - lieutenant = "joemiller" - - [Org.Components.Subsystems.Gentoo] - title = "Gentoo" - team = "client-gentoo" - - maintainers = [ - "lamont-granquist" - ] - - [Org.Components.Subsystems.OmniOS] - title = "OmniOS" - team = "client-omnios" - - maintainers = [ - "thommay" - ] - - [Org.Components.Subsystems.ArchLinux] - title = "ArchLinux" - team = "client-archlinux" - - maintainers = [ - "lamont-granquist", - "ryancragun" - ] - -[people] - [people.adamhjk] - Name = "Adam Jacob" - GitHub = "adamhjk" - - [people.adamleff] - Name = "Adam Leff" - GitHub = "adamleff" - - [people.Aevin1387] - Name = "Cory Stephenson" - GitHub = "Aevin1387" - - [people.AgentMeerkat] - Name = "Bryant Lippert" - GitHub = "AgentMeerkat" - - [people.btm] - Name = "Bryan McLellan" - GitHub = "btm" - - [people.danielsdeleo] - Name = "Daniel DeLeo" - GitHub = "danielsdeleo" - - [people.fujin] - Name = "AJ Christensen" - GitHub = "fujin" - - [people.jaymzh] - Name = "Phil Dibowitz" - GitHub = "jaymzh" - - [people.jaym] - Name = "Jay Mundrawala" - GitHub = "jaym" - - [people.jonlives] - Name = "Jon Cowie" - GitHub = "jonlives" - - [people.jtimberman] - Name = "Joshua Timberman" - GitHub = "jtimberman" - - [people.lamont-granquist] - Name = "Lamont Granquist" - GitHub = "lamont-granquist" - - [people.martinisoft] - Name = "Aaron Kalin" - GitHub = "martinisoft" - - [people.ranjib] - Name = "Ranjib Dey" - GitHub = "ranjib" - - [people.smurawski] - Name = "Steven Murawski" - GitHub = "smurawski" - - [people.stevendanna] - Name = "Steven Danna" - GitHub = "stevendanna" - - [people.OnlyHaveCans] - Name = "David Aronsohn" - GitHub = "OnlyHaveCans" - IRC = "tBunnyMan" - Twitter = "OnlyHaveCans" - - [people.thommay] - Name = "Thom May" - GitHub = "thommay" - IRC = "thom" - Twitter = "thommay" - - [people.tyler-ball] - Name = "Tyler Ball" - GitHub = "tyler-ball" - - [people.ksubrama] - Name = "Kartik Cating-Subramanian" - GitHub = "ksubrama" - - [people.joemiller] - Name = "Joe Miller" - GitHub = "joemiller" - - [people.coderanger] - Name = "Noah Kantrowitz" - GitHub = "coderanger" - - [people.ryancragun] - Name = "Ryan Cragun" - GitHub = "ryancragun" - - [people.chefsalim] - Name = "Salim Alam" - GitHub = "chefsalim" - - [people.mwrock] - Name = "Matt Wrock" - GitHub = "mwrock" - - [people.tas50] - Name = "Tim Smith" - GitHub = "tas50" - Twitter = "tas50" - IRC = "tas50" - - [people.jkeiser] - Name = "John Keiser" - GitHub = "jkeiser" - - [people.stuartpreston] - Name = "Stuart Preston" - GitHub = "stuartpreston" - - [people.jjasghar] - Name = "JJ Asghar" - GitHub = "jjasghar" - Twitter = "jjasghar" - IRC = "j^2" - - [people.thehar] - Name = "Harley Alaniz" - GitHub = "thehar" - - [people.tduffield] - Name = "Tom Duffield" - GitHub = "tduffield" - - [people.mikedodge04] - Name = "mikedodge04" - GitHub = "mikedodge04" - Twitter = "mikedodge04" - IRC = "mikedodge04" - - [people.itmustbejj] - Name = "Josh Hudson" - GitHub = "itmustbejj" - Twitter = "itmustbejj" - IRC = "itmustbejj" - - [people.cheeseplus] - Name = "Seth Thomas" - GitHub = "cheeseplus" @@ -1,15 +1,26 @@ -# Chef +# Chef Infra [![Code Climate](https://codeclimate.com/github/chef/chef.svg)](https://codeclimate.com/github/chef/chef) -[![Build Status Master](https://travis-ci.org/chef/chef.svg?branch=master)](https://travis-ci.org/chef/chef) -[![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/chef?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/chef/branch/master) +[![Build Status](https://badge.buildkite.com/f798a31e86518429573be35b496b313f4aee72dbb17e946eda.svg?branch=chef-14)](https://buildkite.com/chef-oss/chef-chef-chef-14-verify) [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef) -[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef-rfc/blob/master/rfc086-chef-oss-project-policies.md#cadence-release) +[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/master/docs/dev/design_documents/client_release_cadence.md) + +**Umbrella Project**: [Chef Infra](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-infra.md) + +**Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md#active) + +**Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days + +**Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days ## Getting Started -Want to try Chef? -For Chef user, please refer to [Quick Start](https://docs.chef.io/quick_start.html) -For more details, please refer to [learnchef](https://learn.chef.io) +Chef Infra is a configuration management tool designed to bring automation to your entire infrastructure. + +### Want to try Chef Infra? + +For Chef Infra usage, please refer to our [Learn Chef Rally](https://learn.chef.io/) website, which includes module-based training for Chef Infra, as well as Automate, Habitat, and InSpec. + +Other useful resources for Chef Infra users: - Documentation: <https://docs.chef.io> - Source: <https://github.com/chef/chef/tree/master> @@ -17,10 +17,13 @@ # limitations under the License. # -require_relative "tasks/rspec" -require_relative "tasks/maintainers" -require_relative "tasks/dependencies" -require_relative "tasks/announce" +begin + require_relative "tasks/rspec" + require_relative "tasks/dependencies" + require_relative "tasks/announce" +rescue LoadError => e + puts "Skipping missing rake dep: #{e}" +end # hack the chef-config install to run before the traditional install task task :super_install do diff --git a/spec/data/cookbooks/openldap/metadata.rb b/spec/data/cookbooks/openldap/metadata.rb index ab0dface9d..fc132946f2 100644 --- a/spec/data/cookbooks/openldap/metadata.rb +++ b/spec/data/cookbooks/openldap/metadata.rb @@ -1,6 +1,6 @@ name "openldap" -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" +maintainer "Chef Software, Inc." +maintainer_email "cookbooks@chef.io" license "Apache 2.0" description "Installs and configures all aspects of openldap using Debian style symlinks with helper definitions" long_description "The long description for the openldap cookbook from metadata.rb" diff --git a/spec/data/metadata/quick_start/metadata.rb b/spec/data/metadata/quick_start/metadata.rb index e74eedba0f..e7ae9d1749 100644 --- a/spec/data/metadata/quick_start/metadata.rb +++ b/spec/data/metadata/quick_start/metadata.rb @@ -1,5 +1,5 @@ -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" +maintainer "Chef Software, Inc." +maintainer_email "cookbooks@chef.io" license "Apache 2.0" description "Example cookbook for quick_start wiki document" version "0.7" @@ -12,8 +12,3 @@ version "0.7" }.each do |os| supports os end - -attribute "quick_start/deep_thought", - :display_name => "Quick Start Deep Thought", - :description => "A deep thought", - :default => "If a tree falls in the forest..." diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb index f80256fa5c..ef631edc20 100644 --- a/spec/functional/audit/runner_spec.rb +++ b/spec/functional/audit/runner_spec.rb @@ -108,7 +108,7 @@ describe Chef::Audit::Runner do in_sub_process do runner.run - expect(stdout.string).to match(/Failure\/Error: expect\(2 - 1\)\.to eq\(0\)/) + expect(stdout.string).to match(%r{Failure/Error: expect\(2 - 1\)\.to eq\(0\)}) expect(stdout.string).to match(/1 example, 1 failure/) expect(stdout.string).to match(/# control_group_name should fail/) end diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb index ff7fd574b1..89701802b3 100644 --- a/spec/functional/dsl/reboot_pending_spec.rb +++ b/spec/functional/dsl/reboot_pending_spec.rb @@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending, :windows_only do let(:reg_key) { nil } let(:original_set) { false } - before(:all) { @any_flag = Hash.new } + before(:all) { @any_flag = {} } after { @any_flag[reg_key] = original_set } @@ -47,7 +47,7 @@ describe Chef::DSL::RebootPending, :windows_only do it "returns true if the registry value exists" do skip "found existing registry key" if original_set registry.set_value(reg_key, - { name: "PendingFileRenameOperations", type: :multi_string, data: ['\??\C:\foo.txt|\??\C:\bar.txt'] }) + { name: "PendingFileRenameOperations", type: :multi_string, data: ['\??\C:\foo.txt|\??\C:\bar.txt'] }) expect(recipe.reboot_pending?).to be_truthy end @@ -59,25 +59,6 @@ describe Chef::DSL::RebootPending, :windows_only do end end - describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired' do - let(:reg_key) { 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired' } - let(:original_set) { registry.key_exists?(reg_key) } - - it "returns true if the registry key exists" do - skip "found existing registry key" if original_set - pending "Permissions are limited to 'TrustedInstaller' by default" - registry.create_key(reg_key, false) - - expect(recipe.reboot_pending?).to be_truthy - end - - after do - unless original_set - registry.delete_key(reg_key, false) - end - end - end - describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' do let(:reg_key) { 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' } let(:original_set) { registry.key_exists?(reg_key) } diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb index 8a9475680d..ef3ceb808f 100644 --- a/spec/functional/event_loggers/windows_eventlog_spec.rb +++ b/spec/functional/event_loggers/windows_eventlog_spec.rb @@ -49,16 +49,18 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_start(version) expect(event_log.read(flags, offset).any? do |e| - e.source == "Chef" && e.event_id == 10000 && - e.string_inserts[0].include?(version) end).to be_truthy + e.source == "Chef" && e.event_id == 10000 && + e.string_inserts[0].include?(version) + end ).to be_truthy end it "writes run_started event with event_id 10001 and contains the run_id" do logger.run_started(run_status) expect(event_log.read(flags, offset).any? do |e| - e.source == "Chef" && e.event_id == 10001 && - e.string_inserts[0].include?(run_id) end).to be_truthy + e.source == "Chef" && e.event_id == 10001 && + e.string_inserts[0].include?(run_id) + end ).to be_truthy end it "writes run_completed event with event_id 10002 and contains the run_id and elapsed time" do diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb index 9e2131388f..07991aa8bd 100644 --- a/spec/functional/file_content_management/deploy_strategies_spec.rb +++ b/spec/functional/file_content_management/deploy_strategies_spec.rb @@ -175,20 +175,20 @@ end describe Chef::FileContentManagement::Deploy::Cp do let(:unix_invariants) do - [ - :uid, - :gid, - :mode, - :ino, - ] + %i{ + uid + gid + mode + ino + } end let(:security_descriptor_invariants) do - [ - :owner, - :group, - :dacl, - ] + %i{ + owner + group + dacl + } end it_should_behave_like "a content deploy strategy" @@ -198,11 +198,11 @@ end describe Chef::FileContentManagement::Deploy::MvUnix, :unix_only do let(:unix_invariants) do - [ - :uid, - :gid, - :mode, - ] + %i{ + uid + gid + mode + } end it_should_behave_like "a content deploy strategy" @@ -216,11 +216,11 @@ describe Chef::FileContentManagement::Deploy::MvWindows, :windows_only do context "when a file has no sacl" do let(:security_descriptor_invariants) do - [ - :owner, - :group, - :dacl, - ] + %i{ + owner + group + dacl + } end it_should_behave_like "a content deploy strategy" diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb index 7cdf1c93eb..010b89c4f4 100644 --- a/spec/functional/knife/exec_spec.rb +++ b/spec/functional/knife/exec_spec.rb @@ -49,7 +49,7 @@ describe Chef::Knife::Exec do code = "$output.puts nodes.all" @knife.config[:exec] = code @knife.run - expect($output.string).to match(%r{node\[ohai-world\]}) + expect($output.string).to match(/node\[ohai-world\]/) end end diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index 95e7b6454c..aade00cbf1 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -31,7 +31,7 @@ describe Chef::Knife::Ssh do @server.stop end - let(:ssh_config) { Hash.new } + let(:ssh_config) { {} } before do allow(Net::SSH).to receive(:configuration_for).and_return(ssh_config) end @@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do end it "uses the ssh_gateway_identity file" do - expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) @knife.run expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") end @@ -315,7 +315,7 @@ describe Chef::Knife::Ssh do end it "uses the ssh_gateway_identity file" do - expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true }) @knife.run expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") end diff --git a/spec/functional/mixin/user_context_spec.rb b/spec/functional/mixin/user_context_spec.rb index 802b1db9f1..b6b8b057d5 100644 --- a/spec/functional/mixin/user_context_spec.rb +++ b/spec/functional/mixin/user_context_spec.rb @@ -26,7 +26,7 @@ describe Chef::Mixin::UserContext, windows_only: true do let(:get_user_name_a) do FFI.ffi_lib "advapi32.dll" - FFI.attach_function :GetUserNameA, [ :pointer, :pointer ], :bool + FFI.attach_function :GetUserNameA, %i{pointer pointer}, :bool end let(:process_username) do @@ -36,12 +36,14 @@ describe Chef::Mixin::UserContext, windows_only: true do if succeeded || last_error != Chef::ReservedNames::Win32::API::Error::ERROR_INSUFFICIENT_BUFFER raise Chef::Exceptions::Win32APIError, "Expected ERROR_INSUFFICIENT_BUFFER from GetUserNameA but it returned the following error: #{last_error}" end + user_name = FFI::MemoryPointer.new :char, (name_size.read_long) succeeded = get_user_name_a.call(user_name, name_size) last_error = FFI::LastError.error if succeeded == 0 || last_error != 0 raise Chef::Exceptions::Win32APIError, "GetUserNameA failed with #{lasterror}" end + user_name.read_string end diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb index 8e5b23f86b..747978cc96 100644 --- a/spec/functional/rebooter_spec.rb +++ b/spec/functional/rebooter_spec.rb @@ -44,7 +44,7 @@ describe Chef::Platform::Rebooter do let(:expected) do { - windows: "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"", + windows: "#{ENV["SYSTEMROOT"]}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"", linux: 'shutdown -r +5 "rebooter spec test" &', solaris: 'shutdown -i6 -g5 -y "rebooter spec test" &', } diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb index 5fff3e00d7..9ffe05266d 100755 --- a/spec/functional/resource/aix_service_spec.rb +++ b/spec/functional/resource/aix_service_spec.rb @@ -77,7 +77,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do include Chef::Mixin::ShellOut def get_user_id - shell_out("id -u #{ENV['USER']}").stdout.chomp + shell_out("id -u #{ENV["USER"]}").stdout.chomp end describe "When service is a subsystem" do diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb index 68ea5ab8b2..fc8a80eb08 100755 --- a/spec/functional/resource/aixinit_service_spec.rb +++ b/spec/functional/resource/aixinit_service_spec.rb @@ -40,7 +40,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do directory = [] if priority.is_a? Hash priority.each do |level, o| - directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? 'S' : 'K')}#{o[1]}#{new_resource.service_name}" + directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? "S" : "K")}#{o[1]}#{new_resource.service_name}" end directory else diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb index c1ac51c4b1..ad4378b83a 100644 --- a/spec/functional/resource/apt_package_spec.rb +++ b/spec/functional/resource/apt_package_spec.rb @@ -89,7 +89,7 @@ end metadata = { unix_only: true, requires_root: true, provider: { package: Chef::Provider::Package::Apt }, - arch: "x86_64" # test packages are 64bit + arch: "x86_64", # test packages are 64bit } describe Chef::Resource::AptPackage, metadata do diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb index e8dae581b9..c5590b2d88 100644 --- a/spec/functional/resource/chocolatey_package_spec.rb +++ b/spec/functional/resource/chocolatey_package_spec.rb @@ -22,7 +22,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do include Chef::Mixin::PowershellOut let(:package_name) { "test-A" } - let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(' ')}").stdout.chomp } } + let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } } let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") } subject do @@ -63,7 +63,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do end context "installing multiple packages" do - let(:package_name) { [ "test-A", "test-B" ] } + let(:package_name) { %w{test-A test-B} } it "installs both packages" do subject.run_action(:install) diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb index d127413c73..6e964a6499 100644 --- a/spec/functional/resource/cookbook_file_spec.rb +++ b/spec/functional/resource/cookbook_file_spec.rb @@ -25,9 +25,7 @@ describe Chef::Resource::CookbookFile do let(:source) { "java.response" } let(:cookbook_name) { "java" } let(:expected_content) do - content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb") do |f| - f.read - end + content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb", &:read) content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding) content end diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index 84fe304585..16b0d2645c 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -28,7 +28,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do # Platform specific validation routines. def cron_should_exists(cron_name, command) case ohai[:platform] - when "aix", "solaris", "opensolaris", "solaris2", "omnios" + when "aix", "opensolaris", "solaris2", "omnios" expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(0) expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").stdout.lines.to_a.size).to eq(1) expect(shell_out("crontab -l #{new_resource.user} | grep \"#{command}\"").exitstatus).to eq(0) @@ -43,7 +43,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do def cron_should_not_exists(cron_name) case ohai[:platform] - when "aix", "solaris", "opensolaris", "solaris2", "omnios" + when "aix", "opensolaris", "solaris2", "omnios" expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(1) expect(shell_out("crontab -l #{new_resource.user} | grep \"#{new_resource.command}\"").stdout.lines.to_a.size).to eq(0) else @@ -57,7 +57,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context) new_resource.user "root" # @hourly is not supported on solaris, aix - if ohai[:platform] == "solaris" || ohai[:platform] == "solaris2" || ohai[:platform] == "aix" + if ohai[:platform] == "solaris2" || ohai[:platform] == "aix" new_resource.minute "0 * * * *" else new_resource.minute "@hourly" @@ -118,6 +118,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do def cron_attribute_should_exists(cron_name, attribute, value) return if %w{aix solaris}.include?(ohai[:platform]) + # Test if the attribute exists on newly created cron cron_should_exists(cron_name, "") expect(shell_out("crontab -l -u #{new_resource.user} | grep '#{attribute.upcase}=\"#{value}\"'").exitstatus).to eq(0) diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb index 1988fd0c7d..ef4a52017f 100644 --- a/spec/functional/resource/dpkg_package_spec.rb +++ b/spec/functional/resource/dpkg_package_spec.rb @@ -273,7 +273,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: it "should remove both packages when called with two" do shell_out!("dpkg -i #{test1_0} #{test2_0}") - set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] + set_dpkg_package_name %w{chef-integration-test chef-integration-test2} dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action should_be_purged_or_removed("chef-integration-test") @@ -282,7 +282,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: it "should remove a package when only the first one is installed" do shell_out!("dpkg -i #{test1_0}") - set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] + set_dpkg_package_name %w{chef-integration-test chef-integration-test2} dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action should_be_purged_or_removed("chef-integration-test") @@ -291,7 +291,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: it "should remove a package when only the second one is installed" do shell_out!("dpkg -i #{test2_0}") - set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] + set_dpkg_package_name %w{chef-integration-test chef-integration-test2} dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action should_be_purged_or_removed("chef-integration-test") @@ -299,7 +299,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: end it "should do nothing when both packages are not installed" do - set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] + set_dpkg_package_name %w{chef-integration-test chef-integration-test2} dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action should_be_purged_or_removed("chef-integration-test") diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb index 3491bb6bbe..8f5ba5fd9e 100644 --- a/spec/functional/resource/dsc_resource_spec.rb +++ b/spec/functional/resource/dsc_resource_spec.rb @@ -46,7 +46,8 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do it "raises an exception if the resource is not found" do new_resource.resource "thisdoesnotexist" expect { new_resource.run_action(:run) }.to raise_error( - Chef::Exceptions::ResourceNotFound) + Chef::Exceptions::ResourceNotFound + ) end end diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 0439625778..224141c0f8 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -103,7 +103,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do ValueData = '#{test_registry_data}' Ensure = 'Present' } -EOH + EOH end let(:dsc_code) { dsc_reg_code } @@ -111,7 +111,7 @@ EOH <<-EOH param($testregkeyname, $testregvaluename) #{dsc_reg_code} -EOH + EOH end let(:dsc_user_prefix) { "dsc" } @@ -138,7 +138,7 @@ EOH $#{dsc_user_prefix_param_name}, $#{dsc_user_suffix_param_name} ) -EOH + EOH end let(:config_param_section) { "" } @@ -166,7 +166,7 @@ EOH PasswordChangeRequired = $false } } -EOH + EOH end let(:dsc_user_config_data) do @@ -180,12 +180,12 @@ EOH ) } -EOH + EOH end let(:dsc_environment_env_var_name) { "dsc_test_cwd" } - let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" } - let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } + let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV["systemroot"]}\\system32" } + let(:dsc_environment_fail_etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" } let(:exception_message_signature) { "LL927-LL928" } let(:dsc_environment_config) do <<~EOH @@ -199,7 +199,7 @@ EOH Value = $pwd.path Ensure = 'Present' } -EOH + EOH end let(:dsc_config_name) do @@ -249,7 +249,7 @@ EOH Name = '#{dsc_environment_env_var_name}' Ensure = 'Absent' } -EOH + EOH removal_resource.run_action(:run) end @@ -310,7 +310,7 @@ EOH it "should set a registry key according to parameters passed to the configuration" do dsc_test_resource.configuration_name(config_name_value) - dsc_test_resource.flags({ :"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value }) + dsc_test_resource.flags({ "#{reg_key_name_param_name}": test_registry_key, "#{reg_key_value_param_name}": test_registry_value }) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) @@ -347,11 +347,9 @@ EOH shared_examples_for "a dsc_script with configuration data that takes parameters" do let(:dsc_user_code) { dsc_user_param_code } let(:config_param_section) { config_params } - let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => (dsc_user_prefix).to_s, :"#{dsc_user_suffix_param_name}" => (dsc_user_suffix).to_s } } + let(:config_flags) { { "#{dsc_user_prefix_param_name}": (dsc_user_prefix).to_s, "#{dsc_user_suffix_param_name}": (dsc_user_suffix).to_s } } it "does not directly contain the user name" do - configuration_script_content = ::File.open(dsc_test_resource.command) do |file| - file.read - end + configuration_script_content = ::File.open(dsc_test_resource.command, &:read) expect(configuration_script_content.include?(dsc_user)).to be(false) end it_behaves_like "a dsc_script with configuration data" @@ -361,9 +359,7 @@ EOH let(:dsc_user_code) { dsc_user_env_code } it "does not directly contain the user name" do - configuration_script_content = ::File.open(dsc_test_resource.command) do |file| - file.read - end + configuration_script_content = ::File.open(dsc_test_resource.command, &:read) expect(configuration_script_content.include?(dsc_user)).to be(false) end it_behaves_like "a dsc_script with configuration data" @@ -448,7 +444,7 @@ EOH } "@ $ConfigurationData | out-file '#{configuration_data_path}' -force - MYCODE + MYCODE end let(:powershell_script_resource) do @@ -464,10 +460,10 @@ EOH User dsctestusercreate { UserName = '#{dsc_user}' - Password = #{r.ps_credential('jf9a8m49jrajf4#')} + Password = #{r.ps_credential("jf9a8m49jrajf4#")} Ensure = "Present" } -EOF + EOF r.configuration_data_script(configuration_data_path) end end diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 3ad8762169..3e57795f73 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -87,8 +87,8 @@ describe Chef::Resource::Execute do describe "when parent resource sets :environment" do before do resource.environment({ - "SAWS_SECRET" => "supersecret", - "SAWS_KEY" => "qwerty", + "SAWS_SECRET" => "supersecret", + "SAWS_KEY" => "qwerty", }) end diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb index 16cde6351a..e978041038 100644 --- a/spec/functional/resource/git_spec.rb +++ b/spec/functional/resource/git_spec.rb @@ -69,7 +69,7 @@ describe Chef::Resource::Git, requires_git: true do [user] name = frodoTbaggins email = frodo@shire.org -E + E end before(:each) do @@ -220,7 +220,7 @@ E context "when dealing with a repo with a degenerate tag named 'HEAD'" do before do shell_out!("git tag -m\"degenerate tag\" HEAD ed181b3419b6f489bedab282348162a110d6d3a1", - cwd: origin_repo) + cwd: origin_repo) end let(:basic_git_resource) do @@ -240,16 +240,16 @@ E it "checks out the (master) HEAD revision and ignores the tag" do basic_git_resource.run_action(:sync) head_rev = shell_out!("git rev-parse HEAD", - cwd: deploy_directory, - returns: [0]).stdout.strip + cwd: deploy_directory, + returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end it "checks out the (master) HEAD revision when no revision is specified (ignores tag)" do git_resource_default_rev.run_action(:sync) head_rev = shell_out!("git rev-parse HEAD", - cwd: deploy_directory, - returns: [0]).stdout.strip + cwd: deploy_directory, + returns: [0]).stdout.strip expect(head_rev).to eq(rev_head) end diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb index 32bfdb0328..02e94da9d3 100644 --- a/spec/functional/resource/group_spec.rb +++ b/spec/functional/resource/group_spec.rb @@ -96,7 +96,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do end def create_user(username, uid = nil) - if ! windows_domain_user?(username) + unless windows_domain_user?(username) user_to_create = user(username) user_to_create.uid(uid) if uid user_to_create.run_action(:create) @@ -105,7 +105,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do end def remove_user(username) - if ! windows_domain_user?(username) + unless windows_domain_user?(username) u = user(username) u.manage_home false # jekins hosts throw mail spool file not owned by user if we use manage_home true u.run_action(:remove) @@ -152,7 +152,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do let(:excluded_members) { [] } it "should raise an error" do - expect { group_resource.run_action(tested_action) }.to raise_error() + expect { group_resource.run_action(tested_action) }.to raise_error end end @@ -162,7 +162,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do end it "should raise an error" do - expect { group_resource.run_action(tested_action) }.to raise_error() + expect { group_resource.run_action(tested_action) }.to raise_error end end end @@ -336,7 +336,8 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do "theoldmanwalkingdownthestreetalwayshadagood\ smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\ theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\ -downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end +downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" + end it "should create a group" do group_resource.run_action(:create) @@ -362,7 +363,8 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end "theoldmanwalkingdownthestreetalwayshadagood\ smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\ theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\ -downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end +downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" + end it "should not create a group" do expect { group_resource.run_action(:create) }.to raise_error(ArgumentError) @@ -423,7 +425,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end end end - describe "group manage action", :not_supported_on_solaris do + describe "group manage action" do let(:spec_members) { %w{mnou5sdz htulrvwq x4c3g1lu} } let(:included_members) { [spec_members[0], spec_members[1]] } let(:excluded_members) { [spec_members[2]] } diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index c52a4c0694..0a82e59137 100644 --- a/spec/functional/resource/ifconfig_spec.rb +++ b/spec/functional/resource/ifconfig_spec.rb @@ -23,9 +23,7 @@ require "chef/mixin/shell_out" # run this test only for following platforms. include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7)) -describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, external: include_flag do - # This test does not work in travis because there is no eth0 - +describe Chef::Resource::Ifconfig, :requires_root, external: include_flag do include Chef::Mixin::ShellOut let(:new_resource) do @@ -53,7 +51,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, external: inclu end def fetch_first_interface_name - shell_out("ip link list |grep UP|grep -vi loop|head -1|cut -d':' -f 2").stdout.strip + shell_out("ip link list |grep UP|grep -vi loop|head -1|cut -d':' -f 2 |cut -d'@' -f 1").stdout.strip end # **Caution: any updates to core interfaces can be risky. diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index d86a904098..4593dc1971 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -133,9 +133,9 @@ describe Chef::Resource::Link do end def get_sid(value) - if value.kind_of?(String) + if value.is_a?(String) Chef::ReservedNames::Win32::Security::SID.from_account(value) - elsif value.kind_of?(Chef::ReservedNames::Win32::Security::SID) + elsif value.is_a?(Chef::ReservedNames::Win32::Security::SID) value else raise "Must specify username or SID: #{value}" diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb index f6c7f91bcd..4052480b5e 100644 --- a/spec/functional/resource/mount_spec.rb +++ b/spec/functional/resource/mount_spec.rb @@ -1,6 +1,6 @@ # # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>) -# Copyright:: Copyright 2013-2018, Chef Software Inc. +# Copyright:: Copyright 2013-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,14 +24,10 @@ require "tmpdir" # run this test only for following platforms. include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family])) -describe Chef::Resource::Mount, :requires_root, :skip_travis, external: include_flag do - # Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not - # exist even after loading the kernel module - +describe Chef::Resource::Mount, :requires_root, external: include_flag do include Chef::Mixin::ShellOut # Platform specific setup, cleanup and validation helpers. - def setup_device_for_mount # use ramdisk for creating a test device for mount. # This can cleaner if we have chef resource/provider for ramdisk. @@ -73,7 +69,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, external: include_ def mount_should_exist(mount_point, device, fstype = nil, options = nil) validation_cmd = "mount | grep #{mount_point} | grep #{device} " validation_cmd << " | grep #{fstype} " unless fstype.nil? - validation_cmd << " | grep #{options.join(',')} " unless options.nil? || options.empty? + validation_cmd << " | grep #{options.join(",")} " unless options.nil? || options.empty? expect(shell_out(validation_cmd).exitstatus).to eq(0) end diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb index e4c96976d9..79123fb614 100644 --- a/spec/functional/resource/powershell_script_spec.rb +++ b/spec/functional/resource/powershell_script_spec.rb @@ -28,13 +28,13 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it_behaves_like "a Windows script running on Windows" - let(:successful_executable_script_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe $env:systemroot" } - let(:failed_executable_script_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe /badargument" } + let(:successful_executable_script_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe $env:systemroot" } + let(:failed_executable_script_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe /badargument" } let(:processor_architecture_script_content) { "echo $env:PROCESSOR_ARCHITECTURE" } let(:native_architecture_script_content) { "echo $env:PROCESSOR_ARCHITECTUREW6432" } let(:cmdlet_exit_code_not_found_content) { "get-item '.\\thisdoesnotexist'" } let(:cmdlet_exit_code_success_content) { "get-item ." } - let(:windows_process_exit_code_success_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe $env:systemroot" } + let(:windows_process_exit_code_success_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe $env:systemroot" } let(:windows_process_exit_code_not_found_content) { "findstr /notavalidswitch" } let(:arbitrary_nonzero_process_exit_code) { 4193 } let(:arbitrary_nonzero_process_exit_code_content) { "exit #{arbitrary_nonzero_process_exit_code}" } @@ -473,26 +473,26 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do end it "evaluates a not_if block using the cwd guard parameter" do - custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" + custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc" resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd expect(resource.should_skip?(:run)).to be_truthy end it "evaluates an only_if block using the cwd guard parameter" do - custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" + custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc" resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd expect(resource.should_skip?(:run)).to be_falsey end it "inherits cwd from the parent resource for only_if" do - custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" + custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc" resource.cwd custom_cwd resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')" expect(resource.should_skip?(:run)).to be_falsey end it "inherits cwd from the parent resource for not_if" do - custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc" + custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc" resource.cwd custom_cwd resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')" expect(resource.should_skip?(:run)).to be_truthy @@ -584,7 +584,8 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do resource.only_if "$true", architecture: :i386 expect { resource.run_action(:run) }.to raise_error( Chef::Exceptions::Win32ArchitectureIncorrect, - /cannot execute script with requested architecture 'i386' on Windows Nano Server/) + /cannot execute script with requested architecture 'i386' on Windows Nano Server/ + ) end end end diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb index 3b8e3efe8a..5489dc1c72 100644 --- a/spec/functional/resource/reboot_spec.rb +++ b/spec/functional/resource/reboot_spec.rb @@ -45,7 +45,7 @@ describe Chef::Resource::Reboot do shared_context "testing run context modification" do def test_reboot_action(resource) reboot_info = resource.run_context.reboot_info - expect(reboot_info.keys.sort).to eq([:delay_mins, :reason, :requested_by, :timestamp]) + expect(reboot_info.keys.sort).to eq(%i{delay_mins reason requested_by timestamp}) expect(reboot_info[:delay_mins]).to eq(expected[:delay_mins]) expect(reboot_info[:reason]).to eq(expected[:reason]) expect(reboot_info[:requested_by]).to eq(expected[:requested_by]) diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb index 44a7a46d68..ffa0364d1d 100644 --- a/spec/functional/resource/remote_file_spec.rb +++ b/spec/functional/resource/remote_file_spec.rb @@ -134,7 +134,7 @@ describe Chef::Resource::RemoteFile do let(:smb_file_local_file_name) { "smb_file.txt" } let(:smb_file_local_path) { File.join( smb_share_root_directory, smb_file_local_file_name ) } let(:smb_share_name) { "chef_smb_test" } - let(:smb_remote_path) { File.join("//#{ENV['COMPUTERNAME']}", smb_share_name, smb_file_local_file_name).gsub(/\//, "\\") } + let(:smb_remote_path) { File.join("//#{ENV["COMPUTERNAME"]}", smb_share_name, smb_file_local_file_name).gsub(%r{/}, "\\") } let(:smb_file_content) { "hellofun" } let(:local_destination_path) { File.join(Dir.tmpdir, make_tmpname("chef_remote_file")) } let(:windows_current_user) { ENV["USERNAME"] } @@ -155,7 +155,7 @@ describe Chef::Resource::RemoteFile do before do shell_out("net.exe share #{smb_share_name} /delete") File.write(smb_file_local_path, smb_file_content ) - shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.gsub(/\//, '\\')}\" /grant:\"authenticated users\",read") + shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.gsub(%r{/}, '\\')}\" /grant:\"authenticated users\",read") end after do diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb index 679ffe661a..feef97dd27 100644 --- a/spec/functional/resource/template_spec.rb +++ b/spec/functional/resource/template_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Resource::Template do def binread(file) - File.open(file, "rb") { |f| f.read } + File.open(file, "rb", &:read) end include_context Chef::Resource::File diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb index 3a5535f194..6bab270f56 100644 --- a/spec/functional/resource/user/windows_spec.rb +++ b/spec/functional/resource/user/windows_spec.rb @@ -47,13 +47,13 @@ describe Chef::Provider::User::Windows, :windows_only do end def backup_secedit_policy - backup_command = "secedit /export /cfg #{ENV['TEMP']}\\secedit_restore.inf /areas SECURITYPOLICY" + backup_command = "secedit /export /cfg #{ENV["TEMP"]}\\secedit_restore.inf /areas SECURITYPOLICY" shell_out(backup_command) end def restore_secedit_policy security_database = "C:\\windows\\security\\database\\seceditnew.sdb" - restore_command = "secedit /configure /db #{security_database} /cfg #{ENV['TEMP']}\\secedit_restore.inf /areas SECURITYPOLICY" + restore_command = "secedit /configure /db #{security_database} /cfg #{ENV["TEMP"]}\\secedit_restore.inf /areas SECURITYPOLICY" shell_out(restore_command) end diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb index 79b3cd890b..9b79de6a77 100644 --- a/spec/functional/resource/windows_certificate_spec.rb +++ b/spec/functional/resource/windows_certificate_spec.rb @@ -81,9 +81,9 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do # Byepassing the validation so that we may create a custom store allow_any_instance_of(Chef::Mixin::ParamsValidate) - .to receive(:_pv_equal_to) - .with(opts, key, to_be) - .and_return(true) + .to receive(:_pv_equal_to) + .with(opts, key, to_be) + .and_return(true) # Creating a custom store for the testing create_store(store) diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index f422ac21d6..999b235df1 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -24,7 +24,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ include_context "using Win32::Service" let(:username) { "service_spec_user" } - let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}" } + let(:qualified_username) { "#{ENV["COMPUTERNAME"]}\\#{username}" } let(:password) { "1a2b3c4X!&narf" } let(:user_resource) do @@ -36,7 +36,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ end let(:global_service_file_path) do - "#{ENV['WINDIR']}\\temp\\#{File.basename(test_service[:service_file_path])}" + "#{ENV["WINDIR"]}\\temp\\#{File.basename(test_service[:service_file_path])}" end let(:service_params) do @@ -59,7 +59,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ let(:service_resource) do r = Chef::Resource::WindowsService.new(service_params[:service_name], run_context) - [:run_as_user, :run_as_password].each { |prop| r.send(prop, service_params[prop]) } + %i{run_as_user run_as_password}.each { |prop| r.send(prop, service_params[prop]) } r end diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index 49972360ef..d9a8bd2d0e 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -334,6 +334,7 @@ describe Chef::RunLock do loop do line = readline_nonblock(read_from_process) break if line.nil? + event, time = line.split("@") example.log_event("#{name}.last_event got #{event}") example.log_event("[#{name}] #{event}", time.strip) @@ -346,7 +347,7 @@ describe Chef::RunLock do example.log_event("#{name}.run_to(#{to_event.inspect})") # Start the process if it's not started - start if !pid + start unless pid # Tell the process what to stop at (also means it can go) write_to_process.print "#{to_event}\n" @@ -370,7 +371,7 @@ describe Chef::RunLock do def run_to_completion example.log_event("#{name}.run_to_completion") # Start the process if it's not started - start if !pid + start unless pid # Tell the process to stop at nothing (no blocking) @write_to_process.print "nothing\n" diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index 3990f1afe0..bc469a259a 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2012-2017, Chef Software Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb index 7912d03f63..1c8fef2180 100644 --- a/spec/functional/util/powershell/cmdlet_spec.rb +++ b/spec/functional/util/powershell/cmdlet_spec.rb @@ -29,7 +29,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) } let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { depth: 2 }) } let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { depth: 2 }) } - let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } + let(:etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" } let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") } it "executes a simple process" do diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb index dc323e9d3a..0b6c413b2e 100644 --- a/spec/functional/version_spec.rb +++ b/spec/functional/version_spec.rb @@ -1,6 +1,6 @@ # # Author:: Serdar Sutay (<dan@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb index b3fe2afb31..a72088a079 100644 --- a/spec/functional/win32/security_spec.rb +++ b/spec/functional/win32/security_spec.rb @@ -61,7 +61,8 @@ describe "Chef::Win32::Security", :windows_only do describe "get_file_security" do it "should return a security descriptor when called with a path that exists" do security_descriptor = Chef::ReservedNames::Win32::Security.get_file_security( - "C:\\Program Files") + "C:\\Program Files" + ) # Make sure the security descriptor works expect(security_descriptor.dacl_present?).to be true end @@ -70,7 +71,8 @@ describe "Chef::Win32::Security", :windows_only do describe "access_check" do let(:security_descriptor) do Chef::ReservedNames::Win32::Security.get_file_security( - "C:\\Program Files") + "C:\\Program Files" + ) end let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS } @@ -78,7 +80,8 @@ describe "Chef::Win32::Security", :windows_only do let(:token) do Chef::ReservedNames::Win32::Security.open_process_token( Chef::ReservedNames::Win32::Process.get_current_process, - token_rights).duplicate_token(:SecurityImpersonation) + token_rights + ).duplicate_token(:SecurityImpersonation) end let(:mapping) do @@ -94,7 +97,7 @@ describe "Chef::Win32::Security", :windows_only do it "should check if the provided token has the desired access" do expect(Chef::ReservedNames::Win32::Security.access_check(security_descriptor, - token, desired_access, mapping)).to be true + token, desired_access, mapping)).to be true end end @@ -102,7 +105,8 @@ describe "Chef::Win32::Security", :windows_only do let(:token) do Chef::ReservedNames::Win32::Security.open_process_token( Chef::ReservedNames::Win32::Process.get_current_process, - token_rights) + token_rights + ) end context "with all rights" do let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS } @@ -127,11 +131,12 @@ describe "Chef::Win32::Security", :windows_only do let(:token) do Chef::ReservedNames::Win32::Security.open_process_token( Chef::ReservedNames::Win32::Process.get_current_process, - token_rights) + token_rights + ) end context "when the token is valid" do - let(:token_elevation_type) { [:TokenElevationTypeDefault, :TokenElevationTypeFull, :TokenElevationTypeLimited] } + let(:token_elevation_type) { %i{TokenElevationTypeDefault TokenElevationTypeFull TokenElevationTypeLimited} } it "returns the token elevation type" do elevation_type = Chef::ReservedNames::Win32::Security.get_token_information_elevation_type(token) diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb index 8fff73396e..abc8118835 100644 --- a/spec/functional/win32/service_manager_spec.rb +++ b/spec/functional/win32/service_manager_spec.rb @@ -43,7 +43,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind end it "throws an error with required missing options" do - [:service_name, :service_display_name, :service_description, :service_file_path].each do |key| + %i{service_name service_display_name service_description service_file_path}.each do |key| service_def = test_service.dup service_def.delete(key) diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 0e8e37bedb..d0041de054 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -20,9 +20,7 @@ describe "chef-client" do # just a normal file # (expected_content should be uncompressed) @api.get("/recipes.tgz", 200) do - File.open(recipes_filename, "rb") do |f| - f.read - end + File.open(recipes_filename, "rb", &:read) end end @@ -56,20 +54,20 @@ describe "chef-client" do it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) end it "should complete successfully with no other environment variables", skip: (Chef::Platform.windows?) do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM begin - result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) result.error! rescue Chef::Log.info "Bare invocation will have the following load-path." @@ -81,10 +79,10 @@ EOM it "should complete successfully with --no-listen" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} --no-listen -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) result.error! end @@ -125,10 +123,10 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) result.error! end @@ -162,40 +160,40 @@ EOM syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA= -----END RSA PRIVATE KEY----- -EOM + EOM end it "should complete with success even with a client key" do file "config/client.rb", <<~EOM local_mode true - client_key #{path_to('mykey.pem').inspect} - cookbook_path #{path_to('cookbooks').inspect} -EOM + client_key #{path_to("mykey.pem").inspect} + cookbook_path #{path_to("cookbooks").inspect} + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) result.error! end it "should run recipes specified directly on the command line" do file "config/client.rb", <<~EOM local_mode true - client_key #{path_to('mykey.pem').inspect} - cookbook_path #{path_to('cookbooks').inspect} -EOM + client_key #{path_to("mykey.pem").inspect} + cookbook_path #{path_to("cookbooks").inspect} + EOM file "arbitrary.rb", <<~EOM - file #{path_to('tempfile.txt').inspect} do + file #{path_to("tempfile.txt").inspect} do content '1' end -EOM + EOM file "arbitrary2.rb", <<~EOM - file #{path_to('tempfile2.txt').inspect} do + file #{path_to("tempfile2.txt").inspect} do content '2' end -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" #{path_to("arbitrary.rb")} #{path_to("arbitrary2.rb")}", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -205,17 +203,17 @@ EOM it "should run recipes specified as relative paths directly on the command line" do file "config/client.rb", <<~EOM local_mode true - client_key #{path_to('mykey.pem').inspect} - cookbook_path #{path_to('cookbooks').inspect} -EOM + client_key #{path_to("mykey.pem").inspect} + cookbook_path #{path_to("cookbooks").inspect} + EOM file "arbitrary.rb", <<~EOM - file #{path_to('tempfile.txt').inspect} do + file #{path_to("tempfile.txt").inspect} do content '1' end -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", cwd: path_to("")) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" arbitrary.rb", cwd: path_to("")) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -224,22 +222,22 @@ EOM it "should run recipes specified directly on the command line AFTER recipes in the run list" do file "config/client.rb", <<~EOM local_mode true - client_key #{path_to('mykey.pem').inspect} - cookbook_path #{path_to('cookbooks').inspect} -EOM + client_key #{path_to("mykey.pem").inspect} + cookbook_path #{path_to("cookbooks").inspect} + EOM file "cookbooks/x/recipes/constant_definition.rb", <<~EOM class ::Blah THECONSTANT = '1' end -EOM + EOM file "arbitrary.rb", <<~EOM - file #{path_to('tempfile.txt').inspect} do + file #{path_to("tempfile.txt").inspect} do content ::Blah::THECONSTANT end -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", cwd: path_to("")) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o x::constant_definition arbitrary.rb", cwd: path_to("")) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("1") @@ -250,30 +248,30 @@ EOM it "should complete with success when passed the -z flag" do file "config/client.rb", <<~EOM chef_server_url 'http://omg.com/blah' - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir) result.error! end it "should complete with success when passed the --local-mode flag" do file "config/client.rb", <<~EOM chef_server_url 'http://omg.com/blah' - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --local-mode", cwd: chef_dir) result.error! end it "should not print SSL warnings when running in local-mode" do file "config/client.rb", <<~EOM chef_server_url 'http://omg.com/blah' - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --local-mode", cwd: chef_dir) expect(result.stdout).not_to include("SSL validation of HTTPS requests is disabled.") result.error! end @@ -281,20 +279,20 @@ EOM it "should complete with success when passed -z and --chef-zero-port" do file "config/client.rb", <<~EOM chef_server_url 'http://omg.com/blah' - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir) result.error! end it "should complete with success when setting the run list with -r" do file "config/client.rb", <<~EOM chef_server_url 'http://omg.com/blah' - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -r 'x::default' -z -l info", cwd: chef_dir) expect(result.stdout).not_to include("Overridden Run List") expect(result.stdout).to include("Run List is [recipe[x::default]]") result.error! @@ -303,9 +301,9 @@ EOM it "should complete with success when using --profile-ruby and output a profile file", :not_supported_on_aix do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir) + cookbook_path "#{path_to("cookbooks")}" + EOM + result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir) result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true end @@ -313,9 +311,9 @@ EOM it "doesn't produce a profile when --profile-ruby is not present" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir) + cookbook_path "#{path_to("cookbooks")}" + EOM + result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir) result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false end @@ -328,14 +326,14 @@ EOM name 'x' version '0.0.1' chef_version '~> 999.99' -EOM + EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end it "should fail the chef client run" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(1) expect(command.stdout).to match(/Chef::Exceptions::CookbookChefVersionMismatch/) end @@ -356,12 +354,12 @@ EOM EOM file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" EOM end it "the cheffish DSL is loaded lazily" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(0) end end @@ -373,16 +371,16 @@ EOM EOM file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" EOM end it "the cheffish DSL tries to load but fails (because chef-provisioning is not there)" do # we'd need to have a custom bundle to fix this that omitted chef-provisioning, but that would dig our crazy even deeper, so lets not skip "but if chef-provisioning is in our bundle or in our gemset then this test, very annoyingly, always fails" - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) expect(command.exitstatus).to eql(1) - expect(command.stdout).to match(/cannot load such file -- chef\/provisioning/) + expect(command.stdout).to match(%r{cannot load such file -- chef/provisioning}) end end @@ -407,15 +405,15 @@ EOM it "should output each deprecation warning only once, at the end of the run" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" # Mimick what happens when you are on the console formatters << :doc log_level :warn -EOM + EOM ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS") - result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) expect(result.error?).to be_falsey # Search to the end of the client run in the output @@ -432,10 +430,10 @@ EOM before do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" audit_mode :enabled silence_deprecation_warnings %w{chef-27} -EOM + EOM end it "should exit with a zero code when there is not an audit failure" do @@ -447,7 +445,7 @@ EOM end RECIPE - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'audit_test::succeed' -l info", cwd: chef_dir) expect(result.error?).to be_falsey expect(result.stdout).to include("Successfully executed all `control_group` blocks and contained examples") end @@ -461,7 +459,7 @@ EOM end RECIPE - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'audit_test::fail'", cwd: chef_dir) expect(result.error?).to be_truthy expect(result.stdout).to include("Failure/Error: expect(2 - 2).to eq(1)") end @@ -470,7 +468,7 @@ EOM when_the_repository "has a cookbook that deploys a file" do before do file "cookbooks/x/recipes/default.rb", <<~RECIPE - cookbook_file #{path_to('tempfile.txt').inspect} do + cookbook_file #{path_to("tempfile.txt").inspect} do source "my_file" end RECIPE @@ -486,9 +484,9 @@ EOM file "config/client.rb", <<~EOM no_lazy_load #{lazy} local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM - result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + cookbook_path "#{path_to("cookbooks")}" + EOM + result = shell_out("#{chef_client} -l debug -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt")).strip).to eq("this is my file") @@ -500,7 +498,7 @@ EOM when_the_repository "has a cookbook with an ohai plugin" do before do file "cookbooks/x/recipes/default.rb", <<~RECIPE - file #{path_to('tempfile.txt').inspect} do + file #{path_to("tempfile.txt").inspect} do content node["english"]["version"] end RECIPE @@ -518,12 +516,12 @@ EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end it "should run the ohai plugin" do - result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + result = shell_out("#{chef_client} -l debug -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) result.error! expect(IO.read(path_to("tempfile.txt"))).to eq("2014") @@ -545,8 +543,8 @@ EOM it "should complete with success when passed -z and --recipe-url" do file "config/client.rb", <<~EOM chef_repo_path "#{tmp_dir}" -EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir) + EOM + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir) result.error! end @@ -569,27 +567,27 @@ EOM name 'x' version '0.0.1' raise "TEH SADNESS" -EOM + EOM file "cookbooks/x/metadata.json", <<~EOM { "name": "x", "version": "0.0.1" } -EOM + EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end it "the chef client run should succeed" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! end it "a chef-solo run should succeed" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! end end @@ -603,30 +601,30 @@ EOM EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end it "a chef client run should not log to info by default" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef client run to a pipe should not log to info by default" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork | tee #{path_to("chefrun.out")}", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef solo run should not log to info by default" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end it "a chef solo run to a pipe should not log to info by default" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork | tee #{path_to("chefrun.out")}", cwd: chef_dir) command.error! expect(command.stdout).not_to include("INFO") end @@ -636,45 +634,45 @@ EOM before do file "cookbooks/x/recipes/default.rb", <<~EOM puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK" -EOM + EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end it "chef-client runs by default with no supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo runs by default with no supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-client --no-fork does not fork" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo --no-fork does not fork" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-client with --fork uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --fork", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end it "chef-solo with --fork uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --fork", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end @@ -684,22 +682,22 @@ EOM before do file "cookbooks/x/recipes/default.rb", <<~EOM puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK" -EOM + EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" client_fork true -EOM + EOM end it "chef-client uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end it "chef-solo uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("WITHFORK") end @@ -709,22 +707,22 @@ EOM before do file "cookbooks/x/recipes/default.rb", <<~EOM puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK" -EOM + EOM file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" client_fork false -EOM + EOM end it "chef-client uses a supervisor" do - command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end it "chef-solo uses a supervisor" do - command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir) + command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir) command.error! expect(command.stdout).to include("NOFORK") end diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb index d310a56973..99e56169aa 100644 --- a/spec/integration/client/exit_code_spec.rb +++ b/spec/integration/client/exit_code_spec.rb @@ -30,21 +30,21 @@ describe "chef-client" do def setup_client_rb file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + EOM end def setup_client_rb_with_audit_mode file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" audit_mode :audit_only silence_deprecation_warnings %w{chef-27} -EOM + EOM end def run_chef_client_and_expect_exit_code(exit_code) - shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", + shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir, returns: [exit_code]) end @@ -73,7 +73,7 @@ EOM expect(4 - 4).to eq(1) end end -RECIPE + RECIPE end it "exits with AUDIT_MODE_FAILURE, 42" do @@ -115,7 +115,7 @@ RECIPE before do file "cookbooks/x/recipes/default.rb", <<~EOM raise Chef::Exceptions::Reboot.new -EOM + EOM end it "exits with REBOOT_SCHEDULED, 35" do @@ -128,7 +128,7 @@ EOM before do file "cookbooks/x/recipes/default.rb", <<~EOM raise Chef::Exceptions::RebootFailed.new -EOM + EOM end it "exits with REBOOT_FAILED, 41" do diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb index c3cb73e4fa..2d16786334 100644 --- a/spec/integration/client/ipv6_spec.rb +++ b/spec/integration/client/ipv6_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,7 +53,7 @@ describe "chef-client" do syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA= -----END RSA PRIVATE KEY----- -END_VALIDATION_PEM + END_VALIDATION_PEM end let(:cache_path) do @@ -63,10 +63,10 @@ END_VALIDATION_PEM let(:basic_config_file) do <<~END_CLIENT_RB chef_server_url "http://[::1]:8900" - validation_key '#{path_to('config/validator.pem')}' + validation_key '#{path_to("config/validator.pem")}' cache_path '#{cache_path}' client_key '#{cache_path}/client.pem' -END_CLIENT_RB + END_CLIENT_RB end let(:client_rb_content) do @@ -75,7 +75,7 @@ END_CLIENT_RB let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") } - let(:chef_client_cmd) { %Q{ruby '#{chef_dir}/chef-client' --minimal-ohai -c "#{path_to('config/client.rb')}" -lwarn} } + let(:chef_client_cmd) { %Q{bundle exec chef-client --minimal-ohai -c "#{path_to("config/client.rb")}" -lwarn} } after do FileUtils.rm_rf(cache_path) diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb index 79b0307e0d..58ca5121c5 100644 --- a/spec/integration/knife/chef_fs_data_store_spec.rb +++ b/spec/integration/knife/chef_fs_data_store_spec.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -107,7 +107,7 @@ describe "ChefFSDataStore tests", :workstation do /policy_groups/x.json /roles/ /roles/x.json -EOM + EOM end end @@ -185,47 +185,47 @@ EOM end it "knife raw -z -i empty.json -m PUT /clients/x" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_succeed( /"x"/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /clients/x").should_succeed( /"x"/ ) knife("list --local /clients").should_succeed "/clients/x.json\n" end it "knife cookbook upload works" do - knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed stderr: <<~EOM + knife("cookbook upload -z --cookbook-path #{path_to("cookbooks_to_upload")} x").should_succeed stderr: <<~EOM Uploading x [1.0.0] Uploaded 1 cookbook. -EOM + EOM knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n" end it "knife raw -z -i empty.json -m PUT /data/x/y" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_succeed( /"y"/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /data/x/y").should_succeed( /"y"/ ) knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/y.json\n" end it "knife raw -z -i empty.json -m PUT /environments/x" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_succeed( /"x"/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /environments/x").should_succeed( /"x"/ ) knife("list --local /environments").should_succeed "/environments/x.json\n" end it "knife raw -z -i dummynode.json -m PUT /nodes/x" do - knife("raw -z -i #{path_to('dummynode.json')} -m PUT /nodes/x").should_succeed( /"x"/ ) + knife("raw -z -i #{path_to("dummynode.json")} -m PUT /nodes/x").should_succeed( /"x"/ ) knife("list --local /nodes").should_succeed "/nodes/x.json\n" knife("show -z /nodes/x.json --verbose").should_succeed(/"bar"/) end it "knife raw -z -i empty.json -m PUT /roles/x" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_succeed( /"x"/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /roles/x").should_succeed( /"x"/ ) knife("list --local /roles").should_succeed "/roles/x.json\n" end - it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do - knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty" do + knife("raw -z -i #{path_to("rolestuff.json")} -m PUT /roles/x").should_succeed( /"x"/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip { "name": "x", "description": "hi there" } -EOM + EOM end end end @@ -242,53 +242,53 @@ EOM end it "knife raw -z -i empty.json -m POST /clients" do - knife("raw -z -i #{path_to('empty.json')} -m POST /clients").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty.json")} -m POST /clients").should_succeed( /uri/ ) knife("list --local /clients").should_succeed "/clients/z.json\n" end it "knife cookbook upload works" do - knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed stderr: <<~EOM + knife("cookbook upload -z --cookbook-path #{path_to("cookbooks_to_upload")} z").should_succeed stderr: <<~EOM Uploading z [1.0.0] Uploaded 1 cookbook. -EOM + EOM knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n" end it "knife raw -z -i empty.json -m POST /data" do - knife("raw -z -i #{path_to('empty.json')} -m POST /data").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty.json")} -m POST /data").should_succeed( /uri/ ) knife("list --local -Rfp /data_bags").should_succeed "/data_bags/z/\n" end it "knife raw -z -i empty.json -m POST /data/x" do - knife("raw -z -i #{path_to('empty_x.json')} -m POST /data").should_succeed( /uri/ ) - knife("raw -z -i #{path_to('empty_id.json')} -m POST /data/x").should_succeed( /"z"/ ) + knife("raw -z -i #{path_to("empty_x.json")} -m POST /data").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty_id.json")} -m POST /data/x").should_succeed( /"z"/ ) knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/z.json\n" end it "knife raw -z -i empty.json -m POST /environments" do - knife("raw -z -i #{path_to('empty.json')} -m POST /environments").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty.json")} -m POST /environments").should_succeed( /uri/ ) knife("list --local /environments").should_succeed "/environments/z.json\n" end it "knife raw -z -i dummynode.json -m POST /nodes" do - knife("raw -z -i #{path_to('dummynode.json')} -m POST /nodes").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("dummynode.json")} -m POST /nodes").should_succeed( /uri/ ) knife("list --local /nodes").should_succeed "/nodes/z.json\n" knife("show -z /nodes/z.json").should_succeed(/"bar"/) end it "knife raw -z -i empty.json -m POST /roles" do - knife("raw -z -i #{path_to('empty.json')} -m POST /roles").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty.json")} -m POST /roles").should_succeed( /uri/ ) knife("list --local /roles").should_succeed "/roles/z.json\n" end - it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", skip: (RUBY_VERSION < "1.9") do - knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ ) + it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty" do + knife("raw -z -i #{path_to("rolestuff.json")} -m POST /roles").should_succeed( /uri/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip { "name": "x", "description": "hi there" } -EOM + EOM end end @@ -321,7 +321,7 @@ EOM /policies/ /policy_groups/ /roles/ -EOM + EOM end context "DELETE /TYPE/NAME" do @@ -388,23 +388,23 @@ EOM end it "knife raw -z -i empty.json -m PUT /clients/x fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /clients/x").should_fail( /404/ ) end it "knife raw -z -i empty.json -m PUT /data/x/y fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /data/x/y").should_fail( /404/ ) end it "knife raw -z -i empty.json -m PUT /environments/x fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /environments/x").should_fail( /404/ ) end it "knife raw -z -i empty.json -m PUT /nodes/x fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /nodes/x").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /nodes/x").should_fail( /404/ ) end it "knife raw -z -i empty.json -m PUT /roles/x fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /roles/x").should_fail( /404/ ) end end @@ -459,7 +459,7 @@ EOM /roles/x.json /users/ /users/x.json -EOM + EOM end end @@ -485,18 +485,18 @@ EOM end it "knife raw -z -i empty.json -m PUT /users/x" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_succeed( /"x"/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /users/x").should_succeed( /"x"/ ) knife("list --local /users").should_succeed "/users/x.json\n" end - it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do - knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty" do + knife("raw -z -i #{path_to("rolestuff.json")} -m PUT /roles/x").should_succeed( /"x"/ ) expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip { "name": "x", "description": "hi there" } -EOM + EOM end end end @@ -513,7 +513,7 @@ EOM end it "knife raw -z -i empty.json -m POST /users" do - knife("raw -z -i #{path_to('empty.json')} -m POST /users").should_succeed( /uri/ ) + knife("raw -z -i #{path_to("empty.json")} -m POST /users").should_succeed( /uri/ ) knife("list --local /users").should_succeed "/users/z.json\n" end end @@ -527,7 +527,7 @@ EOM /nodes/ /roles/ /users/ -EOM + EOM end context "DELETE /TYPE/NAME" do @@ -548,7 +548,7 @@ EOM end it "knife raw -z -i empty.json -m PUT /users/x fails with 404" do - knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_fail( /404/ ) + knife("raw -z -i #{path_to("empty.json")} -m PUT /users/x").should_fail( /404/ ) end end end diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb index 9eb4e28df1..7d98b7ad4e 100644 --- a/spec/integration/knife/chef_repo_path_spec.rb +++ b/spec/integration/knife/chef_repo_path_spec.rb @@ -59,7 +59,7 @@ describe "chef_repo_path tests", :workstation do it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do Chef::Config.delete(:chef_repo_path) - knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM + knife("list --local -Rfp --chef-repo-path #{path_to("chef_repo2")} /").should_succeed <<~EOM /clients/ /clients/client3.json /cookbooks/ @@ -76,13 +76,13 @@ describe "chef_repo_path tests", :workstation do /roles/role3.json /users/ /users/user3.json -EOM + EOM end # "Skipping for BK... As Windows 2019 has 8dot3name disabled by default" it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only, :skip_buildkite do Chef::Config.delete(:chef_repo_path) - knife("list --local -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM + knife("list --local -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM /clients/ /clients/client3.json /cookbooks/ @@ -99,13 +99,13 @@ EOM /roles/role3.json /users/ /users/user3.json -EOM + EOM end # "Skipping for BK... As Windows 2019 has 8dot3name disabled by default" it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only, :skip_buildkite do Chef::Config.delete(:chef_repo_path) - knife("list -z -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM + knife("list -z -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM /acls/ /acls/clients/ /acls/clients/client3.json @@ -147,7 +147,7 @@ EOM /policy_groups/ /roles/ /roles/role3.json -EOM + EOM end context "when all _paths are set to alternates" do @@ -159,7 +159,7 @@ EOM end it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do - knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM + knife("list --local -Rfp --chef-repo-path #{path_to("chef_repo2")} /").should_succeed <<~EOM /clients/ /clients/client3.json /cookbooks/ @@ -176,7 +176,7 @@ EOM /roles/role3.json /users/ /users/user3.json -EOM + EOM end context "when cwd is at the top level" do @@ -213,7 +213,7 @@ EOM roles/role2.json users/ users/user2.json -EOM + EOM end end @@ -223,7 +223,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag2/ bag2/item2.json -EOM + EOM end it "knife list --local -Rfp ../roles lists roles" do knife("list --local -Rfp ../roles").should_succeed "/roles/role2.json\n" @@ -258,7 +258,7 @@ EOM roles/role2.json users/ users/user2.json -EOM + EOM end end @@ -282,7 +282,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag2/ bag2/item2.json -EOM + EOM end end end @@ -329,7 +329,7 @@ EOM roles/role3.json users/ users/user3.json -EOM + EOM end end @@ -339,7 +339,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag3/ bag3/item3.json -EOM + EOM end end end @@ -366,7 +366,7 @@ EOM { } -EOM + EOM end end @@ -383,7 +383,7 @@ EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/ /cookbooks/cookbook2/metadata.rb -EOM + EOM end end @@ -400,7 +400,7 @@ EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/ /cookbooks/cookbook2/metadata.rb -EOM + EOM end end @@ -417,7 +417,7 @@ EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/ /cookbooks/cookbook2/metadata.rb -EOM + EOM end end @@ -434,7 +434,7 @@ EOM /data_bags/bag2/item2.json /data_bags/blah/ /data_bags/blah/item.json -EOM + EOM end end @@ -451,7 +451,7 @@ EOM /data_bags/bag2/item2.json /data_bags/blah/ /data_bags/blah/item1.json -EOM + EOM end end @@ -466,7 +466,7 @@ EOM { } -EOM + EOM end end @@ -481,7 +481,7 @@ EOM { } -EOM + EOM end end @@ -496,7 +496,7 @@ EOM { } -EOM + EOM end end @@ -511,7 +511,7 @@ EOM { } -EOM + EOM end end @@ -530,7 +530,7 @@ EOM bag/item.json bag2/ bag2/item2.json -EOM + EOM end end @@ -563,7 +563,7 @@ EOM users/ users/user1.json users/user2.json -EOM + EOM end end @@ -575,7 +575,7 @@ EOM bag/item.json bag2/ bag2/item2.json -EOM + EOM end end end @@ -620,7 +620,7 @@ EOM users/ users/user1.json users/user3.json -EOM + EOM end end @@ -632,7 +632,7 @@ EOM bag/item.json bag3/ bag3/item3.json -EOM + EOM end end @@ -665,7 +665,7 @@ EOM users/ users/user1.json users/user3.json -EOM + EOM end end @@ -677,7 +677,7 @@ EOM bag/item.json bag3/ bag3/item3.json -EOM + EOM end end end @@ -725,7 +725,7 @@ EOM roles/role3.json users/ users/user3.json -EOM + EOM end end @@ -735,7 +735,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag3/ bag3/item3.json -EOM + EOM end end end @@ -781,7 +781,7 @@ EOM users/ users/user1.json users/user3.json -EOM + EOM end end @@ -793,7 +793,7 @@ EOM bag/item.json bag3/ bag3/item3.json -EOM + EOM end end @@ -826,7 +826,7 @@ EOM users/ users/user1.json users/user3.json -EOM + EOM end end @@ -838,7 +838,7 @@ EOM bag/item.json bag3/ bag3/item3.json -EOM + EOM end end end @@ -865,7 +865,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag/ bag/item.json -EOM + EOM end end @@ -889,7 +889,7 @@ EOM roles/role3.json users/ users/user3.json -EOM + EOM end end @@ -917,14 +917,14 @@ EOM /data_bags/ /data_bags/bag/ /data_bags/bag/item.json -EOM + EOM end it "knife list --local -Rfp /data_bags lists data bags" do knife("list --local -Rfp /data_bags").should_succeed <<~EOM /data_bags/bag/ /data_bags/bag/item.json -EOM + EOM end context "when cwd is inside the data_bags directory" do @@ -933,7 +933,7 @@ EOM knife("list --local -Rfp").should_succeed <<~EOM bag/ bag/item.json -EOM + EOM end end end diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb index 538d6c5a63..6e9c4611e2 100644 --- a/spec/integration/knife/chef_repository_file_system_spec.rb +++ b/spec/integration/knife/chef_repository_file_system_spec.rb @@ -37,7 +37,7 @@ describe "General chef_repo file system checks", :workstation do /data_bags/bag1/ /environments/ /roles/ -EOM + EOM end end @@ -55,7 +55,7 @@ EOM it "knife list --local -Rfp / does not return it" do knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ -EOM + EOM end end @@ -65,7 +65,7 @@ EOM it "knife list --local -Rfp / does not return it" do knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ -EOM + EOM end end @@ -82,7 +82,7 @@ EOM /cookbooks/cookbook1/templates/ /cookbooks/cookbook1/templates/default/ /cookbooks/cookbook1/templates/default/x.txt -EOM + EOM end end @@ -92,7 +92,7 @@ EOM it "knife list --local -Rfp / does not return it" do knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ -EOM + EOM end end @@ -110,7 +110,7 @@ EOM /cookbooks/cookbook1/templates/ /cookbooks/cookbook1/templates/default/ /cookbooks/cookbook1/templates/default/x.txt -EOM + EOM end end @@ -154,7 +154,7 @@ EOM /environments/environment1.json /roles/ /roles/role1.json -EOM + EOM end end @@ -163,7 +163,7 @@ EOM it "does not show up in list -Rfp" do knife("list --local -Rfp /").should_succeed <<~EOM /cookbooks/ -EOM + EOM end end @@ -172,7 +172,7 @@ EOM it "does not show up in list -Rfp" do knife("list --local -Rfp /").should_succeed <<~EOM /data_bags/ -EOM + EOM end end end diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb index eb36f4675f..b92fb1f485 100644 --- a/spec/integration/knife/chefignore_spec.rb +++ b/spec/integration/knife/chefignore_spec.rb @@ -56,7 +56,7 @@ describe "chefignore tests", :workstation do /environments/x.json /roles/ /roles/x.json -EOM + EOM end end end @@ -71,7 +71,7 @@ EOM it "the cookbook is not listed" do knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ -EOM + EOM end end @@ -93,7 +93,7 @@ EOM /cookbooks/cookbook1/y.json /cookbooks/cookbook2/ /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -110,7 +110,7 @@ EOM /cookbooks/cookbook1/y.json /cookbooks/cookbook2/ /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -132,7 +132,7 @@ EOM /cookbooks/cookbook2/recipes/y.rb /cookbooks/cookbook2/x.json /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -153,7 +153,7 @@ EOM /cookbooks/cookbook2/ /cookbooks/cookbook2/x.json /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -173,7 +173,7 @@ EOM /cookbooks/cookbook2/ /cookbooks/cookbook2/x.json /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -191,7 +191,7 @@ EOM /cookbooks/cookbook2/ /cookbooks/cookbook2/x.json /cookbooks/cookbook2/y.json -EOM + EOM end end @@ -207,7 +207,7 @@ EOM /cookbooks/cookbook1/y.json /cookbooks/cookbook2/ /cookbooks/cookbook2/y.json -EOM + EOM end end end @@ -239,7 +239,7 @@ EOM /cookbooks/mycookbook/x.json /cookbooks/yourcookbook/ /cookbooks/yourcookbook/metadata.rb -EOM + EOM end context "and conflicting cookbooks" do @@ -258,7 +258,7 @@ EOM /cookbooks/yourcookbook/ /cookbooks/yourcookbook/onlyincookbooks1.rb /cookbooks/yourcookbook/x.json -EOM + EOM end end end @@ -272,7 +272,7 @@ EOM knife("list --local -Rfp /cookbooks").should_succeed <<~EOM /cookbooks/chefignore/ /cookbooks/chefignore/metadata.rb -EOM + EOM end end @@ -294,7 +294,7 @@ EOM /cookbooks/blah/metadata.rb /cookbooks/chefignore/ /cookbooks/chefignore/metadata.rb -EOM + EOM end end end diff --git a/spec/integration/knife/client_bulk_delete_spec.rb b/spec/integration/knife/client_bulk_delete_spec.rb index 42bfe0396a..73dd1680b2 100644 --- a/spec/integration/knife/client_bulk_delete_spec.rb +++ b/spec/integration/knife/client_bulk_delete_spec.rb @@ -40,7 +40,7 @@ describe "knife client bulk delete", :workstation do Are you sure you want to delete these clients? (Y/N) Deleted client car Deleted client cat -EOM + EOM knife("client list").should_succeed <<~EOM cdr @@ -48,7 +48,7 @@ EOM chef-webui concat cons -EOM + EOM end it "deletes all matching clients when unanchored" do @@ -60,14 +60,14 @@ EOM Are you sure you want to delete these clients? (Y/N) Deleted client car Deleted client cat Deleted client concat -EOM + EOM knife("client list").should_succeed <<~EOM cdr chef-validator chef-webui cons -EOM + EOM end end @@ -93,7 +93,7 @@ EOM Are you sure you want to delete these clients? (Y/N) Deleted client car Deleted client cat -EOM + EOM knife("client list").should_succeed <<~EOM car-validator @@ -101,7 +101,7 @@ EOM chef-validator chef-webui cons -EOM + EOM end it "deletes a validator when told to" do @@ -117,14 +117,14 @@ EOM Are you sure you want to delete these clients? (Y/N) Deleted client car Deleted client cat -EOM + EOM knife("client list").should_succeed <<~EOM cdr chef-validator chef-webui cons -EOM + EOM end end end diff --git a/spec/integration/knife/client_create_spec.rb b/spec/integration/knife/client_create_spec.rb index 86609a63cd..505358923b 100644 --- a/spec/integration/knife/client_create_spec.rb +++ b/spec/integration/knife/client_create_spec.rb @@ -38,7 +38,7 @@ describe "knife client create", :workstation do chef_type: client name: bah validator: true -EOM + EOM end it "refuses to add an existing client" do diff --git a/spec/integration/knife/client_delete_spec.rb b/spec/integration/knife/client_delete_spec.rb index 914827cb46..3ba51fca96 100644 --- a/spec/integration/knife/client_delete_spec.rb +++ b/spec/integration/knife/client_delete_spec.rb @@ -35,7 +35,7 @@ describe "knife client delete", :workstation do it "deletes a client" do knife("client delete car", input: "Y").should_succeed <<~EOM Do you really want to delete car? (Y/N) Deleted client[car] -EOM + EOM knife("client list").should_succeed <<~EOM car-validator @@ -44,19 +44,19 @@ EOM chef-validator chef-webui cons -EOM + EOM end it "refuses to delete a validator normally" do knife("client delete car-validator", input: "Y").should_fail exit_code: 2, stdout: "Do you really want to delete car-validator? (Y/N) ", stderr: <<~EOM FATAL: You must specify --delete-validators to delete the validator client car-validator -EOM + EOM end it "deletes a validator correctly" do knife("client delete car-validator -D", input: "Y").should_succeed <<~EOM Do you really want to delete car-validator? (Y/N) Deleted client[car-validator] -EOM + EOM end end diff --git a/spec/integration/knife/client_key_delete_spec.rb b/spec/integration/knife/client_key_delete_spec.rb index 061a3fea76..04826bb0b8 100644 --- a/spec/integration/knife/client_key_delete_spec.rb +++ b/spec/integration/knife/client_key_delete_spec.rb @@ -33,7 +33,7 @@ describe "knife client key delete", :workstation do knife("client key create -k new car") knife("client key delete car new", input: "Y").should_succeed stdout: out, stderr: <<~EOM Deleted key named new for the client named car -EOM + EOM knife("client key list car").should_succeed "" end diff --git a/spec/integration/knife/client_key_list_spec.rb b/spec/integration/knife/client_key_list_spec.rb index 0969d5fb98..4fd18a6cd5 100644 --- a/spec/integration/knife/client_key_list_spec.rb +++ b/spec/integration/knife/client_key_list_spec.rb @@ -45,7 +45,7 @@ describe "knife client key list", :workstation do expired: http://127.0.0.1:8900/clients/cons/keys/expired (expired) new: http://127.0.0.1:8900/clients/cons/keys/new next_month: http://127.0.0.1:8900/clients/cons/keys/next_month -EOM + EOM end it "lists the expired keys for a client" do diff --git a/spec/integration/knife/client_list_spec.rb b/spec/integration/knife/client_list_spec.rb index 41cf8dcbb6..27ceecf7de 100644 --- a/spec/integration/knife/client_list_spec.rb +++ b/spec/integration/knife/client_list_spec.rb @@ -41,7 +41,7 @@ describe "knife client list", :workstation do chef-validator chef-webui cons -EOM + EOM end end diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb index e0622eb801..5eac571a85 100644 --- a/spec/integration/knife/common_options_spec.rb +++ b/spec/integration/knife/common_options_spec.rb @@ -95,7 +95,7 @@ describe "knife common options", :workstation do syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA= -----END RSA PRIVATE KEY----- -EOM + EOM end it "knife raw /nodes/x should retrieve the node" do diff --git a/spec/integration/knife/config_get_spec.rb b/spec/integration/knife/config_get_spec.rb index bdeabf96af..83150a39b8 100644 --- a/spec/integration/knife/config_get_spec.rb +++ b/spec/integration/knife/config_get_spec.rb @@ -150,7 +150,7 @@ describe "knife config get", :workstation do let(:cmd_args) { %w{node_name client_key} } before { file(".chef/credentials", "[default]\nclient_name = \"three\"\nclient_key = \"three.pem\"") } - it { is_expected.to match(/^client_key:\s+\S*\/.chef\/three.pem\nnode_name:\s+three\Z/) } + it { is_expected.to match(%r{^client_key:\s+\S*/.chef/three.pem\nnode_name:\s+three\Z}) } end context "with a dotted argument" do diff --git a/spec/integration/knife/config_list_profiles_spec.rb b/spec/integration/knife/config_list_profiles_spec.rb index 32846f9999..044b50b5be 100644 --- a/spec/integration/knife/config_list_profiles_spec.rb +++ b/spec/integration/knife/config_list_profiles_spec.rb @@ -183,6 +183,7 @@ describe "knife config list-profiles", :workstation do { "profile" => "default", "active" => true, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/testorg" }, { "profile" => "prod", "active" => false, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/prod" }, { "profile" => "qa", "active" => false, "client_name" => "qauser", "client_key" => path_to("src/qauser.pem"), "server_url" => "https://example.com/organizations/testorg" }, - ] } + ] + } end end diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb index 8c2b0208ae..c615d8de7a 100644 --- a/spec/integration/knife/cookbook_api_ipv6_spec.rb +++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb @@ -54,7 +54,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA= -----END RSA PRIVATE KEY----- -END_VALIDATION_PEM + END_VALIDATION_PEM end let(:cache_path) do @@ -77,10 +77,10 @@ END_VALIDATION_PEM <<~END_CLIENT_RB chef_server_url "http://[::1]:8900" syntax_check_cache_path '#{cache_path}' - client_key '#{path_to('config/knifeuser.pem')}' + client_key '#{path_to("config/knifeuser.pem")}' node_name 'whoisthisis' cookbook_path '#{CHEF_SPEC_DATA}/cookbooks' -END_CLIENT_RB + END_CLIENT_RB end before do diff --git a/spec/integration/knife/cookbook_bulk_delete_spec.rb b/spec/integration/knife/cookbook_bulk_delete_spec.rb index d3180c788f..5b8dc3a952 100644 --- a/spec/integration/knife/cookbook_bulk_delete_spec.rb +++ b/spec/integration/knife/cookbook_bulk_delete_spec.rb @@ -42,21 +42,21 @@ describe "knife cookbook bulk delete", :workstation do foo fox Do you really want to delete these cookbooks? (Y/N) -EOM + EOM stderr = <<~EOM Deleted cookbook foo [1.0.0] Deleted cookbook foo [0.6.5] Deleted cookbook fox [0.6.5] Deleted cookbook fox [0.6.0] -EOM + EOM knife("cookbook bulk delete ^fo.*", input: "Y").should_succeed(stderr: stderr, stdout: stdout) knife("cookbook list -a").should_succeed <<~EOM fax 0.6.0 zfa 0.6.5 -EOM + EOM end # rubocop:enable Layout/TrailingWhitespace diff --git a/spec/integration/knife/cookbook_download_spec.rb b/spec/integration/knife/cookbook_download_spec.rb index 2dbf9e5ae5..538c06802b 100644 --- a/spec/integration/knife/cookbook_download_spec.rb +++ b/spec/integration/knife/cookbook_download_spec.rb @@ -37,7 +37,7 @@ describe "knife cookbook download", :workstation do Downloading x cookbook version 1.0.1 Downloading root_files Cookbook downloaded to #{tmpdir}/x-1.0.1 -EOM + EOM end it "knife cookbook download with a version downloads the specified version" do @@ -45,7 +45,7 @@ EOM Downloading x cookbook version 1.0.1 Downloading root_files Cookbook downloaded to #{tmpdir}/x-1.0.1 -EOM + EOM end it "knife cookbook download with an unknown version raises an error" do @@ -64,8 +64,8 @@ EOM Downloading x cookbook version 1.0.1 Downloading root_files Cookbook downloaded to #{tmpdir}/x-1.0.1 -EOM -) + EOM + ) end end end diff --git a/spec/integration/knife/cookbook_list_spec.rb b/spec/integration/knife/cookbook_list_spec.rb index afea745bce..c9e4069a44 100644 --- a/spec/integration/knife/cookbook_list_spec.rb +++ b/spec/integration/knife/cookbook_list_spec.rb @@ -39,7 +39,7 @@ describe "knife cookbook list", :workstation do x 1.0.0 y 0.6.5 z 0.6.5 -EOM + EOM end it "knife cookbook list -a shows all the versions of all the cookbooks" do @@ -47,7 +47,7 @@ EOM x 1.0.0 0.6.5 0.6.0 y 0.6.5 0.6.0 z 0.6.5 -EOM + EOM end end diff --git a/spec/integration/knife/cookbook_show_spec.rb b/spec/integration/knife/cookbook_show_spec.rb index a8e87204e4..7b894efe30 100644 --- a/spec/integration/knife/cookbook_show_spec.rb +++ b/spec/integration/knife/cookbook_show_spec.rb @@ -82,7 +82,7 @@ describe "knife cookbook show", :workstation do specificity: default url: http://127.0.0.1:8900/file_store/checksums/8226671f751ba102dea6a6b6bd32fa8d version: 1.0.0 -EOM + EOM end it "knife cookbook show x 1.0.0 metadata shows the metadata" do @@ -109,7 +109,7 @@ EOM x::x: source_url: version: 1.0.0 -EOM + EOM end it "knife cookbook show x 1.0.0 recipes shows all the recipes" do @@ -125,7 +125,7 @@ EOM path: recipes/x.rb specificity: default url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e -EOM + EOM end # rubocop:enable Layout/TrailingWhitespace diff --git a/spec/integration/knife/cookbook_upload_spec.rb b/spec/integration/knife/cookbook_upload_spec.rb index e96884e786..7e98b6ea64 100644 --- a/spec/integration/knife/cookbook_upload_spec.rb +++ b/spec/integration/knife/cookbook_upload_spec.rb @@ -36,14 +36,14 @@ describe "knife cookbook upload", :workstation do knife("cookbook upload x -o #{cb_dir}").should_succeed stderr: <<~EOM Uploading x [1.0.0] Uploaded 1 cookbook. -EOM + EOM end it "knife cookbook upload --freeze uploads and freezes the cookbook" do knife("cookbook upload x -o #{cb_dir} --freeze").should_succeed stderr: <<~EOM Uploading x [1.0.0] Uploaded 1 cookbook. -EOM + EOM # Modify the file, attempt to reupload file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different' knife("cookbook upload x -o #{cb_dir} --freeze").should_fail stderr: <<~EOM @@ -51,7 +51,7 @@ EOM ERROR: Version 1.0.0 of cookbook x is frozen. Use --force to override. WARNING: Not updating version constraints for x in the environment as the cookbook is frozen. ERROR: Failed to upload 1 cookbook. -EOM + EOM end end @@ -66,7 +66,7 @@ EOM Uploading x [1.0.0] Uploading y [1.0.0] Uploaded 2 cookbooks. -EOM + EOM end it "knife cookbook upload fails due to missing dependencies" do @@ -75,7 +75,7 @@ EOM ERROR: Cookbook x depends on cookbooks which are not currently ERROR: being uploaded and cannot be found on the server. ERROR: The missing cookbook(s) are: 'y' version '>= 0.0.0' -EOM + EOM end it "knife cookbook upload -a uploads both cookbooks" do @@ -83,7 +83,7 @@ EOM Uploading x [1.0.0] Uploading y [1.0.0] Uploaded all cookbooks. -EOM + EOM end end end diff --git a/spec/integration/knife/data_bag_delete_spec.rb b/spec/integration/knife/data_bag_delete_spec.rb index f0ca05a3e4..b5ee1b0422 100644 --- a/spec/integration/knife/data_bag_delete_spec.rb +++ b/spec/integration/knife/data_bag_delete_spec.rb @@ -34,25 +34,25 @@ describe "knife data bag delete", :workstation do it "with an empty data bag" do knife("data bag delete canteloupe", input: "y").should_succeed <<~EOM Do you really want to delete canteloupe? (Y/N) Deleted data_bag[canteloupe] -EOM + EOM end it "with a bag with some items" do knife("data bag delete rocket", input: "y").should_succeed <<~EOM Do you really want to delete rocket? (Y/N) Deleted data_bag[rocket] -EOM + EOM end it "with a single item" do knife("data bag delete rocket falcon9", input: "y").should_succeed <<~EOM Do you really want to delete falcon9? (Y/N) Deleted data_bag_item[falcon9] -EOM + EOM end it "choosing not to delete" do knife("data bag delete rocket falcon9", input: "n").should_succeed <<~EOM, exit_code: 3 Do you really want to delete falcon9? (Y/N) You said no, so I'm done here. -EOM + EOM end end end diff --git a/spec/integration/knife/data_bag_from_file_spec.rb b/spec/integration/knife/data_bag_from_file_spec.rb index afaafc1e6b..5083153e91 100644 --- a/spec/integration/knife/data_bag_from_file_spec.rb +++ b/spec/integration/knife/data_bag_from_file_spec.rb @@ -47,7 +47,7 @@ describe "knife data bag from file", :workstation do "cipher": "aes-256-cbc" } } -EOM + EOM file "data_bags/bar/round_trip.json", <<~EOM { "name": "data_bag_item_bar_round_trip", @@ -70,33 +70,33 @@ EOM } } } -EOM + EOM end it "uploads a single file" do knife("data bag from file foo #{db_dir}/foo/bar.json").should_succeed stderr: <<~EOM Updated data_bag_item[foo::bar] -EOM + EOM end it "uploads a single encrypted file" do knife("data bag from file foo #{db_dir}/foo/encrypted.json").should_succeed stderr: <<~EOM Updated data_bag_item[foo::encrypted] -EOM + EOM end it "uploads a file in chef's internal format" do pending "chef/chef#4815" knife("data bag from file bar #{db_dir}/bar/round_trip.json").should_succeed stderr: <<~EOM Updated data_bag_item[bar::round_trip] -EOM + EOM end it "uploads many files" do knife("data bag from file foo #{db_dir}/foo/bar.json #{db_dir}/foo/bzr.json").should_succeed stderr: <<~EOM Updated data_bag_item[foo::bar] Updated data_bag_item[foo::bzr] -EOM + EOM end it "uploads a whole directory" do @@ -107,7 +107,7 @@ EOM cat dog encrypted -EOM + EOM end end diff --git a/spec/integration/knife/data_bag_list_spec.rb b/spec/integration/knife/data_bag_list_spec.rb index 4a2b740937..2e57cc7cca 100644 --- a/spec/integration/knife/data_bag_list_spec.rb +++ b/spec/integration/knife/data_bag_list_spec.rb @@ -36,7 +36,7 @@ describe "knife data bag list", :workstation do canteloupe rocket x -EOM + EOM end end diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb index 2e3efcf693..fd5853dfef 100644 --- a/spec/integration/knife/delete_spec.rb +++ b/spec/integration/knife/delete_spec.rb @@ -43,7 +43,7 @@ describe "knife delete", :workstation do /roles/x.json /users /users/x.json -EOM + EOM end let :server_everything do @@ -68,7 +68,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM end let :server_nothing do <<~EOM @@ -83,7 +83,7 @@ EOM /roles /users /users/admin.json -EOM + EOM end let :nothing do @@ -95,7 +95,7 @@ EOM /nodes /roles /users -EOM + EOM end when_the_chef_server "has one of each thing" do @@ -125,7 +125,7 @@ EOM knife("delete --both /cookbooks/x").should_fail <<~EOM ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete. -EOM + EOM knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed everything end @@ -151,7 +151,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM /clients /clients/x.json @@ -168,7 +168,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete -r --local /cookbooks/x deletes x locally but not remotely" do @@ -190,7 +190,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete -r /cookbooks/x deletes x remotely but not locally" do @@ -214,7 +214,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed everything end @@ -229,7 +229,7 @@ EOM knife("delete --both /data_bags/empty").should_fail <<~EOM ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/empty (local) must be deleted recursively! Pass -r to knife delete. -EOM + EOM knife("list -Rf /").should_succeed <<~EOM /clients /clients/chef-validator.json @@ -252,7 +252,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM /clients /clients/x.json @@ -272,7 +272,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end end @@ -280,7 +280,7 @@ EOM knife("delete --both /data_bags/x").should_fail <<~EOM ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete. -EOM + EOM knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed everything end @@ -306,7 +306,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM /clients /clients/x.json @@ -323,7 +323,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /environments/x.json deletes x" do @@ -348,7 +348,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM /clients /clients/x.json @@ -366,7 +366,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /roles/x.json deletes x" do @@ -391,7 +391,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM /clients /clients/x.json @@ -409,7 +409,7 @@ EOM /roles /users /users/x.json -EOM + EOM end it "knife delete --both /environments/_default.json fails but still deletes the local copy" do @@ -432,7 +432,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /environments/nonexistent.json fails" do @@ -445,7 +445,7 @@ EOM knife("delete --both /").should_fail <<~EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. -EOM + EOM knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed everything end @@ -468,7 +468,7 @@ EOM ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. -EOM + EOM knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed everything end @@ -512,7 +512,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed nothing end @@ -543,7 +543,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed nothing end @@ -569,7 +569,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed nothing end @@ -595,7 +595,7 @@ EOM /users /users/admin.json /users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed nothing end @@ -629,7 +629,7 @@ EOM ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. -EOM + EOM knife("list -Rf /").should_succeed server_everything knife("list -Rf --local /").should_succeed nothing end @@ -665,7 +665,7 @@ EOM users users/admin.json users/x.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM clients cookbooks @@ -674,7 +674,7 @@ EOM nodes roles users -EOM + EOM end end end @@ -718,7 +718,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /data_bags/x fails" do @@ -746,7 +746,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /environments/x.json deletes x" do @@ -769,7 +769,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both /roles/x.json deletes x" do @@ -792,7 +792,7 @@ EOM /roles /users /users/x.json -EOM + EOM end it "knife delete --both /environments/_default.json fails but still deletes the local copy" do @@ -815,7 +815,7 @@ EOM /roles/x.json /users /users/x.json -EOM + EOM end it "knife delete --both / fails" do @@ -842,7 +842,7 @@ EOM ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. -EOM + EOM knife("list -Rf /").should_succeed server_nothing knife("list -Rf --local /").should_succeed everything end @@ -869,7 +869,7 @@ EOM roles users users/admin.json -EOM + EOM knife("list -Rf --local /").should_succeed <<~EOM clients clients/x.json @@ -888,7 +888,7 @@ EOM roles/x.json users users/x.json -EOM + EOM end end end diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index b7eafcbd1c..4dfccf38de 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -46,7 +46,7 @@ describe "knife deps", :workstation do /cookbooks/quiche /cookbooks/soup /roles/starring.json -EOM + EOM end end @@ -65,7 +65,7 @@ EOM /cookbooks/quiche /cookbooks/soup /roles/starring.json -EOM + EOM end end @@ -99,7 +99,7 @@ EOM /cookbooks/quiche /cookbooks/soup /nodes/mort.json -EOM + EOM end end when_the_repository "has a cookbook with no dependencies" do @@ -155,7 +155,7 @@ depends "kettle"' /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps * reports all dependencies of all things" do knife("deps /nodes/*").should_succeed <<~EOM @@ -166,7 +166,7 @@ EOM /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps a b reports all dependencies of a and b" do knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<~EOM @@ -177,7 +177,7 @@ EOM /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps --tree /* shows dependencies in a tree" do knife("deps --tree /nodes/*").should_succeed <<~EOM @@ -189,7 +189,7 @@ EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup -EOM + EOM end it "knife deps --tree --no-recurse shows only the first level of dependencies" do knife("deps --tree --no-recurse /nodes/*").should_succeed <<~EOM @@ -198,7 +198,7 @@ EOM /nodes/mort.json /environments/desert.json /roles/starring.json -EOM + EOM end end @@ -237,7 +237,7 @@ depends "foo"' /roles/bar.json /roles/foo.json /roles/self.json -EOM + EOM end it "knife deps --tree prints each once" do knife("deps --tree /roles/foo.json /roles/self.json") do @@ -383,7 +383,7 @@ EOM /cookbooks/quiche /cookbooks/soup /roles/starring.json -EOM + EOM end end @@ -400,7 +400,7 @@ EOM /cookbooks/quiche /cookbooks/soup /roles/starring.json -EOM + EOM end end @@ -432,7 +432,7 @@ EOM /cookbooks/quiche /cookbooks/soup /nodes/mort.json -EOM + EOM end end when_the_chef_server "has a cookbook with no dependencies" do @@ -484,7 +484,7 @@ depends "kettle"', "recipes" => { "default.rb" => "" } } /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps * reports all dependencies of all things" do knife("deps --remote /nodes/*").should_succeed <<~EOM @@ -495,7 +495,7 @@ EOM /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps a b reports all dependencies of a and b" do knife("deps --remote /nodes/bart.json /nodes/mort.json").should_succeed <<~EOM @@ -506,7 +506,7 @@ EOM /cookbooks/soup /roles/starring.json /nodes/mort.json -EOM + EOM end it "knife deps --tree /* shows dependencies in a tree" do knife("deps --remote --tree /nodes/*").should_succeed <<~EOM @@ -518,7 +518,7 @@ EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup -EOM + EOM end it "knife deps --tree --no-recurse shows only the first level of dependencies" do knife("deps --remote --tree --no-recurse /nodes/*").should_succeed <<~EOM @@ -527,18 +527,18 @@ EOM /nodes/mort.json /environments/desert.json /roles/starring.json -EOM + EOM end end context "circular dependencies" do when_the_chef_server "has cookbooks with circular dependencies" do before do - cookbook "foo", "1.0.0", { "metadata.rb" => 'name "foo" + cookbook "foo", "1.0.0", { "metadata.rb" => 'name "foo" depends "bar"' } - cookbook "bar", "1.0.0", { "metadata.rb" => 'name "bar" + cookbook "bar", "1.0.0", { "metadata.rb" => 'name "bar" depends "baz"' } - cookbook "baz", "1.0.0", { "metadata.rb" => 'name "baz" + cookbook "baz", "1.0.0", { "metadata.rb" => 'name "baz" depends "foo"' } cookbook "self", "1.0.0", { "metadata.rb" => 'name "self" depends "self"' } @@ -549,7 +549,7 @@ depends "self"' } /cookbooks/bar /cookbooks/foo /cookbooks/self -EOM + EOM end it "knife deps --tree prints each once" do knife("deps --remote --tree /cookbooks/foo /cookbooks/self").should_succeed <<~EOM @@ -559,7 +559,7 @@ EOM /cookbooks/foo /cookbooks/self /cookbooks/self -EOM + EOM end end when_the_chef_server "has roles with circular dependencies" do @@ -575,7 +575,7 @@ EOM /roles/bar.json /roles/foo.json /roles/self.json -EOM + EOM end it "knife deps --tree prints each once" do knife("deps --remote --tree /roles/foo.json /roles/self.json") do diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb index 9e54558300..28fe839def 100644 --- a/spec/integration/knife/diff_spec.rb +++ b/spec/integration/knife/diff_spec.rb @@ -58,7 +58,7 @@ describe "knife diff", :workstation do D\t/roles/x.json D\t/users/admin.json D\t/users/x.json -EOM + EOM end end @@ -96,13 +96,13 @@ EOM { "foo": "bar" } -EOM + EOM end it "knife diff reports the role as different" do knife("diff --name-status /").should_succeed <<~EOM M\t/roles/x.json -EOM + EOM end end @@ -130,7 +130,7 @@ EOM A\t/nodes/y.json A\t/roles/y.json A\t/users/y.json -EOM + EOM end context "when cwd is the data_bags directory" do @@ -139,13 +139,13 @@ EOM knife("diff --name-status").should_succeed <<~EOM A\tx/z.json A\ty -EOM + EOM end it "knife diff * reports different data bags" do knife("diff --name-status *").should_succeed <<~EOM A\tx/z.json A\ty -EOM + EOM end end end @@ -161,7 +161,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end end end @@ -183,14 +183,14 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end it "knife diff --diff-filter=MAT does not show deleted files" do knife("diff --diff-filter=MAT --name-status /cookbooks/x").should_succeed <<~EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end end @@ -214,7 +214,7 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end end @@ -228,7 +228,7 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin0.9.9.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end end end @@ -309,7 +309,7 @@ EOM when_the_repository "has an environment with bad JSON" do before { file "environments/x.json", "{" } it "knife diff reports an error and does a textual diff" do - error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" + error_text = "WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match) end @@ -353,7 +353,7 @@ EOM D\t/roles/x.json D\t/users/admin.json D\t/users/x.json -EOM + EOM end end @@ -390,13 +390,13 @@ EOM { "foo": "bar" } -EOM + EOM end it "knife diff reports the role as different" do knife("diff --name-status /").should_succeed <<~EOM M\t/roles/x.json -EOM + EOM end end @@ -426,7 +426,7 @@ EOM A\t/nodes/y.json A\t/roles/y.json A\t/users/y.json -EOM + EOM end context "when cwd is the data_bags directory" do @@ -435,13 +435,13 @@ EOM knife("diff --name-status").should_succeed <<~EOM A\tx/z.json A\ty -EOM + EOM end it "knife diff * reports different data bags" do knife("diff --name-status *").should_succeed <<~EOM A\tx/z.json A\ty -EOM + EOM end end end @@ -457,7 +457,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end end end @@ -477,7 +477,7 @@ EOM it "knife diff /cookbooks shows differences" do knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x-1.0.1 -EOM + EOM end it "knife diff --diff-filter=MAT does not show deleted files" do @@ -504,7 +504,7 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 -EOM + EOM end end @@ -517,7 +517,7 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x-0.9.9 A\t/cookbooks/x-1.0.0 -EOM + EOM end end end @@ -592,7 +592,7 @@ EOM when_the_repository "has an environment with bad JSON" do before { file "environments/x.json", "{" } it "knife diff reports an error and does a textual diff" do - error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" + error_text = "WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match) end diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index 04610ba4e7..77f6d3890e 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -62,7 +62,7 @@ describe "knife download", :workstation do Created /roles/x.json Created /users/admin.json Created /users/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -110,7 +110,7 @@ EOM ] } -EOM + EOM end it "knife download changes the role" do @@ -142,7 +142,7 @@ EOM ] } -EOM + EOM end it "knife download / does not change anything" do @@ -176,7 +176,7 @@ EOM A\t/nodes/y.json A\t/roles/y.json A\t/users/y.json -EOM + EOM end it "knife download --purge deletes the extra files" do @@ -190,7 +190,7 @@ EOM Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -219,7 +219,7 @@ EOM Created /users Created /users/admin.json Created /users/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end @@ -245,7 +245,7 @@ EOM Created /users Created /users/admin.json Created /users/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end @@ -273,10 +273,10 @@ EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/z.json -EOM + EOM end it "knife download /data_bags/x /data_bags/x/y.json downloads x once" do @@ -285,7 +285,7 @@ EOM Created /data_bags/x Created /data_bags/x/y.json Created /data_bags/x/z.json -EOM + EOM end end end @@ -296,17 +296,17 @@ EOM { "id": "deleted" } -EOM + EOM file "data_bags/x/modified.json", <<~EOM { "id": "modified" } -EOM + EOM file "data_bags/x/unmodified.json", <<~EOM { "id": "unmodified" } -EOM + EOM end when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do @@ -321,11 +321,11 @@ EOM it "knife download of the modified file succeeds" do knife("download /data_bags/x/modified.json").should_succeed <<~EOM Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the unmodified file does nothing" do knife("download /data_bags/x/unmodified.json").should_succeed "" @@ -333,16 +333,16 @@ EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the added file succeeds" do knife("download /data_bags/x/added.json").should_succeed <<~EOM Created /data_bags/x/added.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the deleted file does nothing" do knife("download /data_bags/x/deleted.json").should_succeed "" @@ -350,32 +350,32 @@ EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download --purge of the deleted file deletes it" do knife("download --purge /data_bags/x/deleted.json").should_succeed <<~EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json -EOM + EOM end it "knife download of the entire data bag downloads everything" do knife("download /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download --purge of the entire data bag downloads everything" do knife("download --purge /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end context "when cwd is the /data_bags directory" do @@ -390,7 +390,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end it "knife download --purge * downloads everything" do @@ -398,7 +398,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end end @@ -421,7 +421,7 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb -EOM + EOM end it "knife download of a deleted file does nothing" do knife("download /cookbooks/x/z.rb").should_succeed "" @@ -429,37 +429,37 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb -EOM + EOM end it "knife download --purge of a deleted file succeeds" do knife("download --purge /cookbooks/x/z.rb").should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n" knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb -EOM + EOM end it "knife download of an added file succeeds" do knife("download /cookbooks/x/y.rb").should_succeed "Created /cookbooks/x/y.rb\n" knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/z.rb -EOM + EOM end it "knife download of the cookbook itself succeeds" do knife("download /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb -EOM + EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM A\t/cookbooks/x/z.rb -EOM + EOM end it "knife download --purge of the cookbook itself succeeds" do knife("download --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb Deleted extra entry /cookbooks/x/z.rb (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -482,7 +482,7 @@ EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -496,7 +496,7 @@ EOM it "knife download /cookbooks/x downloads the updated file" do knife("download --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x/onlyin1.0.0.rb -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -511,7 +511,7 @@ EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -526,7 +526,7 @@ EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin0.9.9.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -541,7 +541,7 @@ EOM file "roles/x.rb", <<~EOM name "x" description "x" -EOM + EOM end it "knife download refuses to change the role" do @@ -561,11 +561,11 @@ EOM end it "knife download succeeds" do warning = <<~EOH - WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF { (right here) ------^ -EOH + EOH knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", stderr: warning knife("diff --name-status /environments/x.json").should_succeed "" end @@ -631,7 +631,7 @@ EOH Created /roles/x.json Created /users/admin.json Created /users/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -690,7 +690,7 @@ EOM ] } -EOM + EOM end it "knife download / does not change anything" do @@ -726,7 +726,7 @@ EOM A\t/nodes/y.json A\t/roles/y.json A\t/users/y.json -EOM + EOM end it "knife download --purge deletes the extra files" do @@ -741,7 +741,7 @@ EOM Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -770,7 +770,7 @@ EOM Created /users Created /users/admin.json Created /users/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end @@ -797,10 +797,10 @@ EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/z.json -EOM + EOM end end end @@ -811,17 +811,17 @@ EOM { "id": "deleted" } -EOM + EOM file "data_bags/x/modified.json", <<~EOM { "id": "modified" } -EOM + EOM file "data_bags/x/unmodified.json", <<~EOM { "id": "unmodified" } -EOM + EOM end when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do @@ -836,11 +836,11 @@ EOM it "knife download of the modified file succeeds" do knife("download /data_bags/x/modified.json").should_succeed <<~EOM Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the unmodified file does nothing" do knife("download /data_bags/x/unmodified.json").should_succeed "" @@ -848,16 +848,16 @@ EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the added file succeeds" do knife("download /data_bags/x/added.json").should_succeed <<~EOM Created /data_bags/x/added.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download of the deleted file does nothing" do knife("download /data_bags/x/deleted.json").should_succeed "" @@ -865,32 +865,32 @@ EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download --purge of the deleted file deletes it" do knife("download --purge /data_bags/x/deleted.json").should_succeed <<~EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json -EOM + EOM end it "knife download of the entire data bag downloads everything" do knife("download /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM A\t/data_bags/x/deleted.json -EOM + EOM end it "knife download --purge of the entire data bag downloads everything" do knife("download --purge /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end context "when cwd is the /data_bags directory" do @@ -905,7 +905,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end it "knife download --purge * downloads everything" do @@ -913,7 +913,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end end @@ -936,7 +936,7 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb -EOM + EOM end it "knife download of a deleted file does nothing" do knife("download /cookbooks/x-1.0.0/z.rb").should_succeed "" @@ -944,37 +944,37 @@ EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb -EOM + EOM end it "knife download --purge of a deleted file succeeds" do knife("download --purge /cookbooks/x-1.0.0/z.rb").should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n" knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb -EOM + EOM end it "knife download of an added file succeeds" do knife("download /cookbooks/x-1.0.0/y.rb").should_succeed "Created /cookbooks/x-1.0.0/y.rb\n" knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x-1.0.0/metadata.rb A\t/cookbooks/x-1.0.0/z.rb -EOM + EOM end it "knife download of the cookbook itself succeeds" do knife("download /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb -EOM + EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM A\t/cookbooks/x-1.0.0/z.rb -EOM + EOM end it "knife download --purge of the cookbook itself succeeds" do knife("download --purge /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -998,7 +998,7 @@ EOM Created /cookbooks/x-1.0.1 Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1015,7 +1015,7 @@ EOM Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1031,7 +1031,7 @@ EOM Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1047,7 +1047,7 @@ EOM Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1106,7 +1106,7 @@ EOM Created /cookbooks Created /cookbooks/x Created /cookbooks/x/metadata.rb -EOM + EOM end end end @@ -1189,7 +1189,7 @@ EOM Created /policies Created /policy_groups Created /roles -EOM + EOM end context "and the server has one of each thing" do @@ -1232,7 +1232,7 @@ EOM Created /acls/roles/x.json Updated /groups/clients.json Updated /groups/users.json -EOM + EOM end it "knife download / downloads everything" do @@ -1254,7 +1254,7 @@ EOM Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end @@ -1323,7 +1323,7 @@ EOM Updated /policies/x-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json -EOM + EOM knife("diff --name-status /").should_succeed "" end end diff --git a/spec/integration/knife/environment_compare_spec.rb b/spec/integration/knife/environment_compare_spec.rb index d3999fffa3..713c1efe12 100644 --- a/spec/integration/knife/environment_compare_spec.rb +++ b/spec/integration/knife/environment_compare_spec.rb @@ -49,7 +49,7 @@ describe "knife environment compare", :workstation do blah = 1.0.0 krad >= 1.0.0 -EOM + EOM end it "compares the cookbooks for two environments" do @@ -58,7 +58,7 @@ EOM blah = 1.0.0 = 1.1.0 krad >= 1.0.0 >= 1.0.0 -EOM + EOM end it "compares the cookbooks for all environments" do @@ -67,7 +67,7 @@ EOM blah = 1.0.0 = 1.1.0 krad >= 1.0.0 >= 1.0.0 -EOM + EOM end # rubocop:enable Layout/TrailingWhitespace end diff --git a/spec/integration/knife/environment_from_file_spec.rb b/spec/integration/knife/environment_from_file_spec.rb index 8948a3772c..8b33e254d8 100644 --- a/spec/integration/knife/environment_from_file_spec.rb +++ b/spec/integration/knife/environment_from_file_spec.rb @@ -45,7 +45,7 @@ describe "knife environment from file", :workstation do } } -EOM + EOM file "environments/car.json", <<~EOM { @@ -63,7 +63,7 @@ EOM } } -EOM + EOM file "environments/cdr.json", <<~EOM { @@ -81,14 +81,14 @@ EOM } } -EOM + EOM end it "uploads a single file" do knife("environment from file #{env_dir}/cons.json").should_succeed stderr: <<~EOM Updated Environment cons -EOM + EOM end it "uploads many files" do @@ -96,7 +96,7 @@ EOM Updated Environment cons Updated Environment car Updated Environment cdr -EOM + EOM end it "uploads all environments in the repository" do @@ -107,7 +107,7 @@ EOM car cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/environment_list_spec.rb b/spec/integration/knife/environment_list_spec.rb index 0ac2df6300..b6b25e8661 100644 --- a/spec/integration/knife/environment_list_spec.rb +++ b/spec/integration/knife/environment_list_spec.rb @@ -34,7 +34,7 @@ describe "knife environment list", :workstation do _default b y -EOM + EOM end end diff --git a/spec/integration/knife/environment_show_spec.rb b/spec/integration/knife/environment_show_spec.rb index fdf41e70ce..c0334ecbf3 100644 --- a/spec/integration/knife/environment_show_spec.rb +++ b/spec/integration/knife/environment_show_spec.rb @@ -43,7 +43,7 @@ describe "knife environment show", :workstation do json_class: Chef::Environment name: b override_attributes: -EOM + EOM end # rubocop:enable Layout/TrailingWhitespace @@ -54,7 +54,7 @@ EOM baz: raz.my: mataz foo: bar -EOM + EOM end it "shows the requested nested attribute of an environment" do @@ -62,7 +62,7 @@ EOM b: default_attributes.baz: raz.my: mataz -EON + EON end it "shows the requested attribute of an environment with custom field separator" do @@ -70,7 +70,7 @@ EON b: default_attributes:baz: raz.my: mataz -EOT + EOT end end end diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb index 39a3f77fc5..830dd0e428 100644 --- a/spec/integration/knife/list_spec.rb +++ b/spec/integration/knife/list_spec.rb @@ -35,7 +35,7 @@ describe "knife list", :workstation do /nodes /roles /users -EOM + EOM end it "knife list -R / returns everything" do @@ -66,7 +66,7 @@ EOM /users: admin.json -EOM + EOM end end @@ -100,7 +100,7 @@ EOM /nodes /roles /users -EOM + EOM end it "knife list -R / returns everything" do @@ -163,7 +163,7 @@ EOM admin.json user1.json user2.json -EOM + EOM end it "knife list -R --flat / returns everything" do @@ -201,7 +201,7 @@ EOM /users/admin.json /users/user1.json /users/user2.json -EOM + EOM end it "knife list -Rfp / returns everything" do @@ -239,14 +239,14 @@ EOM /users/admin.json /users/user1.json /users/user2.json -EOM + EOM end it "knife list /cookbooks returns the list of cookbooks" do knife("list /cookbooks").should_succeed <<~EOM /cookbooks/cookbook1 /cookbooks/cookbook2 -EOM + EOM end it "knife list /cookbooks/*2/*/*.rb returns the one file" do @@ -258,7 +258,7 @@ EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb -EOM + EOM end it "knife list /cookbooks/**.rb returns all ruby files" do @@ -266,7 +266,7 @@ EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb -EOM + EOM end it "knife list /**.json returns all json files" do @@ -289,7 +289,7 @@ EOM /users/admin.json /users/user1.json /users/user2.json -EOM + EOM end it "knife list /data**.json returns all data bag json files" do @@ -298,7 +298,7 @@ EOM /data_bags/bag1/item2.json /data_bags/bag2/item1.json /data_bags/bag2/item2.json -EOM + EOM end it "knife list /environments/missing_file.json reports missing file" do @@ -351,7 +351,7 @@ EOM users/admin.json users/user1.json users/user2.json -EOM + EOM end end end @@ -396,7 +396,7 @@ EOM /users/admin.json /users/user1.json /users/user2.json -EOM + EOM end it "knife list -Rfp .. returns everything" do @@ -434,7 +434,7 @@ EOM /users/admin.json /users/user1.json /users/user2.json -EOM + EOM end it "knife list -Rfp returns cookbooks" do @@ -445,7 +445,7 @@ EOM cookbook2/metadata.rb cookbook2/recipes/ cookbook2/recipes/default.rb -EOM + EOM end end end @@ -461,7 +461,7 @@ EOM metadata.rb recipes/ recipes/default.rb -EOM + EOM end end end @@ -483,7 +483,7 @@ EOM cookbook2/metadata.rb cookbook2/recipes/ cookbook2/recipes/default.rb -EOM + EOM end end @@ -498,7 +498,7 @@ EOM cookbook2/metadata.rb cookbook2/recipes/ cookbook2/recipes/default.rb -EOM + EOM end end end @@ -520,7 +520,7 @@ EOM cookbook2/metadata.rb cookbook2/recipes/ cookbook2/recipes/default.rb -EOM + EOM end end @@ -535,7 +535,7 @@ EOM cookbook2/metadata.rb cookbook2/recipes/ cookbook2/recipes/default.rb -EOM + EOM end end end @@ -619,7 +619,7 @@ EOM /users/ /users/user1.json /users/user2.json -EOM + EOM end context "missing file/directory tests" do @@ -665,7 +665,7 @@ EOM /policies /policy_groups /roles -EOM + EOM end it "knife list -R / returns everything" do @@ -780,7 +780,7 @@ EOM /policy_groups: /roles: -EOM + EOM end end @@ -896,7 +896,7 @@ EOM /policy_groups: /roles: -EOM + EOM end context "has plenty of stuff in it" do @@ -1052,7 +1052,7 @@ EOM /roles/ /roles/role1.json /roles/role2.json -EOM + EOM end end end diff --git a/spec/integration/knife/node_bulk_delete_spec.rb b/spec/integration/knife/node_bulk_delete_spec.rb index 501091c0e7..4dce471150 100644 --- a/spec/integration/knife/node_bulk_delete_spec.rb +++ b/spec/integration/knife/node_bulk_delete_spec.rb @@ -39,12 +39,12 @@ describe "knife node bulk delete", :workstation do Are you sure you want to delete these nodes? (Y/N) Deleted node car Deleted node cat -EOM + EOM knife("node list").should_succeed <<~EOM cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/node_delete_spec.rb b/spec/integration/knife/node_delete_spec.rb index 9d8f382690..a578ae912e 100644 --- a/spec/integration/knife/node_delete_spec.rb +++ b/spec/integration/knife/node_delete_spec.rb @@ -34,13 +34,13 @@ describe "knife node delete", :workstation do it "deletes a node" do knife("node delete car", input: "Y").should_succeed <<~EOM Do you really want to delete car? (Y/N) Deleted node[car] -EOM + EOM knife("node list").should_succeed <<~EOM cat cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/node_environment_set_spec.rb b/spec/integration/knife/node_environment_set_spec.rb index 09d1828130..96251f6351 100644 --- a/spec/integration/knife/node_environment_set_spec.rb +++ b/spec/integration/knife/node_environment_set_spec.rb @@ -34,7 +34,7 @@ describe "knife node environment set", :workstation do knife("node show cons -a chef_environment").should_succeed <<~EOM cons: chef_environment: lisp -EOM + EOM end it "with no environment" do diff --git a/spec/integration/knife/node_from_file_spec.rb b/spec/integration/knife/node_from_file_spec.rb index f7a4717e7c..8a2dddb76e 100644 --- a/spec/integration/knife/node_from_file_spec.rb +++ b/spec/integration/knife/node_from_file_spec.rb @@ -43,14 +43,14 @@ describe "knife node from file", :workstation do ] } } -EOM + EOM end it "uploads a single file" do knife("node from file #{node_dir}/cons.json").should_succeed stderr: <<~EOM Updated Node cons -EOM + EOM end end diff --git a/spec/integration/knife/node_list_spec.rb b/spec/integration/knife/node_list_spec.rb index fd7394f00b..9e5378f121 100644 --- a/spec/integration/knife/node_list_spec.rb +++ b/spec/integration/knife/node_list_spec.rb @@ -37,7 +37,7 @@ describe "knife node list", :workstation do cat cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb index 04f14be335..8875654bc8 100644 --- a/spec/integration/knife/raw_spec.rb +++ b/spec/integration/knife/raw_spec.rb @@ -63,7 +63,7 @@ describe "knife raw", :workstation do ] } -EOM + EOM end it "knife raw /blarghle returns 404" do @@ -90,7 +90,7 @@ EOM } } -EOM + EOM knife("show /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end @@ -115,7 +115,7 @@ EOM } } -EOM + EOM file.close knife("raw -m PUT -i #{file.path} /roles/x").should_succeed <<~EOM @@ -137,14 +137,14 @@ EOM } } -EOM + EOM knife("show /roles/x.json").should_succeed <<~EOM /roles/x.json: { "name": "x", "description": "eek" } -EOM + EOM end end @@ -166,21 +166,21 @@ EOM "env_run_lists": { } } -EOM + EOM file.close knife("raw -m POST -i #{file.path} /roles").should_succeed <<~EOM { "uri": "#{Chef::Config.chef_server_url}/roles/y" } -EOM + EOM knife("show /roles/y.json").should_succeed <<~EOM /roles/y.json: { "name": "y", "description": "eek" } -EOM + EOM end end @@ -206,13 +206,13 @@ EOM "x": "y", "a": "b" } -EOM + EOM end it "knife raw --no-pretty /blah returns the raw json" do knife("raw --no-pretty /blah").should_succeed <<~EOM { "x": "y", "a": "b" } -EOM + EOM end end @@ -235,13 +235,13 @@ EOM it "knife raw /blah returns the raw text" do knife("raw /blah").should_succeed(<<~EOM) { "x": "y", "a": "b" } -EOM + EOM end it "knife raw --no-pretty /blah returns the raw text" do knife("raw --no-pretty /blah").should_succeed(<<~EOM) { "x": "y", "a": "b" } -EOM + EOM end end end diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb index d387b10e3b..5e5ef27b9a 100644 --- a/spec/integration/knife/redirection_spec.rb +++ b/spec/integration/knife/redirection_spec.rb @@ -34,7 +34,7 @@ describe "redirection", :workstation do real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [302, { "Content-Type" => "text", "Location" => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ["302 found"] ] + [302, { "Content-Type" => "text", "Location" => "#{real_chef_server_url}#{env["PATH_INFO"]}" }, ["302 found"] ] end @redirector_server_thread = start_app_server(app, 9018) end diff --git a/spec/integration/knife/role_bulk_delete_spec.rb b/spec/integration/knife/role_bulk_delete_spec.rb index 5a88ef282e..36d1cb2041 100644 --- a/spec/integration/knife/role_bulk_delete_spec.rb +++ b/spec/integration/knife/role_bulk_delete_spec.rb @@ -39,12 +39,12 @@ describe "knife role bulk delete", :workstation do Are you sure you want to delete these roles? (Y/N) Deleted role car Deleted role cat -EOM + EOM knife("role list").should_succeed <<~EOM cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/role_delete_spec.rb b/spec/integration/knife/role_delete_spec.rb index 875f80cede..aa12de57e8 100644 --- a/spec/integration/knife/role_delete_spec.rb +++ b/spec/integration/knife/role_delete_spec.rb @@ -34,13 +34,13 @@ describe "knife role delete", :workstation do it "deletes a role" do knife("role delete car", input: "Y").should_succeed <<~EOM Do you really want to delete car? (Y/N) Deleted role[car] -EOM + EOM knife("role list").should_succeed <<~EOM cat cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/role_from_file_spec.rb b/spec/integration/knife/role_from_file_spec.rb index bc93d0f6e0..69f58e8c36 100644 --- a/spec/integration/knife/role_from_file_spec.rb +++ b/spec/integration/knife/role_from_file_spec.rb @@ -42,7 +42,7 @@ describe "knife role from file", :workstation do } } -EOM + EOM file "roles/car.json", <<~EOM { @@ -57,7 +57,7 @@ EOM } } -EOM + EOM file "roles/cdr.json", <<~EOM { @@ -72,14 +72,14 @@ EOM } } -EOM + EOM end it "uploads a single file" do knife("role from file #{role_dir}/cons.json").should_succeed stderr: <<~EOM Updated Role cons -EOM + EOM end it "uploads many files" do @@ -87,7 +87,7 @@ EOM Updated Role cons Updated Role car Updated Role cdr -EOM + EOM end end diff --git a/spec/integration/knife/role_list_spec.rb b/spec/integration/knife/role_list_spec.rb index db13e521b5..e718425cee 100644 --- a/spec/integration/knife/role_list_spec.rb +++ b/spec/integration/knife/role_list_spec.rb @@ -37,7 +37,7 @@ describe "knife role list", :workstation do cat cdr cons -EOM + EOM end end diff --git a/spec/integration/knife/role_show_spec.rb b/spec/integration/knife/role_show_spec.rb index c2f5efedaf..07afd19440 100644 --- a/spec/integration/knife/role_show_spec.rb +++ b/spec/integration/knife/role_show_spec.rb @@ -42,7 +42,7 @@ describe "knife role show", :workstation do name: cons override_attributes: run_list: -EOM + EOM end # rubocop:enable Layout/TrailingWhitespace diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb index df9f55fbf2..a4013802c5 100644 --- a/spec/integration/knife/show_spec.rb +++ b/spec/integration/knife/show_spec.rb @@ -52,13 +52,13 @@ describe "knife show", :workstation do knife("show /cookbooks/x/metadata.rb").should_succeed <<~EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" -EOM + EOM end it "knife show --local /cookbooks/x/metadata.rb shows the local version" do knife("show --local /cookbooks/x/metadata.rb").should_succeed <<~EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" -EOM + EOM end it "knife show /data_bags/x/y.json shows the remote version" do knife("show /data_bags/x/y.json").should_succeed <<~EOM @@ -66,7 +66,7 @@ EOM { "id": "y" } -EOM + EOM end it "knife show --local /data_bags/x/y.json shows the local version" do knife("show --local /data_bags/x/y.json").should_succeed <<~EOM @@ -74,7 +74,7 @@ EOM { "foo": "bar" } -EOM + EOM end it "knife show /environments/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do knife("show /environments/x.json").should_succeed <<~EOM @@ -82,7 +82,7 @@ EOM { "name": "x" } -EOM + EOM end it "knife show --local /environments/x.json shows the local version" do knife("show --local /environments/x.json").should_succeed <<~EOM @@ -90,7 +90,7 @@ EOM { "foo": "bar" } -EOM + EOM end it "knife show /roles/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do knife("show /roles/x.json").should_succeed <<~EOM @@ -98,7 +98,7 @@ EOM { "name": "x" } -EOM + EOM end it "knife show --local /roles/x.json shows the local version" do knife("show --local /roles/x.json").should_succeed <<~EOM @@ -106,7 +106,7 @@ EOM { "foo": "bar" } -EOM + EOM end # show directory it "knife show /data_bags/x fails" do @@ -151,7 +151,7 @@ EOM "x": "y" } } -EOM + EOM end end @@ -161,7 +161,7 @@ EOM knife("show --local /environments/x.json").should_succeed <<~EOM /environments/x.json: { -EOM + EOM end end end diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index 647c7773f9..6eea684c1d 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -64,7 +64,7 @@ describe "knife upload", :workstation do D\t/roles/x.json D\t/users/admin.json D\t/users/x.json -EOM + EOM end it "knife upload --purge deletes everything" do @@ -79,10 +79,10 @@ EOM Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) -EOM + EOM knife("diff --name-status /").should_succeed <<~EOM D\t/environments/_default.json -EOM + EOM end end @@ -145,7 +145,7 @@ EOM ] } -EOM + EOM end it "knife upload / does not change anything" do @@ -159,7 +159,7 @@ EOM file "roles/x.rb", <<~EOM name "x" description "blargle" -EOM + EOM end it "knife upload changes the role" do @@ -208,7 +208,7 @@ EOM Created /nodes/y.json Created /roles/y.json Created /users/y.json -EOM + EOM knife("diff /").should_succeed "" end @@ -224,7 +224,7 @@ EOM Created /nodes/y.json Created /roles/y.json Created /users/y.json -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -241,7 +241,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end it "knife upload --purge deletes nothing" do @@ -253,7 +253,7 @@ EOM ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. -EOM + EOM knife("diff --name-status /").should_succeed <<~EOM D\t/clients D\t/cookbooks @@ -262,7 +262,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end context "when current directory is top level" do @@ -288,7 +288,7 @@ EOM knife("upload /data_bags/x/y.json").should_succeed <<~EOM Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<EOM EOM expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false).keys.sort).to eq(%w{foo id}) @@ -298,7 +298,7 @@ EOM knife("upload /data_bags/x /data_bags/x/y.json").should_succeed <<~EOM Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM end end @@ -312,7 +312,7 @@ EOM knife("upload /data_bags/x/y.json").should_succeed <<~EOM Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false) expect(result.keys.sort).to eq(%w{chef_type data_bag id}) @@ -331,10 +331,10 @@ EOM knife("upload /data_bags/x/y.json").should_succeed <<~EOM Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM A\t/data_bags/x/z.json -EOM + EOM end end end @@ -355,11 +355,11 @@ EOM it "knife upload of the modified file succeeds" do knife("upload /data_bags/x/modified.json").should_succeed <<~EOM Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the unmodified file does nothing" do knife("upload /data_bags/x/unmodified.json").should_succeed "" @@ -367,16 +367,16 @@ EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the added file succeeds" do knife("upload /data_bags/x/added.json").should_succeed <<~EOM Created /data_bags/x/added.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json -EOM + EOM end it "knife upload of the deleted file does nothing" do knife("upload /data_bags/x/deleted.json").should_succeed "" @@ -384,32 +384,32 @@ EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload --purge of the deleted file deletes it" do knife("upload --purge /data_bags/x/deleted.json").should_succeed <<~EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the entire data bag uploads everything" do knife("upload /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json -EOM + EOM end it "knife upload --purge of the entire data bag uploads everything" do knife("upload --purge /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end context "when cwd is the /data_bags directory" do @@ -427,7 +427,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end it "knife upload --purge * uploads everything" do @@ -435,7 +435,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end end @@ -468,13 +468,13 @@ EOM it "knife upload of the cookbook itself succeeds" do knife("upload /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end it "knife upload --purge of the cookbook itself succeeds" do knife("upload /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -487,7 +487,7 @@ EOM it "knife upload of the cookbook succeeds" do knife("upload /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -502,7 +502,7 @@ EOM it "knife upload of the cookbook succeeds" do knife("upload /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -515,7 +515,7 @@ EOM it "knife upload --freeze freezes the cookbook" do knife("upload --freeze /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM # Modify a file and attempt to upload file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different' knife("upload /cookbooks/x").should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n" @@ -540,7 +540,7 @@ EOM it "knife upload --force uploads the frozen cookbook" do knife("upload --force /cookbooks/frozencook").should_succeed <<~EOM Updated /cookbooks/frozencook -EOM + EOM end end end @@ -562,15 +562,15 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM knife("upload --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end end @@ -583,7 +583,7 @@ EOM it "knife upload /cookbooks/x uploads the local version" do knife("upload --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -598,27 +598,27 @@ EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM knife("upload --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb -EOM + EOM end end when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end it "knife upload /cookbooks/x uploads the new version" do knife("upload --purge /cookbooks/x").should_succeed <<~EOM Updated /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -636,7 +636,7 @@ EOM it "knife upload tries and fails" do error1 = <<~EOH - WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF { (right here) ------^ @@ -646,7 +646,7 @@ EOM EOH warn = <<~EOH - WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF { (right here) ------^ @@ -718,7 +718,7 @@ EOM it "knife upload succeeds" do knife("upload /cookbooks/x").should_succeed <<~EOM Created /cookbooks/x -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -763,7 +763,7 @@ EOM D\t/roles/x.json D\t/users/admin.json D\t/users/x.json -EOM + EOM end it "knife upload --purge deletes everything" do @@ -778,10 +778,10 @@ EOM Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) -EOM + EOM knife("diff --name-status /").should_succeed <<~EOM D\t/environments/_default.json -EOM + EOM end end @@ -840,7 +840,7 @@ EOM ] } -EOM + EOM end it "knife upload / does not change anything" do @@ -876,7 +876,7 @@ EOM Created /nodes/y.json Created /roles/y.json Created /users/y.json -EOM + EOM knife("diff --name-status /").should_succeed "" end end @@ -893,7 +893,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end it "knife upload --purge deletes nothing" do @@ -905,7 +905,7 @@ EOM ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. -EOM + EOM knife("diff --name-status /").should_succeed <<~EOM D\t/clients D\t/cookbooks @@ -914,7 +914,7 @@ EOM D\t/nodes D\t/roles D\t/users -EOM + EOM end context "when current directory is top level" do @@ -940,10 +940,10 @@ EOM knife("upload /data_bags/x/y.json").should_succeed <<~EOM Created /data_bags/x Created /data_bags/x/y.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM A\t/data_bags/x/z.json -EOM + EOM end end end @@ -962,11 +962,11 @@ EOM it "knife upload of the modified file succeeds" do knife("upload /data_bags/x/modified.json").should_succeed <<~EOM Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the unmodified file does nothing" do knife("upload /data_bags/x/unmodified.json").should_succeed "" @@ -974,16 +974,16 @@ EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the added file succeeds" do knife("upload /data_bags/x/added.json").should_succeed <<~EOM Created /data_bags/x/added.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json -EOM + EOM end it "knife upload of the deleted file does nothing" do knife("upload /data_bags/x/deleted.json").should_succeed "" @@ -991,32 +991,32 @@ EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload --purge of the deleted file deletes it" do knife("upload --purge /data_bags/x/deleted.json").should_succeed <<~EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json -EOM + EOM end it "knife upload of the entire data bag uploads everything" do knife("upload /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json -EOM + EOM knife("diff --name-status /data_bags").should_succeed <<~EOM D\t/data_bags/x/deleted.json -EOM + EOM end it "knife upload --purge of the entire data bag uploads everything" do knife("upload --purge /data_bags/x").should_succeed <<~EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end context "when cwd is the /data_bags directory" do @@ -1031,7 +1031,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end it "knife upload --purge * uploads everything" do @@ -1039,7 +1039,7 @@ EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) -EOM + EOM knife("diff --name-status /data_bags").should_succeed "" end end @@ -1072,14 +1072,14 @@ EOM it "knife upload of the cookbook itself succeeds" do knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end it "knife upload --purge of the cookbook itself succeeds" do knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1092,7 +1092,7 @@ EOM it "knife upload of the cookbook succeeds" do knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1107,7 +1107,7 @@ EOM it "knife upload of the cookbook succeeds" do knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1129,11 +1129,11 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb D\t/cookbooks/x-1.0.1 -EOM + EOM knife("upload --purge /cookbooks").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1147,7 +1147,7 @@ EOM knife("upload --purge /cookbooks").should_succeed <<~EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1161,11 +1161,11 @@ EOM knife("diff --name-status /cookbooks").should_succeed <<~EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 -EOM + EOM knife("upload --purge /cookbooks").should_succeed <<~EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1179,7 +1179,7 @@ EOM knife("upload --purge /cookbooks").should_succeed <<~EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1252,7 +1252,7 @@ EOM it "knife upload succeeds" do knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM Created /cookbooks/x-1.0.0 -EOM + EOM knife("diff --name-status /cookbooks").should_succeed "" end end @@ -1331,7 +1331,7 @@ EOM Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json -EOM + EOM expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ]) expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) knife("diff --name-status --diff-filter=AMT /").should_succeed "" @@ -1368,7 +1368,7 @@ EOM it "knife upload makes no changes" do knife("upload /").should_succeed <<~EOM Updated /acls/groups/blah.json -EOM + EOM end end @@ -1380,7 +1380,7 @@ EOM it "should fail because policies are not updateable" do knife("upload /policies/x-1.0.0.json").should_fail <<~EOM ERROR: /policies/x-1.0.0.json cannot be updated: policy revisions are immutable once uploaded. If you want to change the policy, create a new revision with your changes. -EOM + EOM end end @@ -1392,7 +1392,7 @@ EOM it "should fail because cookbook_artifacts cannot be updated" do knife("upload /cookbook_artifacts/x-1x1").should_fail <<~EOM ERROR: /cookbook_artifacts/x-1x1 cannot be updated: cookbook artifacts are immutable once uploaded. -EOM + EOM end end @@ -1434,7 +1434,7 @@ EOM Created /policies/blah-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json -EOM + EOM knife("diff --name-status --diff-filter=AMT /").should_succeed "" end end diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb index 65a05fcdc5..0f067d309d 100644 --- a/spec/integration/recipes/accumulator_spec.rb +++ b/spec/integration/recipes/accumulator_spec.rb @@ -115,11 +115,11 @@ describe "Accumulators" do it "should complete with success" do file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) result.error! # runs only a single template resource (in the outer run context, as a delayed resource) expect(result.stdout.scan(/template\S+ action create/).size).to eql(1) @@ -217,11 +217,11 @@ describe "Accumulators" do it "should complete with success" do file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) result.error! # runs only a single template resource (in the outer run context, as a delayed resource) expect(result.stdout.scan(/template\S+ action create/).size).to eql(1) diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb index bda4728449..74e88832ae 100644 --- a/spec/integration/recipes/lwrp_inline_resources_spec.rb +++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb @@ -53,7 +53,7 @@ describe "LWRPs with inline resources" do action :fiddle do file PATH do content new_resource.content - action [:create, :delete] + action %i{create delete} end end end @@ -147,12 +147,12 @@ describe "LWRPs with inline resources" do it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) - actual = result.stdout.lines.map { |l| l.chomp }.join("\n") + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + actual = result.stdout.lines.map(&:chomp).join("\n") expected = <<EOM * x_my_machine[me] action create * x_do_nothing[a] action create (up to date) @@ -163,7 +163,7 @@ EOM * x_do_nothing[b] action create (up to date) (up to date) EOM - expected = expected.lines.map { |l| l.chomp }.join("\n") + expected = expected.lines.map(&:chomp).join("\n") expect(actual).to include(expected) result.error! end diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb index 3f591d4cfc..2fd1dc2438 100644 --- a/spec/integration/recipes/lwrp_spec.rb +++ b/spec/integration/recipes/lwrp_spec.rb @@ -24,15 +24,15 @@ describe "LWRPs" do file "resources/foo.rb", <<~EOM default_action :create -EOM + EOM file "providers/foo.rb", <<~EOM action :create do end -EOM + EOM file "recipes/default.rb", <<~EOM l_w_r_p_foo "me" -EOM + EOM end # directory 'cookbooks/x' end @@ -40,11 +40,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir) expect(result.stdout).to match(/\* l_w_r_p_foo\[me\] action create \(up to date\)/) expect(result.stdout).not_to match(/WARN: You are overriding l_w_r_p_foo/) result.error! diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb index d9e89e7f1e..8ae23bbbbe 100644 --- a/spec/integration/recipes/notifies_spec.rb +++ b/spec/integration/recipes/notifies_spec.rb @@ -28,11 +28,11 @@ describe "notifications" do it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* log\[foo\] action write\s+\* log\[bar\] action write\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/) result.error! @@ -53,7 +53,7 @@ EOM notifies :write, 'log[foo]', :delayed end end -EOM + EOM file "recipes/default.rb", <<~EOM log "foo" do @@ -61,7 +61,7 @@ EOM end notifying_test "whatever" log "baz" -EOM + EOM end end @@ -69,11 +69,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) result.error! @@ -94,7 +94,7 @@ EOM notifies :write, 'log[foo]', :delayed end end -EOM + EOM file "recipes/default.rb", <<~EOM log "foo" do @@ -104,7 +104,7 @@ EOM log "baz" do notifies :write, 'log[foo]', :delayed end -EOM + EOM end end @@ -112,11 +112,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # our delayed notification should run at the end of the parent run_context after the baz resource expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) # and only run once @@ -139,7 +139,7 @@ EOM notifies :write, 'log[foo]', :delayed end end -EOM + EOM file "recipes/default.rb", <<~EOM log "foo" do @@ -151,7 +151,7 @@ EOM end notifying_test "whatever" log "baz" -EOM + EOM end end @@ -159,11 +159,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context expect(result.stdout).to match(/\* log\[quux\] action write\s+\* notifying_test\[whatever\] action run\s+\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) # and only run once @@ -185,7 +185,7 @@ EOM log "baz" do notifies :write, 'log[foo]', :delayed end -EOM + EOM end end @@ -193,11 +193,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) # the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/) # and only run once @@ -220,7 +220,7 @@ EOM notifies :write, 'log[foo]', :immediately end end -EOM + EOM file "recipes/default.rb", <<~EOM log "foo" do @@ -228,7 +228,7 @@ EOM end notifying_test "whatever" log "baz" -EOM + EOM end end @@ -236,11 +236,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) result.error! end @@ -260,7 +260,7 @@ EOM notifies :write, resources(log: "foo"), :immediately end end -EOM + EOM file "recipes/default.rb", <<~EOM log "foo" do @@ -268,7 +268,7 @@ EOM end notifying_test "whatever" log "baz" -EOM + EOM end end @@ -276,11 +276,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/) result.error! end @@ -300,12 +300,12 @@ EOM notifies :write, "log[foo]" end end -EOM + EOM file "recipes/default.rb", <<~EOM notifying_test "whatever" log "baz" -EOM + EOM end end @@ -313,11 +313,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/Chef::Exceptions::ResourceNotFound/) expect(result.exitstatus).not_to eql(0) end @@ -337,7 +337,7 @@ EOM level :info end end -EOM + EOM file "recipes/default.rb", <<~EOM log "bar" do @@ -345,7 +345,7 @@ EOM end cloning_test "whatever" -EOM + EOM end end @@ -353,11 +353,11 @@ EOM it "should complete with success" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).not_to match(/CHEF-3694/) result.error! end @@ -381,11 +381,11 @@ EOM it "notifying the resource should work" do file "config/client.rb", <<~EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn -EOM + EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match /\* log\[a, b\] action write/ result.error! end diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb index 6c50854038..f345ddf846 100644 --- a/spec/integration/recipes/notifying_block_spec.rb +++ b/spec/integration/recipes/notifying_block_spec.rb @@ -45,7 +45,7 @@ describe "notifying_block" do end file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn EOM end @@ -55,7 +55,7 @@ describe "notifying_block" do # 2. delayed notifications are de-dup'd in the subcontext # 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext it "should run alpha, beta, gamma, and delta in that order" do - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/) result.error! end @@ -94,7 +94,7 @@ describe "notifying_block" do end file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" log_level :warn EOM end @@ -103,7 +103,7 @@ describe "notifying_block" do # 1. notifying block will correctly update wrapping new_resource updated_by_last_action status # 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context it "should run foo, quux, bar, and baz in that order" do - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir) expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/) result.error! end diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb index 1895d93891..dea58230db 100644 --- a/spec/integration/recipes/provider_choice.rb +++ b/spec/integration/recipes/provider_choice.rb @@ -16,8 +16,7 @@ describe "Recipe DSL methods" do context "And class Chef::Provider::ProviderThingy with no provides" do before :context do class Chef::Provider::ProviderThingy < Chef::Provider - def load_current_resource - end + def load_current_resource; end def action_create Chef::Log.warn("hello from #{self.class.name}") diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 0250786f0e..766752ac13 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -28,8 +28,7 @@ describe "Recipe DSL methods" do Provider end class Provider < Chef::Provider - def load_current_resource - end + def load_current_resource; end def action_create BaseThingy.created_name = new_resource.name @@ -1154,7 +1153,8 @@ describe "Recipe DSL methods" do def to_s "MyResource" end - end end + end + end let(:my_resource) { :"my_resource#{Namer.current_index}" } let(:blarghle_blarghle_little_star) { :"blarghle_blarghle_little_star#{Namer.current_index}" } @@ -1340,10 +1340,10 @@ describe "Recipe DSL methods" do resource_class.new("blah", run_context) end it "The actions are part of actions along with :nothing" do - expect(resource_class.actions).to eq [ :nothing, :create ] + expect(resource_class.actions).to eq %i{nothing create} end it "The actions are part of allowed_actions along with :nothing" do - expect(resource.allowed_actions).to eq [ :nothing, :create ] + expect(resource.allowed_actions).to eq %i{nothing create} end context "and a subclass that declares more actions" do @@ -1358,14 +1358,14 @@ describe "Recipe DSL methods" do end it "The parent class actions are not part of actions" do - expect(subresource_class.actions).to eq [ :nothing, :delete ] + expect(subresource_class.actions).to eq %i{nothing delete} end it "The parent class actions are not part of allowed_actions" do - expect(subresource.allowed_actions).to eq [ :nothing, :delete ] + expect(subresource.allowed_actions).to eq %i{nothing delete} end it "The parent class actions do not change" do - expect(resource_class.actions).to eq [ :nothing, :create ] - expect(resource.allowed_actions).to eq [ :nothing, :create ] + expect(resource_class.actions).to eq %i{nothing create} + expect(resource.allowed_actions).to eq %i{nothing create} end end end diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb index a0e3e23ef3..6413b43d22 100644 --- a/spec/integration/recipes/remote_directory.rb +++ b/spec/integration/recipes/remote_directory.rb @@ -22,7 +22,7 @@ describe Chef::Resource::RemoteDirectory do before do file "config/client.rb", <<-EOM local_mode true - cookbook_path "#{path_to('cookbooks')}" + cookbook_path "#{path_to("cookbooks")}" EOM directory "cookbooks/test" do directory "files/default/source_dir" do @@ -50,7 +50,7 @@ describe Chef::Resource::RemoteDirectory do end EOM end - shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", cwd: chef_dir) + shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'test::default'", cwd: chef_dir) end def mode_of(path) diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index 149b17fcad..c8da9196ca 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -154,7 +154,7 @@ module ResourceActionSpec ResourceActionSpec::ActionJackson.ruby_block_converged = ResourceActionSpec::ActionJackson.succeeded end end - EOM + EOM expect(ActionJackson.ran_action).to eq :access_attribute expect(ActionJackson.succeeded).to eq "foo!" expect(ActionJackson.ruby_block_converged).to eq "foo!" diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb index e1def5e191..605cb2c941 100644 --- a/spec/integration/recipes/resource_converge_if_changed_spec.rb +++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb @@ -87,7 +87,7 @@ describe "Resource::ActionClass#converge_if_changed" do * #{resource_name}[blah] action create - update default_identity1 - set state1 to "new_state1" (was "current_state1") - EOM + EOM end end @@ -109,7 +109,7 @@ describe "Resource::ActionClass#converge_if_changed" do - update default_identity1 - set state1 to "new_state1" (was "current_state1") - set state2 to "new_state2" (was "current_state2") -EOM + EOM end end @@ -132,7 +132,7 @@ EOM - update default_identity1 - set state1 to (suppressed sensitive property) - set state2 to (suppressed sensitive property) -EOM + EOM end end @@ -152,7 +152,7 @@ EOM * #{resource_name}[blah] action create - update default_identity1 - set sensitive1 to (suppressed sensitive property) -EOM + EOM end end @@ -173,7 +173,7 @@ EOM * #{resource_name}[blah] action create - update default_identity1 - set state2 to "new_state2" (was "current_state2") -EOM + EOM end end @@ -192,7 +192,7 @@ EOM expect(resource.updated?).to be_falsey expect(converged_recipe.stdout).to eq <<~EOM * #{resource_name}[blah] action create (up to date) -EOM + EOM end end @@ -213,7 +213,7 @@ EOM expect(resource.updated?).to be_falsey expect(converged_recipe.stdout).to eq <<~EOM * #{resource_name}[blah] action create (up to date) -EOM + EOM end end end @@ -270,7 +270,7 @@ EOM - set state1 to "default_state1" (default value) - set state2 to "default_state2" (default value) - set sensitive1 to (suppressed sensitive property) (default value) -EOM + EOM end end @@ -295,7 +295,7 @@ EOM - set state1 to "new_state1" - set state2 to "new_state2" - set sensitive1 to (suppressed sensitive property) -EOM + EOM end end @@ -320,7 +320,7 @@ EOM - set state1 to (suppressed sensitive property) - set state2 to (suppressed sensitive property) - set sensitive1 to (suppressed sensitive property) (default value) -EOM + EOM end end end @@ -357,7 +357,7 @@ EOM expect(resource.updated?).to be_falsey expect(converged_recipe.stdout).to eq <<~EOM * #{resource_name}[blah] action create (up to date) -EOM + EOM end end @@ -378,7 +378,7 @@ EOM * #{resource_name}[blah] action create - update default_identity1 - set state1 to "new_state1" (was "current_state1") -EOM + EOM end end @@ -401,7 +401,7 @@ EOM - set state1 to "new_state1" (was "current_state1") - update default_identity1 - set state2 to "new_state2" (was "current_state2") -EOM + EOM end end @@ -422,7 +422,7 @@ EOM * #{resource_name}[blah] action create - update default_identity1 - set state2 to "new_state2" (was "current_state2") -EOM + EOM end end @@ -441,7 +441,7 @@ EOM expect(resource.updated?).to be_falsey expect(converged_recipe.stdout).to eq <<~EOM * #{resource_name}[blah] action create (up to date) -EOM + EOM end end @@ -461,7 +461,7 @@ EOM * #{resource_name}[blah] action create - update default_identity1 - set sensitive1 to (suppressed sensitive property) -EOM + EOM end end end @@ -489,7 +489,7 @@ EOM - set state2 to "default_state2" (default value) - create default_identity1 - set sensitive1 to (suppressed sensitive property) (default value) -EOM + EOM end end @@ -515,7 +515,7 @@ EOM - set state2 to "new_state2" - create default_identity1 - set sensitive1 to (suppressed sensitive property) -EOM + EOM end end @@ -541,7 +541,7 @@ EOM - set state2 to (suppressed sensitive property) - create default_identity1 - set sensitive1 to (suppressed sensitive property) (default value) -EOM + EOM end end diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index 58314473e7..b4300b6c0a 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -25,8 +25,8 @@ describe "chef-solo" do before do file "config/solo.rb", <<~EOM chef_repo_path "#{@repository_dir}" -EOM - result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", cwd: chef_dir) + EOM + result = shell_out("ruby bin/chef-solo -c \"#{path_to("config/solo.rb")}\" -l debug", cwd: chef_dir) result.error! end @@ -75,25 +75,25 @@ EOM it "should complete with success" do file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM + result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir) result.error! expect(result.stdout).to include("ITWORKS") end it "should evaluate its node.json file" do file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM file "config/node.json", <<~E {"run_list":["x::default"]} -E + E - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", cwd: chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -j '#{path_to("config/node.json")}' -l debug", cwd: chef_dir) result.error! expect(result.stdout).to include("ITWORKS") end @@ -111,10 +111,10 @@ E it "should exit with an error" do file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM + result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(0) # For CHEF-5120 this becomes 1 expect(result.stdout).to include("WARN: MissingCookbookDependency") end @@ -125,13 +125,13 @@ EOM file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"' file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM end it "should exit with an error" do - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(1) expect(result.stdout).to include("Chef::Exceptions::CookbookChefVersionMismatch") end @@ -142,13 +142,13 @@ EOM file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nohai_version '~> 999.0'") file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"' file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM end it "should exit with an error" do - result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir) + result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir) expect(result.exitstatus).to eq(1) expect(result.stdout).to include("Chef::Exceptions::CookbookOhaiVersionMismatch") end @@ -169,14 +169,14 @@ EOM end end end -EOM + EOM end it "while running solo concurrently" do file "config/solo.rb", <<~EOM - cookbook_path "#{path_to('cookbooks')}" - file_cache_path "#{path_to('config/cache')}" -EOM + cookbook_path "#{path_to("cookbooks")}" + file_cache_path "#{path_to("config/cache")}" + EOM # We have a timeout protection here so that if due to some bug # run_lock gets stuck we can discover it. expect do @@ -187,13 +187,13 @@ EOM # Instantiate the first chef-solo run threads << Thread.new do - s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir) + s1 = Process.spawn("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug -L #{path_to("logs/runs.log")}", chdir: chef_dir) Process.waitpid(s1) end # Instantiate the second chef-solo run threads << Thread.new do - s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir) + s2 = Process.spawn("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug -L #{path_to("logs/runs.log")}", chdir: chef_dir) Process.waitpid(s2) end diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb index 66e400b6d0..e9f645416c 100644 --- a/spec/scripts/ssl-serve.rb +++ b/spec/scripts/ssl-serve.rb @@ -34,7 +34,7 @@ DEFAULT_OPTIONS = { Host: "localhost", environment: :none, Logger: LOGGER, - DocumentRoot: File.expand_path("#{Dir.tmpdir}/chef-118-sampledata") + DocumentRoot: File.expand_path("#{Dir.tmpdir}/chef-118-sampledata"), #:AccessLog => [] # Remove this option to enable the access log when debugging. }.freeze diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b52c7d171d..c7672fe930 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -52,7 +52,7 @@ require "chef/knife" Dir["lib/chef/knife/**/*.rb"] .map { |f| f.gsub("lib/", "") } - .map { |f| f.gsub(%r{\.rb$}, "") } + .map { |f| f.gsub(/\.rb$/, "") } .each { |f| require f } require "chef/resource_resolver" @@ -93,7 +93,7 @@ require "spec/support/shared/unit/mock_shellout" Dir["spec/support/**/*.rb"] .reject { |f| f =~ %r{^spec/support/platforms} } .reject { |f| f =~ %r{^spec/support/pedant} } - .map { |f| f.gsub(%r{.rb$}, "") } + .map { |f| f.gsub(/.rb$/, "") } .map { |f| f.gsub(%r{spec/}, "") } .each { |f| require f } @@ -140,19 +140,18 @@ RSpec.configure do |config| config.filter_run_excluding skip_appveyor: true if ENV["APPVEYOR"] config.filter_run_excluding appveyor_only: true unless ENV["APPVEYOR"] - config.filter_run_excluding skip_travis: true if ENV["TRAVIS"] config.filter_run_excluding skip_buildkite: true if ENV["BUILDKITE"] config.filter_run_excluding windows_only: true unless windows? + config.filter_run_excluding not_supported_on_windows: true if windows? config.filter_run_excluding not_supported_on_mac_osx: true if mac_osx? - config.filter_run_excluding mac_osx_only: true if !mac_osx? + config.filter_run_excluding mac_osx_only: true unless mac_osx? config.filter_run_excluding not_supported_on_aix: true if aix? config.filter_run_excluding not_supported_on_solaris: true if solaris? config.filter_run_excluding not_supported_on_gce: true if gce? config.filter_run_excluding not_supported_on_nano: true if windows_nano_server? config.filter_run_excluding win2012r2_only: true unless windows_2012r2? - config.filter_run_excluding windows_2008r2_or_later: true unless windows_2008r2_or_later? config.filter_run_excluding windows64_only: true unless windows64? config.filter_run_excluding windows32_only: true unless windows32? config.filter_run_excluding windows_nano_only: true unless windows_nano_server? @@ -161,7 +160,7 @@ RSpec.configure do |config| config.filter_run_excluding ruby64_only: true unless ruby_64bit? config.filter_run_excluding ruby32_only: true unless ruby_32bit? config.filter_run_excluding windows_powershell_dsc_only: true unless windows_powershell_dsc? - config.filter_run_excluding windows_powershell_no_dsc_only: true unless ! windows_powershell_dsc? + config.filter_run_excluding windows_powershell_no_dsc_only: true if windows_powershell_dsc? config.filter_run_excluding windows_domain_joined_only: true unless windows_domain_joined? config.filter_run_excluding windows_not_domain_joined_only: true if windows_domain_joined? # We think this line was causing rspec tests to not run on the Jenkins windows @@ -189,7 +188,6 @@ RSpec.configure do |config| config.filter_run_excluding not_wpar: true unless wpar? config.filter_run_excluding not_supported_under_fips: true if fips? config.filter_run_excluding rhel: true unless rhel? - config.filter_run_excluding rhel5: true unless rhel5? config.filter_run_excluding rhel6: true unless rhel6? config.filter_run_excluding rhel7: true unless rhel7? config.filter_run_excluding rhel8: true unless rhel8? @@ -316,14 +314,11 @@ require "thread" module WEBrick module Utils class TimeoutHandler - def initialize - end + def initialize; end - def register(*args) - end + def register(*args); end - def cancel(*args) - end + def cancel(*args); end end end end diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb index 0280398ad5..8929a2ff74 100644 --- a/spec/stress/win32/security_spec.rb +++ b/spec/stress/win32/security_spec.rb @@ -50,7 +50,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do it "should not leak when retrieving and reading the ACE from a file", :volatile do expect do - sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid } + sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select(&:sid) GC.start end.not_to leak_memory(warmup: 50, iterations: 100) end diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb index 84fc71cc99..72dd67ca97 100644 --- a/spec/support/lib/chef/resource/zen_follower.rb +++ b/spec/support/lib/chef/resource/zen_follower.rb @@ -25,7 +25,7 @@ class Chef provides :follower, platform: "zen" def master(arg = nil) - if !arg.nil? + unless arg.nil? @master = arg end @master diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb index 9d6e5d46f7..710742a285 100644 --- a/spec/support/lib/chef/resource/zen_master.rb +++ b/spec/support/lib/chef/resource/zen_master.rb @@ -30,7 +30,7 @@ class Chef end def something(arg = nil) - if !arg.nil? + unless arg.nil? @something = arg end @something diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb index c6670827f9..2cf605c741 100644 --- a/spec/support/mock/platform.rb +++ b/spec/support/mock/platform.rb @@ -19,7 +19,7 @@ def platform_mock(platform = :unix) mock_constants({ "RUBY_PLATFORM" => (platform == :windows ? "i386-mingw32" : "x86_64-darwin11.2.0"), "File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"), "File::ALT_SEPARATOR" => (platform == :windows ? "\\" : nil) }) do - yield - end + yield + end end end diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 43b3500e46..ce9ec77502 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -46,6 +46,7 @@ require "wmi-lite/wmi" if windows? def windows_domain_joined? return false unless windows? + wmi = WmiLite::Wmi.new computer_system = wmi.first_of("Win32_ComputerSystem") computer_system["partofdomain"] @@ -54,19 +55,20 @@ end def windows_2008r2_or_later? return false unless windows? return false unless host_version - components = host_version.split(".").map do |component| - component.to_i - end + + components = host_version.split(".").map(&:to_i) components.length >= 2 && components[0] >= 6 && components[1] >= 1 end def windows_2012r2? return false unless windows? + (host_version && host_version.start_with?("6.3")) end def windows_gte_10? return false unless windows? + Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(host_version)) end @@ -80,6 +82,7 @@ end def windows_powershell_dsc? return false unless windows? + supports_dsc = false begin wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration") @@ -97,6 +100,7 @@ end def windows_user_right?(right) return false unless windows? + require "chef/win32/security" Chef::ReservedNames::Win32::Security.get_account_right(ENV["USERNAME"]).include?(right) end @@ -238,6 +242,7 @@ end def root? return false if windows? + Process.euid == 0 end diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb index 5548a79afc..2cc4e40298 100644 --- a/spec/support/platforms/win32/spec_service.rb +++ b/spec/support/platforms/win32/spec_service.rb @@ -20,12 +20,12 @@ require "win32/daemon" class SpecService < ::Win32::Daemon def service_init - @test_service_file = "#{ENV['TMP']}/spec_service_file" + @test_service_file = "#{ENV["TMP"]}/spec_service_file" end def service_main(*startup_parameters) while running? - if !File.exists?(@test_service_file) + unless File.exists?(@test_service_file) File.open(@test_service_file, "wb") do |f| f.write("This file is created by SpecService") end @@ -39,17 +39,13 @@ class SpecService < ::Win32::Daemon # Control Signal Callback Methods ################################################################################ - def service_stop - end + def service_stop; end - def service_pause - end + def service_pause; end - def service_resume - end + def service_resume; end - def service_shutdown - end + def service_shutdown; end end # To run this file as a service, it must be called as a script from within diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index d6c49c896b..8a9d1ddf27 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -251,7 +251,8 @@ end shared_context "audit phase completed with failed controls" do let(:audit_runner) do instance_double("Chef::Audit::Runner", failed?: true, - num_failed: 1, num_total: 3) end + num_failed: 1, num_total: 3) + end let(:audit_error) do err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total) diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb index 1a14bb38c3..f56479bb49 100644 --- a/spec/support/shared/functional/execute_resource.rb +++ b/spec/support/shared/functional/execute_resource.rb @@ -21,7 +21,7 @@ shared_context "a non-admin Windows user" do let(:windows_nonadmin_user_domain) { ENV["COMPUTERNAME"] } let(:windows_nonadmin_user_qualified) { "#{windows_nonadmin_user_domain}\\#{windows_nonadmin_user}" } - let(:temp_profile_path) { "#{ENV['USERPROFILE']}\\..\\cheftesttempuser" } + let(:temp_profile_path) { "#{ENV["USERPROFILE"]}\\..\\cheftesttempuser" } before do shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0, 2]) @@ -40,7 +40,7 @@ end shared_context "alternate user identity" do let(:windows_alternate_user) { "chef%02d%02d%02d" % [Time.now.year % 100, Time.now.month, Time.now.day] } let(:windows_alternate_user_password) { "lj28;fx3T!x,2" } - let(:windows_alternate_user_qualified) { "#{ENV['COMPUTERNAME']}\\#{windows_alternate_user}" } + let(:windows_alternate_user_qualified) { "#{ENV["COMPUTERNAME"]}\\#{windows_alternate_user}" } let(:windows_nonadmin_user) { windows_alternate_user } let(:windows_nonadmin_user_password) { windows_alternate_user_password } @@ -58,7 +58,7 @@ shared_context "a command that can be executed as an alternate user" do include Chef::Mixin::ShellOut before do - shell_out!("icacls \"#{script_output_dir.gsub(/\//, '\\')}\" /grant \"authenticated users:(F)\"") + shell_out!("icacls \"#{script_output_dir.gsub(%r{/}, '\\')}\" /grant \"authenticated users:(F)\"") end after do @@ -73,7 +73,7 @@ shared_examples_for "an execute resource that supports alternate user identity" include_context "a command that can be executed as an alternate user" let(:windows_current_user) { ENV["USERNAME"] } - let(:windows_current_user_qualified) { "#{ENV['USERDOMAIN'] || ENV['COMPUTERNAME']}\\#{windows_current_user}" } + let(:windows_current_user_qualified) { "#{ENV["USERDOMAIN"] || ENV["COMPUTERNAME"]}\\#{windows_current_user}" } let(:resource_identity_command) { "powershell.exe -noprofile -command \"import-module microsoft.powershell.utility;([Security.Principal.WindowsPrincipal]([Security.Principal.WindowsIdentity]::GetCurrent())).identity.name | out-file -encoding ASCII '#{script_output_path}'\"" } let(:execute_resource) do diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb index db947614b3..114971641d 100644 --- a/spec/support/shared/functional/file_resource.rb +++ b/spec/support/shared/functional/file_resource.rb @@ -392,9 +392,7 @@ shared_examples_for "a configured file resource" do end def binread(file) - content = File.open(file, "rb") do |f| - f.read - end + content = File.open(file, "rb", &:read) content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding) content end diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb index 76faaaed47..f006c6a24a 100644 --- a/spec/support/shared/functional/http.rb +++ b/spec/support/shared/functional/http.rb @@ -30,9 +30,7 @@ module ChefHTTPShared end def binread(file) - content = File.open(file, "rb") do |f| - f.read - end + content = File.open(file, "rb", &:read) content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding) content end @@ -53,25 +51,19 @@ module ChefHTTPShared # just a normal file # (expected_content should be uncompressed) @api.get("/nyan_cat.png", 200) do - File.open(nyan_uncompressed_filename, "rb") do |f| - f.read - end + File.open(nyan_uncompressed_filename, "rb", &:read) end # this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies) # (expected_content should be compressed) @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do - File.open(nyan_compressed_filename, "rb") do |f| - f.read - end + File.open(nyan_compressed_filename, "rb", &:read) end # this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it # (expected_content should be uncompressed) @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do - File.open(nyan_compressed_filename, "rb") do |f| - f.read - end + File.open(nyan_compressed_filename, "rb", &:read) end # @@ -82,25 +74,19 @@ module ChefHTTPShared @api.get("/nyan_cat_content_length.png", 200, nil, { "Content-Length" => nyan_uncompressed_size.to_s, - } - ) do - File.open(nyan_uncompressed_filename, "rb") do |f| - f.read + }) do + File.open(nyan_uncompressed_filename, "rb", &:read) end - end # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length_compressed.png", 200, nil, { - "Content-Length" => nyan_compressed_size.to_s, - "Content-Type" => "application/gzip", + "Content-Length" => nyan_compressed_size.to_s, + "Content-Type" => "application/gzip", "Content-Encoding" => "gzip", - } - ) do - File.open(nyan_compressed_filename, "rb") do |f| - f.read + }) do + File.open(nyan_compressed_filename, "rb", &:read) end - end # # endpoints that simulate truncated downloads (bad content-length header) @@ -110,25 +96,19 @@ module ChefHTTPShared @api.get("/nyan_cat_truncated.png", 200, nil, { "Content-Length" => (nyan_uncompressed_size + 1).to_s, - } - ) do - File.open(nyan_uncompressed_filename, "rb") do |f| - f.read + }) do + File.open(nyan_uncompressed_filename, "rb", &:read) end - end # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated_compressed.png", 200, nil, { - "Content-Length" => (nyan_compressed_size + 1).to_s, - "Content-Type" => "application/gzip", + "Content-Length" => (nyan_compressed_size + 1).to_s, + "Content-Type" => "application/gzip", "Content-Encoding" => "gzip", - } - ) do - File.open(nyan_compressed_filename, "rb") do |f| - f.read + }) do + File.open(nyan_compressed_filename, "rb", &:read) end - end # # in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work) @@ -137,14 +117,11 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_transfer_encoding.png", 200, nil, { - "Content-Length" => (nyan_uncompressed_size + 1).to_s, + "Content-Length" => (nyan_uncompressed_size + 1).to_s, "Transfer-Encoding" => "anything", - } - ) do - File.open(nyan_uncompressed_filename, "rb") do |f| - f.read + }) do + File.open(nyan_uncompressed_filename, "rb", &:read) end - end # # 403 with a Content-Length @@ -152,8 +129,7 @@ module ChefHTTPShared @api.get("/forbidden", 403, "Forbidden", { "Content-Length" => "Forbidden".bytesize.to_s, - } - ) + }) @api.post("/posty", 200, "Hi!") diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index 18e7243453..010ef27f47 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -89,7 +89,7 @@ shared_context "use Windows permissions", :windows_only do end def explicit_aces - descriptor.dacl.select { |ace| ace.explicit? } + descriptor.dacl.select(&:explicit?) end def extract_ace_properties(aces) @@ -314,7 +314,7 @@ shared_examples_for "a securable resource without existing target" do end it "sets owner when owner is specified with a \\" do - resource.owner "#{ENV['COMPUTERNAME']}\\Guest" + resource.owner "#{ENV["COMPUTERNAME"]}\\Guest" resource.run_action(:create) expect(descriptor.owner).to eq(SID.Guest) end @@ -560,16 +560,12 @@ shared_examples_for "a securable resource without existing target" do # On certain flavors of Windows the default list of ACLs sometimes includes # non-inherited ACLs. Filter them out here. - parent_inherited_acls = parent_acls.dacl.collect do |ace| - ace.inherited? - end + parent_inherited_acls = parent_acls.dacl.collect(&:inherited?) resource.run_action(:create) # Similarly filter out the non-inherited ACLs - resource_inherited_acls = descriptor.dacl.collect do |ace| - ace.inherited? - end + resource_inherited_acls = descriptor.dacl.collect(&:inherited?) expect(resource_inherited_acls).to eq(parent_inherited_acls) end diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb index a528db4a53..2d14c6cf86 100644 --- a/spec/support/shared/functional/win32_service.rb +++ b/spec/support/shared/functional/win32_service.rb @@ -52,6 +52,6 @@ shared_context "using Win32::Service" do # for the file it creates under SYSTEM temp directory let(:test_service_file) do - "#{ENV['SystemDrive']}\\windows\\temp\\spec_service_file" + "#{ENV["SystemDrive"]}\\windows\\temp\\spec_service_file" end end diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb index 5eb68952d7..49fd727055 100644 --- a/spec/support/shared/functional/windows_script.rb +++ b/spec/support/shared/functional/windows_script.rb @@ -114,7 +114,8 @@ shared_context Chef::Resource::WindowsScript do resource.only_if resource_guard_command, architecture: guard_architecture expect { resource.run_action(:run) }.to raise_error( Chef::Exceptions::Win32ArchitectureIncorrect, - /cannot execute script with requested architecture 'i386' on Windows Nano Server/) + /cannot execute script with requested architecture 'i386' on Windows Nano Server/ + ) end end end diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb index 7f05b14689..317a5a2679 100644 --- a/spec/support/shared/integration/app_server_support.rb +++ b/spec/support/shared/integration/app_server_support.rb @@ -27,10 +27,9 @@ module AppServerSupport Rack::Handler::WEBrick.run(app, Port: 9018, AccessLog: [], - Logger: WEBrick::Log.new(StringIO.new, 7) - ) do |found_server| - server = found_server - end + Logger: WEBrick::Log.new(StringIO.new, 7)) do |found_server| + server = found_server + end end Timeout.timeout(30) do sleep(0.01) until server && server.status == :Running diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 5fc9de4de7..6c0eca98be 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -111,6 +111,7 @@ module IntegrationSupport RSpec.shared_context "with a chef repo" do before :each do raise "Can only create one directory per test" if @repository_dir + @repository_dir = Dir.mktmpdir("chef_repo") Chef::Config.chef_repo_path = @repository_dir %w{client cookbook data_bag environment node role user}.each do |object_name| diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index 87ce1bc0b0..07d95f17cc 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -58,7 +58,7 @@ module KnifeSupport old_loggers = Chef::Log.loggers old_log_level = Chef::Log.level begin - puts "knife: #{args.join(' ')}" if DEBUG + puts "knife: #{args.join(" ")}" if DEBUG subcommand_class = Chef::Knife.subcommand_class_from(args) subcommand_class.options = Chef::Application::Knife.options.merge(subcommand_class.options) subcommand_class.load_deps @@ -150,7 +150,7 @@ module KnifeSupport expected[:stderr] = arg end end - expected[:exit_code] = 1 if !expected[:exit_code] + expected[:exit_code] = 1 unless expected[:exit_code] should_result_in(expected) end @@ -169,9 +169,9 @@ module KnifeSupport private def should_result_in(expected) - expected[:stdout] = "" if !expected[:stdout] - expected[:stderr] = "" if !expected[:stderr] - expected[:exit_code] = 0 if !expected[:exit_code] + expected[:stdout] = "" unless expected[:stdout] + expected[:stderr] = "" unless expected[:stderr] + expected[:exit_code] = 0 unless expected[:exit_code] # TODO make this go away stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, "") diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb index b94fa7c184..0f2f06eff8 100644 --- a/spec/support/shared/unit/application_dot_d.rb +++ b/spec/support/shared/unit/application_dot_d.rb @@ -33,13 +33,15 @@ shared_examples_for "an application that loads a dot d" do # make sure that we are correctly globbing. let(:client_d_dir) do Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../../data/client.d_00")) end + File.join(File.dirname(__FILE__), "../../../data/client.d_00") + ) + end it "loads the configuration in order" do expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0") expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("bar 0") expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_return("strings 0") - allow(app).to receive(:apply_config).with(anything(), Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered + allow(app).to receive(:apply_config).with(anything, Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered expect(app).to receive(:apply_config).with("foo 0", Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered expect(app).to receive(:apply_config).with("bar 0", Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered expect(app).to receive(:apply_config).with("strings 0", Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_call_original.ordered @@ -50,7 +52,9 @@ shared_examples_for "an application that loads a dot d" do context "when client_d_dir is set to a directory without configuration" do let(:client_d_dir) do Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_01")) end + File.join(File.dirname(__FILE__), "../../data/client.d_01") + ) + end # client.d_01 has a nested folder with a rb file that if # executed, would raise an exception. If it is executed, @@ -66,7 +70,9 @@ shared_examples_for "an application that loads a dot d" do # foo.rb as a directory should be ignored let(:client_d_dir) do Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_02")) end + File.join(File.dirname(__FILE__), "../../data/client.d_02") + ) + end it "does not raise an exception" do expect { app.reconfigure }.not_to raise_error diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb index 32bdb1456e..957479f149 100644 --- a/spec/support/shared/unit/file_system_support.rb +++ b/spec/support/shared/unit/file_system_support.rb @@ -23,9 +23,10 @@ require "chef/chef_fs/file_system/memory/memory_file" module FileSystemSupport def memory_fs(pretty_name, value, cannot_be_in_regex = nil) - if !value.is_a?(Hash) + unless value.is_a?(Hash) raise "memory_fs() must take a Hash" end + dir = Chef::ChefFS::FileSystem::Memory::MemoryRoot.new(pretty_name, cannot_be_in_regex) value.each do |key, child| dir.add_child(memory_fs_value(child, key.to_s, dir)) @@ -55,7 +56,7 @@ module FileSystemSupport def no_blocking_calls_allowed [ Chef::ChefFS::FileSystem::Memory::MemoryFile, Chef::ChefFS::FileSystem::Memory::MemoryDir ].each do |c| - [ :children, :exists?, :read ].each do |m| + %i{children exists? read}.each do |m| allow_any_instance_of(c).to receive(m).and_raise("#{m} should not be called") end end diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb index 7b9cc0f94e..3b07fdd367 100644 --- a/spec/support/shared/unit/platform_introspector.rb +++ b/spec/support/shared/unit/platform_introspector.rb @@ -36,14 +36,14 @@ shared_examples_for "a platform introspector" do @platform_family_hash = { "debian" => "debian value", - [:rhel, :fedora] => "redhatty value", + %i{rhel fedora} => "redhatty value", "suse" => "suse value", :default => "default value", } end it "returns a default value when there is no known platform" do - node = Hash.new + node = {} expect(platform_introspector.value_for_platform(@platform_hash)).to eq("default") end @@ -125,7 +125,7 @@ shared_examples_for "a platform introspector" do it "returns true if the node is a provided platform and platforms are provided as symbols" do node.automatic_attrs[:platform] = "ubuntu" - expect(platform_introspector.platform?([:redhat, :ubuntu])).to eq(true) + expect(platform_introspector.platform?(%i{redhat ubuntu})).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do @@ -143,7 +143,7 @@ shared_examples_for "a platform introspector" do it "returns true if the node is in a provided platform family and families are provided as symbols" do node.automatic_attrs[:platform_family] = "debian" - expect(platform_introspector.platform_family?([:rhel, :debian])).to eq(true) + expect(platform_introspector.platform_family?(%i{rhel debian})).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do @@ -165,24 +165,24 @@ shared_examples_for "a platform introspector" do describe "when the value is an array" do before do @platform_hash = { - "debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] }, - "ubuntu" => { "default" => [ :restart, :reload, :status ] }, - "centos" => { "default" => [ :restart, :reload, :status ] }, - "redhat" => { "default" => [ :restart, :reload, :status ] }, - "fedora" => { "default" => [ :restart, :reload, :status ] }, - "default" => { "default" => [:restart, :reload ] } } + "debian" => { "4.0" => %i{restart reload}, "default" => %i{restart reload status} }, + "ubuntu" => { "default" => %i{restart reload status} }, + "centos" => { "default" => %i{restart reload status} }, + "redhat" => { "default" => %i{restart reload status} }, + "fedora" => { "default" => %i{restart reload status} }, + "default" => { "default" => %i{restart reload} } } end it "returns the correct default for a given platform" do node.automatic_attrs[:platform] = "debian" node.automatic_attrs[:platform_version] = "9000" - expect(platform_introspector.value_for_platform(@platform_hash)).to eq([ :restart, :reload, :status ]) + expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload status}) end it "returns the correct platform+version specific value " do node.automatic_attrs[:platform] = "debian" node.automatic_attrs[:platform_version] = "4.0" - expect(platform_introspector.value_for_platform(@platform_hash)).to eq([:restart, :reload]) + expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload}) end end diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index b3039f9be4..2771a371d4 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -417,7 +417,7 @@ shared_examples_for Chef::Provider::File do context "when the enclosing directory does not exist" do before { setup_missing_enclosing_directory } - [:create, :create_if_missing, :touch].each do |action| + %i{create create_if_missing touch}.each do |action| context "action #{action}" do it "raises EnclosingDirectoryDoesNotExist" do expect { provider.run_action(action) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist) diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb index a04da4b63e..68773bb050 100644 --- a/spec/support/shared/unit/script_resource.rb +++ b/spec/support/shared/unit/script_resource.rb @@ -66,7 +66,7 @@ shared_examples_for "a script resource" do it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do inherited_difference = Chef::Resource::Script.guard_inherited_attributes - - [:cwd, :environment, :group, :path, :user, :umask ] + %i{cwd environment group path user umask} expect(inherited_difference).to eq([]) end diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb index 5b559bb83b..29238a3917 100644 --- a/spec/support/shared/unit/windows_script_resource.rb +++ b/spec/support/shared/unit/windows_script_resource.rb @@ -25,7 +25,7 @@ shared_examples_for "a Windows script resource" do before(:each) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s run_context = Chef::RunContext.new(node, nil, nil) diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index 948bde04f2..46820cbaae 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -135,7 +135,7 @@ module TinyServer if response = response_for_request(env) response.call else - debug_info = { message: "no data matches the request for #{env['REQUEST_URI']}", + debug_info = { message: "no data matches the request for #{env["REQUEST_URI"]}", available_routes: @routes, request: env } # Uncomment me for glorious debugging # pp :not_found => debug_info diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index 6fd1d4d0e1..3e786c3c02 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -98,7 +98,7 @@ describe Chef::ApiClient::Registration do it "has an HTTP client configured with validator credentials" do expect(registration.http_api).to be_a_kind_of(Chef::ServerAPI) expect(registration.http_api.options[:client_name]).to eq("test-validator") - auth = registration.http_api.middlewares.find { |klass| klass.kind_of? Chef::HTTP::Authenticator } + auth = registration.http_api.middlewares.find { |klass| klass.is_a? Chef::HTTP::Authenticator } expect(auth.client_name).to eq("test-validator") end diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index e6b2eec820..f36cbc721d 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -41,7 +41,7 @@ describe Chef::ApiClient do end it "only allows string values for the name" do - expect { @client.name Hash.new }.to raise_error(ArgumentError) + expect { @client.name({}) }.to raise_error(ArgumentError) end it "has an admin flag attribute" do @@ -55,7 +55,7 @@ describe Chef::ApiClient do it "allows only boolean values for the admin flag" do expect { @client.admin(false) }.not_to raise_error - expect { @client.admin(Hash.new) }.to raise_error(ArgumentError) + expect { @client.admin({}) }.to raise_error(ArgumentError) end it "has a 'validator' flag attribute" do @@ -69,7 +69,7 @@ describe Chef::ApiClient do it "allows only boolean values for the 'validator' flag" do expect { @client.validator(false) }.not_to raise_error - expect { @client.validator(Hash.new) }.to raise_error(ArgumentError) + expect { @client.validator({}) }.to raise_error(ArgumentError) end it "has a public key attribute" do @@ -79,7 +79,7 @@ describe Chef::ApiClient do it "accepts only String values for the public key" do expect { @client.public_key "" }.not_to raise_error - expect { @client.public_key Hash.new }.to raise_error(ArgumentError) + expect { @client.public_key({}) }.to raise_error(ArgumentError) end it "has a private key attribute" do @@ -89,7 +89,7 @@ describe Chef::ApiClient do it "accepts only String values for the private key" do expect { @client.private_key "" }.not_to raise_error - expect { @client.private_key Hash.new }.to raise_error(ArgumentError) + expect { @client.private_key({}) }.to raise_error(ArgumentError) end describe "when serializing to JSON" do diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb index 6c4e7fe188..3bad466a13 100644 --- a/spec/unit/api_client_v1_spec.rb +++ b/spec/unit/api_client_v1_spec.rb @@ -36,7 +36,7 @@ describe Chef::ApiClientV1 do end it "only allows string values for the name" do - expect { @client.name Hash.new }.to raise_error(ArgumentError) + expect { @client.name({}) }.to raise_error(ArgumentError) end it "has an admin flag attribute" do @@ -50,7 +50,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the admin flag" do expect { @client.admin(false) }.not_to raise_error - expect { @client.admin(Hash.new) }.to raise_error(ArgumentError) + expect { @client.admin({}) }.to raise_error(ArgumentError) end it "has an create_key flag attribute" do @@ -64,7 +64,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the create_key flag" do expect { @client.create_key(false) }.not_to raise_error - expect { @client.create_key(Hash.new) }.to raise_error(ArgumentError) + expect { @client.create_key({}) }.to raise_error(ArgumentError) end it "has a 'validator' flag attribute" do @@ -78,7 +78,7 @@ describe Chef::ApiClientV1 do it "allows only boolean values for the 'validator' flag" do expect { @client.validator(false) }.not_to raise_error - expect { @client.validator(Hash.new) }.to raise_error(ArgumentError) + expect { @client.validator({}) }.to raise_error(ArgumentError) end it "has a public key attribute" do @@ -88,7 +88,7 @@ describe Chef::ApiClientV1 do it "accepts only String values for the public key" do expect { @client.public_key "" }.not_to raise_error - expect { @client.public_key Hash.new }.to raise_error(ArgumentError) + expect { @client.public_key({}) }.to raise_error(ArgumentError) end it "has a private key attribute" do @@ -98,7 +98,7 @@ describe Chef::ApiClientV1 do it "accepts only String values for the private key" do expect { @client.private_key "" }.not_to raise_error - expect { @client.private_key Hash.new }.to raise_error(ArgumentError) + expect { @client.private_key({}) }.to raise_error(ArgumentError) end describe "when serializing to JSON" do diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index 40f690abb1..dc5f42da85 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -120,8 +120,8 @@ describe Chef::Application::Client, "reconfigure" do describe "--named-run-list" do it_behaves_like "sets the configuration", - "--named-run-list arglebargle-example", - named_run_list: "arglebargle-example" + "--named-run-list arglebargle-example", + named_run_list: "arglebargle-example" end describe "--no-listen" do @@ -131,17 +131,17 @@ describe Chef::Application::Client, "reconfigure" do describe "--daemonize", :unix_only do context "with no value" do it_behaves_like "sets the configuration", "--daemonize", - daemonize: true + daemonize: true end context "with an integer value" do it_behaves_like "sets the configuration", "--daemonize 5", - daemonize: 5 + daemonize: 5 end context "with a non-integer value" do it_behaves_like "sets the configuration", "--daemonize foo", - daemonize: true + daemonize: true end end @@ -178,17 +178,17 @@ describe Chef::Application::Client, "reconfigure" do describe "--config-option" do context "with a single value" do it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example", - chef_server_url: "http://example" + chef_server_url: "http://example" end context "with two values" do it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example --config-option policy_name=web", - chef_server_url: "http://example", policy_name: "web" + chef_server_url: "http://example", policy_name: "web" end context "with a boolean value" do it_behaves_like "sets the configuration", "--config-option minimal_ohai=true", - minimal_ohai: true + minimal_ohai: true end context "with an empty value" do diff --git a/spec/unit/application/exit_code_spec.rb b/spec/unit/application/exit_code_spec.rb index 7783cf3ed7..228f3a1fe7 100644 --- a/spec/unit/application/exit_code_spec.rb +++ b/spec/unit/application/exit_code_spec.rb @@ -74,7 +74,8 @@ describe Chef::Application::ExitCode do it "does write a warning on non-standard exit codes" do expect(Chef::Log).to receive(:warn).with( - /^Chef attempted to exit with a non-standard exit code of 151/) + /^Chef attempted to exit with a non-standard exit code of 151/ + ) expect(exit_codes.normalize_exit_code(151)).to eq(1) end @@ -83,7 +84,7 @@ describe Chef::Application::ExitCode do end it "returns GENERIC_FAILURE when no exit code is specified" do - expect(exit_codes.normalize_exit_code()).to eq(1) + expect(exit_codes.normalize_exit_code).to eq(1) end it "returns SIGINT_RECEIVED when a SIGINT is received" do diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb index 8a574b4d0f..a38d678332 100644 --- a/spec/unit/application/knife_spec.rb +++ b/spec/unit/application/knife_spec.rb @@ -28,8 +28,7 @@ describe Chef::Application::Knife do long: "-optwithdefault VALUE", default: "default-value" - def run - end + def run; end end end diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb index a9b27f238e..bf199a2db6 100644 --- a/spec/unit/audit/audit_event_proxy_spec.rb +++ b/spec/unit/audit/audit_event_proxy_spec.rb @@ -36,7 +36,8 @@ describe Chef::Audit::AuditEventProxy do let(:description) { "poots" } let(:group) do double("ExampleGroup", parent_groups: parents, - description: description) end + description: description) + end let(:notification) { double("Notification", group: group) } context "when notified from a top-level example group" do @@ -124,7 +125,8 @@ describe Chef::Audit::AuditEventProxy do let(:example) do double("Example", metadata: metadata, description: example_description, - full_description: full_description, exception: nil) end + full_description: full_description, exception: nil) + end let(:metadata) do { @@ -222,12 +224,14 @@ describe Chef::Audit::AuditEventProxy do let(:example_description) { "should not be listening" } let(:full_description) do [control_group_name, group_description, - example_description].join(" ") end + example_description].join(" ") + end # Metadata fields let(:described_class) do double("Serverspec::Type::Port", - class: "Serverspec::Type::Port", name: resource_name) end + class: "Serverspec::Type::Port", name: resource_name) + end # Control data fields let(:resource_type) { "Port" } @@ -252,7 +256,8 @@ describe Chef::Audit::AuditEventProxy do let(:example_description) { "is not listening" } let(:full_description) do [control_group_name, group_description, - example_description].join(" ") end + example_description].join(" ") + end # Metadata fields let(:described_class) { nil } @@ -283,12 +288,14 @@ describe Chef::Audit::AuditEventProxy do let(:example_description) { "is a file" } let(:full_description) do [control_group_name, outer_group_description, - group_description, example_description].join(" ") end + group_description, example_description].join(" ") + end # Metadata parts let(:described_class) do double("Serverspec::Type::File", - class: "Serverspec::Type::File", name: resource_name) end + class: "Serverspec::Type::File", name: resource_name) + end # Example group parts let(:parent_group) do diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb index 60e93a9331..5b0d2404ab 100644 --- a/spec/unit/audit/audit_reporter_spec.rb +++ b/spec/unit/audit/audit_reporter_spec.rb @@ -30,7 +30,8 @@ describe Chef::Audit::AuditReporter do let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") } let(:run_status) do instance_double(Chef::RunStatus, node: node, run_id: run_id, - start_time: start_time, end_time: end_time) end + start_time: start_time, end_time: end_time) + end describe "#audit_phase_start" do @@ -89,7 +90,8 @@ describe Chef::Audit::AuditReporter do let(:audit_error) do double("AuditError", class: "Chef::Exceptions::AuditError", message: "Audit phase failed with error message: derpderpderp", - backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end + backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) + end before do reporter.instance_variable_set(:@audit_phase_error, audit_error) @@ -103,7 +105,7 @@ describe Chef::Audit::AuditReporter do Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp /path/recipe.rb:57 /path/library.rb:106 -EOM + EOM end end @@ -238,12 +240,14 @@ EOM let(:audit_error) do double("AuditError", class: "Chef::Exceptions::AuditError", message: "Audit phase failed with error message: derpderpderp", - backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end + backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) + end let(:run_error) do double("RunError", class: "Chef::Exceptions::RunError", message: "This error shouldn't be reported.", - backtrace: ["fix it", "fix it", "fix it"]) end + backtrace: ["fix it", "fix it", "fix it"]) + end before do allow(reporter).to receive(:auditing_enabled?).and_return(true) @@ -273,7 +277,7 @@ EOM Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp /path/recipe.rb:57 /path/library.rb:106 -EOM + EOM end end end @@ -282,10 +286,12 @@ EOM let(:control_group_foo) do instance_double(Chef::Audit::ControlGroupData, - metadata: double("foo metadata")) end + metadata: double("foo metadata")) + end let(:control_group_bar) do instance_double(Chef::Audit::ControlGroupData, - metadata: double("bar metadata")) end + metadata: double("bar metadata")) + end let(:ordered_control_groups) do { @@ -296,11 +302,13 @@ EOM let(:audit_data) do instance_double(Chef::Audit::AuditData, - add_control_group: true) end + add_control_group: true) + end let(:run_context) do instance_double(Chef::RunContext, - audits: ordered_control_groups) end + audits: ordered_control_groups) + end before do allow(reporter).to receive(:ordered_control_groups).and_return(ordered_control_groups) @@ -350,7 +358,8 @@ EOM let(:name) { "bat" } let(:control_group) do instance_double(Chef::Audit::ControlGroupData, - metadata: double("metadata")) end + metadata: double("metadata")) + end before do allow(Chef::Audit::ControlGroupData).to receive(:new) diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb index e8af8be90d..e1b360c42e 100644 --- a/spec/unit/audit/control_group_data_spec.rb +++ b/spec/unit/audit/control_group_data_spec.rb @@ -66,7 +66,7 @@ describe Chef::Audit::AuditData do end it "describes a Chef::Audit::AuditData object" do - keys = [:node_name, :run_id, :start_time, :end_time, :control_groups] + keys = %i{node_name run_id start_time end_time control_groups} expect(audit_data_hash.keys).to match_array(keys) end @@ -125,7 +125,8 @@ describe Chef::Audit::ControlData do let(:control_data) do described_class.new(name: name, resource_type: resource_type, resource_name: resource_name, - context: context, line_number: line_number) end + context: context, line_number: line_number) + end describe "#to_h" do @@ -136,7 +137,7 @@ describe Chef::Audit::ControlData do end it "describes a Chef::Audit::ControlData object" do - keys = [:name, :resource_type, :resource_name, :context, :status, :details] + keys = %i{name resource_type resource_name context status details} expect(control_data_hash.keys).to match_array(keys) end @@ -190,7 +191,8 @@ describe Chef::Audit::ControlGroupData do let(:control) do Chef::Audit::ControlData.new(name: name, resource_type: resource_type, resource_name: resource_name, - context: context, line_number: line_number) end + context: context, line_number: line_number) + end before do allow(Chef::Audit::ControlData).to receive(:new) @@ -394,8 +396,8 @@ describe Chef::Audit::ControlGroupData do end it "describes a Chef::Audit::ControlGroupData object" do - keys = [:name, :status, :number_succeeded, :number_failed, - :controls, :id] + keys = %i{name status number_succeeded number_failed + controls id} expect(control_group_data_hash.keys).to match_array(keys) end @@ -440,16 +442,19 @@ describe Chef::Audit::ControlGroupData do let(:control_1) do double("control 1", - line_number: control_hash_1[:line_number], - to_h: control_hash_1) end + line_number: control_hash_1[:line_number], + to_h: control_hash_1) + end let(:control_2) do double("control 2", - line_number: control_hash_2[:line_number], - to_h: control_hash_2) end + line_number: control_hash_2[:line_number], + to_h: control_hash_2) + end let(:control_3) do double("control 3", - line_number: control_hash_3[:line_number], - to_h: control_hash_3) end + line_number: control_hash_3[:line_number], + to_h: control_hash_3) + end let(:control_list) { [control_1, control_2, control_3] } let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] } diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb index 0adcbbfbfb..bdb9bc2c72 100644 --- a/spec/unit/chef_fs/config_spec.rb +++ b/spec/unit/chef_fs/config_spec.rb @@ -23,7 +23,7 @@ require "lib/chef/chef_fs/config.rb" describe Chef::ChefFS::Config do describe "initialize" do it "warns when hosted setups use 'everything'" do - base_config = Hash.new() + base_config = {} base_config[:repo_mode] = "everything" base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" @@ -34,7 +34,7 @@ describe Chef::ChefFS::Config do end it "doesn't warn when hosted setups use 'hosted_everything'" do - base_config = Hash.new() + base_config = {} base_config[:repo_mode] = "hosted_everything" base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" @@ -45,7 +45,7 @@ describe Chef::ChefFS::Config do end it "doesn't warn when non-hosted setups use 'everything'" do - base_config = Hash.new() + base_config = {} base_config[:repo_mode] = "everything" base_config[:chef_server_url] = "http://foo.com/" diff --git a/spec/unit/chef_fs/file_system/repository/directory_spec.rb b/spec/unit/chef_fs/file_system/repository/directory_spec.rb index 5b2a0a47b8..ec147ba6a8 100644 --- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb +++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb @@ -106,7 +106,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do end it "filters invalid names" do - expect(test_directory.children.map { |c| c.name }).to eql %w{ test1.json test2.json test3.json } + expect(test_directory.children.map(&:name)).to eql %w{ test1.json test2.json test3.json } end end diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index cbfa3402fa..ddd7d740cf 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -445,7 +445,7 @@ describe Chef::ChefFS::Parallelizer do threads = 0.upto(99).map do |i| Thread.new { outputs[i] = parallelizers[i].to_a } end - threads.each { |thread| thread.join } + threads.each(&:join) outputs.each { |output| expect(output.sort).to eq(2.upto(501).to_a) } end end diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 9e20058846..2d2135afab 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -412,7 +412,7 @@ describe Chef::Client do let(:required_recipe) do <<~EOM fake_recipe_variable = "for reals" -EOM + EOM end context "when required_recipe is configured" do @@ -431,10 +431,10 @@ EOM let(:required_recipe) do <<~EOM this is not a recipe -EOM + EOM end it "should not raise an error" do - expect { client.load_required_recipe(rest, run_context) }.not_to raise_error() + expect { client.load_required_recipe(rest, run_context) }.not_to raise_error end end end diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb index abaea6b2dc..8dadd9e681 100644 --- a/spec/unit/config_fetcher_spec.rb +++ b/spec/unit/config_fetcher_spec.rb @@ -7,7 +7,7 @@ describe Chef::ConfigFetcher do let(:http) { double("Chef::HTTP::Simple") } let(:config_location_regex) { Regexp.escape(config_location) } - let(:invalid_json_error_regex) { %r{Could not parse the provided JSON file \(#{config_location_regex}\)} } + let(:invalid_json_error_regex) { /Could not parse the provided JSON file \(#{config_location_regex}\)/ } let(:fetcher) { Chef::ConfigFetcher.new(config_location) } diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index 0f85d82734..1c8e9e977e 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -26,11 +26,11 @@ describe Chef::Cookbook::Metadata do describe "when comparing for equality" do before do - @fields = [ :name, :description, :long_description, :maintainer, - :maintainer_email, :license, :platforms, :dependencies, - :providing, :attributes, :recipes, :version, - :source_url, :issues_url, :privacy, :ohai_versions, :chef_versions, - :gems ] + @fields = %i{name description long_description maintainer + maintainer_email license platforms dependencies + providing attributes recipes version + source_url issues_url privacy ohai_versions chef_versions + gems} end it "does not depend on object identity for equality" do @@ -438,7 +438,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", display_name: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", display_name: Hash.new) + metadata.attribute("db/mysql/databases", display_name: {}) end.to raise_error(ArgumentError) end @@ -447,7 +447,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", description: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", description: Hash.new) + metadata.attribute("db/mysql/databases", description: {}) end.to raise_error(ArgumentError) end @@ -456,7 +456,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", source_url: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", source_url: Hash.new) + metadata.attribute("db/mysql/databases", source_url: {}) end.to raise_error(ArgumentError) end @@ -465,7 +465,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", issues_url: "foo") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", issues_url: Hash.new) + metadata.attribute("db/mysql/databases", issues_url: {}) end.to raise_error(ArgumentError) end @@ -489,7 +489,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", choice: [10, "shared"]) end.to raise_error(ArgumentError) expect do - metadata.attribute("db/mysql/databases", choice: Hash.new) + metadata.attribute("db/mysql/databases", choice: {}) end.to raise_error(ArgumentError) end @@ -506,7 +506,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", calculated: false) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", calculated: Hash.new) + metadata.attribute("db/mysql/databases", calculated: {}) end.to raise_error(ArgumentError) end @@ -526,7 +526,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", type: "array") end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", type: Array.new) + metadata.attribute("db/mysql/databases", type: []) end.to raise_error(ArgumentError) end @@ -578,7 +578,7 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", recipes: []) end.not_to raise_error expect do - metadata.attribute("db/mysql/databases", required: Hash.new) + metadata.attribute("db/mysql/databases", required: {}) end.to raise_error(ArgumentError) end diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 8421b1ffd1..2f690171ca 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -63,7 +63,7 @@ describe Chef::CookbookSynchronizer do { "path" => "recipes/default.rb", "name" => "recipes/default.rb", - "url" => "http://chef.example.com/abc123", + "url" => "http://chef.example.com/abc123", "checksum" => "abc123", } end @@ -72,7 +72,7 @@ describe Chef::CookbookSynchronizer do { "path" => "attributes/default.rb", "name" => "attributes/default.rb", - "url" => "http://chef.example.com/abc456", + "url" => "http://chef.example.com/abc456", "checksum" => "abc456", } end @@ -198,22 +198,22 @@ describe Chef::CookbookSynchronizer do let(:cookbook_a_default_recipe_tempfile) do double("Tempfile for cookbook_a default.rb recipe", - path: "/tmp/cookbook_a_recipes_default_rb") + path: "/tmp/cookbook_a_recipes_default_rb") end let(:cookbook_a_default_attribute_tempfile) do double("Tempfile for cookbook_a default.rb attr file", - path: "/tmp/cookbook_a_attributes_default_rb") + path: "/tmp/cookbook_a_attributes_default_rb") end let(:cookbook_a_file_default_tempfile) do double("Tempfile for cookbook_a megaman.conf file", - path: "/tmp/cookbook_a_file_default_tempfile") + path: "/tmp/cookbook_a_file_default_tempfile") end let(:cookbook_a_template_default_tempfile) do double("Tempfile for cookbook_a apache.conf.erb template", - path: "/tmp/cookbook_a_template_default_tempfile") + path: "/tmp/cookbook_a_template_default_tempfile") end def setup_common_files_missing_expectations diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index 6553dad433..8dd8583a38 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -91,7 +91,7 @@ describe Chef::CookbookLoader do describe "each" do it "should allow you to iterate over cookbooks with each" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -100,7 +100,7 @@ describe Chef::CookbookLoader do end it "should iterate in alphabetical order" do - seen = Array.new + seen = [] cookbook_loader.each_key do |cookbook_name| seen << cookbook_name end @@ -116,52 +116,52 @@ describe Chef::CookbookLoader do it "should allow you to override an attribute file via cookbook_path" do expect(full_paths_for_part(:openldap, "attributes").detect do |f| - f =~ /cookbooks\/openldap\/attributes\/default.rb/ + f =~ %r{cookbooks/openldap/attributes/default.rb} end).not_to eql(nil) expect(full_paths_for_part(:openldap, "attributes").detect do |f| - f =~ /kitchen\/openldap\/attributes\/default.rb/ + f =~ %r{kitchen/openldap/attributes/default.rb} end).to eql(nil) end it "should load different attribute files from deeper paths" do expect(full_paths_for_part(:openldap, "attributes").detect do |f| - f =~ /kitchen\/openldap\/attributes\/robinson.rb/ + f =~ %r{kitchen/openldap/attributes/robinson.rb} end).not_to eql(nil) end it "should allow you to override a definition file via cookbook_path" do expect(full_paths_for_part(:openldap, "definitions").detect do |f| - f =~ /cookbooks\/openldap\/definitions\/client.rb/ + f =~ %r{cookbooks/openldap/definitions/client.rb} end).not_to eql(nil) expect(full_paths_for_part(:openldap, "definitions").detect do |f| - f =~ /kitchen\/openldap\/definitions\/client.rb/ + f =~ %r{kitchen/openldap/definitions/client.rb} end).to eql(nil) end it "should load definition files from deeper paths" do expect(full_paths_for_part(:openldap, "definitions").detect do |f| - f =~ /kitchen\/openldap\/definitions\/drewbarrymore.rb/ + f =~ %r{kitchen/openldap/definitions/drewbarrymore.rb} end).not_to eql(nil) end it "should allow you to override a recipe file via cookbook_path" do expect(full_paths_for_part(:openldap, "recipes").detect do |f| - f =~ /cookbooks\/openldap\/recipes\/gigantor.rb/ + f =~ %r{cookbooks/openldap/recipes/gigantor.rb} end).not_to eql(nil) expect(full_paths_for_part(:openldap, "recipes").detect do |f| - f =~ /kitchen\/openldap\/recipes\/gigantor.rb/ + f =~ %r{kitchen/openldap/recipes/gigantor.rb} end).to eql(nil) end it "should load recipe files from deeper paths" do expect(full_paths_for_part(:openldap, "recipes").detect do |f| - f =~ /kitchen\/openldap\/recipes\/woot.rb/ + f =~ %r{kitchen/openldap/recipes/woot.rb} end).not_to eql(nil) end it "should allow you to have an 'ignore' file, which skips loading files in later cookbooks" do expect(full_paths_for_part(:openldap, "recipes").detect do |f| - f =~ /kitchen\/openldap\/recipes\/ignoreme.rb/ + f =~ %r{kitchen/openldap/recipes/ignoreme.rb} end).to eql(nil) end @@ -170,8 +170,8 @@ describe Chef::CookbookLoader do f =~ /\.dotfile$/ end).to match(/\.dotfile$/) expect(full_paths_for_part(:openldap, "files").detect do |f| - f =~ /\.ssh\/id_rsa$/ - end).to match(/\.ssh\/id_rsa$/) + f =~ %r{\.ssh/id_rsa$} + end).to match(%r{\.ssh/id_rsa$}) end it "should load the metadata for the cookbook" do @@ -210,7 +210,7 @@ describe Chef::CookbookLoader do end it "should have loaded the correct cookbook" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -238,7 +238,7 @@ describe Chef::CookbookLoader do end it "should not load the other cookbooks" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end @@ -276,7 +276,7 @@ describe Chef::CookbookLoader do end it "should load all cookbooks" do - seen = Hash.new + seen = {} cookbook_loader.each_key do |cookbook_name| seen[cookbook_name] = true end diff --git a/spec/unit/cookbook_manifest_spec.rb b/spec/unit/cookbook_manifest_spec.rb index 417a067451..b28ab573c5 100644 --- a/spec/unit/cookbook_manifest_spec.rb +++ b/spec/unit/cookbook_manifest_spec.rb @@ -89,10 +89,10 @@ describe Chef::CookbookManifest do { "chef_type" => "cookbook_version", - "name" => "tatft-1.2.3", - "version" => "1.2.3", + "name" => "tatft-1.2.3", + "version" => "1.2.3", "cookbook_name" => "tatft", - "metadata" => metadata, + "metadata" => metadata, "frozen?" => false, @@ -129,9 +129,9 @@ describe Chef::CookbookManifest do end { - "name" => name, - "path" => relative_path, - "checksum" => Chef::Digester.generate_md5_checksum_for_file(path), + "name" => name, + "path" => relative_path, + "checksum" => Chef::Digester.generate_md5_checksum_for_file(path), "specificity" => "default", }.tap do |fp| if full @@ -145,10 +145,10 @@ describe Chef::CookbookManifest do { "chef_type" => "cookbook_version", - "name" => "tatft-1.2.3", - "version" => "1.2.3", + "name" => "tatft-1.2.3", + "version" => "1.2.3", "cookbook_name" => "tatft", - "metadata" => metadata, + "metadata" => metadata, "frozen?" => false, diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb index 87ff7abdd7..af714094d0 100644 --- a/spec/unit/cookbook_site_streaming_uploader_spec.rb +++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb @@ -25,8 +25,7 @@ class FakeTempfile @basename = basename end - def close - end + def close; end def path "#{@basename}.ZZZ" diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb index 26e8d28454..2adecfaa82 100644 --- a/spec/unit/cookbook_uploader_spec.rb +++ b/spec/unit/cookbook_uploader_spec.rb @@ -96,8 +96,8 @@ describe Chef::CookbookUploader do upload_headers = { "content-type" => "application/x-binary", - "content-md5" => an_instance_of(String), - "accept" => "application/json", + "content-md5" => an_instance_of(String), + "accept" => "application/json", } expect(http_client).to receive(:put) diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb index d5ecbe4d62..4d0c8c62f1 100644 --- a/spec/unit/cookbook_version_file_specificity_spec.rb +++ b/spec/unit/cookbook_version_file_specificity_spec.rb @@ -371,7 +371,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum-host-1", "csum-host-2"]) + expect(checksums.sort).to eq(%w{csum-host-1 csum-host-2}) end it "should return a directory of manifest records based on priority preference: platform & full version" do @@ -385,7 +385,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum-platver-full-1", "csum-platver-full-2"]) + expect(checksums.sort).to eq(%w{csum-platver-full-1 csum-platver-full-2}) end it "should return a directory of manifest records based on priority preference: platform & partial version" do @@ -399,7 +399,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum-platver-partial-1", "csum-platver-partial-2"]) + expect(checksums.sort).to eq(%w{csum-platver-partial-1 csum-platver-partial-2}) end it "should return a directory of manifest records based on priority preference: platform only" do @@ -413,7 +413,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum-plat-1", "csum-plat-2"]) + expect(checksums.sort).to eq(%w{csum-plat-1 csum-plat-2}) end it "should return a directory of manifest records based on priority preference: default" do @@ -427,7 +427,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum-default-1", "csum-default-2"]) + expect(checksums.sort).to eq(%w{csum-default-1 csum-default-2}) end it "should return a manifest record based on priority preference: platform & full version - platform_version variant 1" do @@ -441,7 +441,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum2-platver-full-1", "csum2-platver-full-2"]) + expect(checksums.sort).to eq(%w{csum2-platver-full-1 csum2-platver-full-2}) end it "should return a manifest record based on priority preference: platform & partial version - platform_version variant 1" do @@ -455,7 +455,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum2-platver-partial-1", "csum2-platver-partial-2"]) + expect(checksums.sort).to eq(%w{csum2-platver-partial-1 csum2-platver-partial-2}) end it "should return a manifest record based on priority preference: platform & full version - platform_version variant 2" do @@ -469,7 +469,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum3-platver-full-1", "csum3-platver-full-2"]) + expect(checksums.sort).to eq(%w{csum3-platver-full-1 csum3-platver-full-2}) end it "should return a manifest record based on priority preference: platform & full version - platform_version variant 3" do @@ -483,7 +483,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(manifest_records.size).to eq(2) checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] } - expect(checksums.sort).to eq(["csum4-platver-full-1", "csum4-platver-full-2"]) + expect(checksums.sort).to eq(%w{csum4-platver-full-1 csum4-platver-full-2}) end end diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb index 83fb3f578f..aede87abfd 100644 --- a/spec/unit/cookbook_version_spec.rb +++ b/spec/unit/cookbook_version_spec.rb @@ -50,7 +50,7 @@ describe Chef::CookbookVersion do let(:cookbook_paths_by_type) do { # Dunno if the paths here are representitive of what is set by CookbookLoader... - all_files: Dir[File.join(cookbook_root, "**", "**")], + all_files: Dir[File.join(cookbook_root, "**", "**")], } end @@ -117,7 +117,7 @@ describe Chef::CookbookVersion do let(:cookbook_paths_by_type) do { - all_files: Dir[File.join(cookbook_root, "**", "**")], + all_files: Dir[File.join(cookbook_root, "**", "**")], } end diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 70fcd7041e..4d95e7f8d3 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -43,7 +43,7 @@ describe Chef::DataBagItem do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { data_bag_item.data_bag Hash.new }.to raise_error(ArgumentError) + expect { data_bag_item.data_bag({}) }.to raise_error(ArgumentError) end end @@ -148,12 +148,12 @@ describe Chef::DataBagItem do end it "implements all the methods of Hash" do - methods = [:rehash, :to_hash, :[], :fetch, :[]=, :store, :default, - :default=, :default_proc, :index, :size, :length, - :empty?, :each_value, :each_key, :each_pair, :each, :keys, :values, - :values_at, :delete, :delete_if, :reject!, :clear, - :invert, :update, :replace, :merge!, :merge, :has_key?, :has_value?, - :key?, :value?] + methods = %i{rehash to_hash [] fetch []= store default + default= default_proc index size length + empty? each_value each_key each_pair each keys values + values_at delete delete_if reject! clear + invert update replace merge! merge has_key? has_value? + key? value?} methods.each do |m| expect(data_bag_item).to respond_to(m) end diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index 388c35232f..4b0ba42172 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -46,7 +46,7 @@ describe Chef::DataBag do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @data_bag.name Hash.new }.to raise_error(ArgumentError) + expect { @data_bag.name({}) }.to raise_error(ArgumentError) end [ ".", "-", "_", "1"].each do |char| diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb index 87729d8652..858f84859c 100644 --- a/spec/unit/data_collector_spec.rb +++ b/spec/unit/data_collector_spec.rb @@ -401,11 +401,11 @@ describe Chef::DataCollector::Reporter do let(:run_status) do instance_double("Chef::RunStatus", - run_id: "run_id", - node: node, - start_time: Time.new, - end_time: Time.new, - exception: exception) + run_id: "run_id", + node: node, + start_time: Time.new, + end_time: Time.new, + exception: exception) end before do @@ -727,29 +727,29 @@ describe Chef::DataCollector::Reporter do Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError, Errno::EHOSTDOWN ].each do |exception_class| - context "when the block raises a #{exception_class} exception" do - it "disables the reporter" do - expect(reporter).to receive(:disable_data_collector_reporter) - reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } - end + context "when the block raises a #{exception_class} exception" do + it "disables the reporter" do + expect(reporter).to receive(:disable_data_collector_reporter) + reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } + end - context "when raise-on-failure is enabled" do - it "logs an error and raises" do - Chef::Config[:data_collector][:raise_on_failure] = true - expect(Chef::Log).to receive(:error) - expect { reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } }.to raise_error(exception_class) + context "when raise-on-failure is enabled" do + it "logs an error and raises" do + Chef::Config[:data_collector][:raise_on_failure] = true + expect(Chef::Log).to receive(:error) + expect { reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } }.to raise_error(exception_class) + end end - end - context "when raise-on-failure is disabled" do - it "logs an info message and does not raise an exception" do - Chef::Config[:data_collector][:raise_on_failure] = false - expect(Chef::Log).to receive(:info) - expect { reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } }.not_to raise_error + context "when raise-on-failure is disabled" do + it "logs an info message and does not raise an exception" do + Chef::Config[:data_collector][:raise_on_failure] = false + expect(Chef::Log).to receive(:info) + expect { reporter.send(:disable_reporter_on_error) { raise exception_class.new("bummer") } }.not_to raise_error + end end end end - end end describe "#validate_data_collector_server_url!" do @@ -824,7 +824,7 @@ describe Chef::DataCollector::Reporter do resource_a = Chef::Resource::Service.new("processed service") resource_b = Chef::Resource::Service.new("unprocessed service") - resource_a.action = [ :enable, :start ] + resource_a.action = %i{enable start} resource_b.action = :start run_context = Chef::RunContext.new(Chef::Node.new, Chef::CookbookCollection.new, nil) diff --git a/spec/unit/decorator_spec.rb b/spec/unit/decorator_spec.rb index 6d73db2cc4..80bbd73bdf 100644 --- a/spec/unit/decorator_spec.rb +++ b/spec/unit/decorator_spec.rb @@ -28,11 +28,11 @@ def impersonates_a(klass) end it "#kind_of?(#{klass}) is true" do - expect(decorator.kind_of?(klass)).to be true + expect(decorator.is_a?(klass)).to be true end it "#kind_of?(Chef::Decorator) is true" do - expect(decorator.kind_of?(Chef::Decorator)).to be true + expect(decorator.is_a?(Chef::Decorator)).to be true end it "#instance_of?(#{klass}) is false" do diff --git a/spec/unit/deprecated_spec.rb b/spec/unit/deprecated_spec.rb index 9c60080cef..7564c042c4 100644 --- a/spec/unit/deprecated_spec.rb +++ b/spec/unit/deprecated_spec.rb @@ -44,7 +44,7 @@ describe Chef::Deprecated do let(:location) { "the location" } it "displays the full URL" do - expect(TestDeprecation.new().url).to eql("https://docs.chef.io/deprecations_test.html") + expect(TestDeprecation.new.url).to eql("https://docs.chef.io/deprecations_test.html") end it "formats a complete deprecation message" do @@ -59,7 +59,7 @@ describe Chef::Deprecated do end collisions = id_map.select { |k, v| v.size != 1 } unless collisions.empty? - raise "Found deprecation ID collisions:\n#{collisions.map { |k, v| "* #{k} #{v.map(&:name).join(', ')}" }.join("\n")}" + raise "Found deprecation ID collisions:\n#{collisions.map { |k, v| "* #{k} #{v.map(&:name).join(", ")}" }.join("\n")}" end end end diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb index f93f07bc52..afc2eacbd7 100644 --- a/spec/unit/dsl/data_query_spec.rb +++ b/spec/unit/dsl/data_query_spec.rb @@ -24,7 +24,7 @@ class DataQueryDSLTester end describe Chef::DSL::DataQuery do - let(:node) { Hash.new } + let(:node) { {} } let(:language) do language = DataQueryDSLTester.new @@ -68,7 +68,8 @@ describe Chef::DSL::DataQuery do "a1" => [1, 2, 3], "a2" => { "b1" => true }, }, - } end + } + end let(:item) do item = Chef::DataBagItem.new diff --git a/spec/unit/dsl/declare_resource_spec.rb b/spec/unit/dsl/declare_resource_spec.rb index 255e85e22e..ead0be2967 100644 --- a/spec/unit/dsl/declare_resource_spec.rb +++ b/spec/unit/dsl/declare_resource_spec.rb @@ -34,7 +34,7 @@ describe Chef::ResourceCollection do describe "mixed in correctly" do it "the resources() method winds up in the right classes" do - methods = [ :resources, :find_resource, :find_resource!, :edit_resource, :edit_resource!, :delete_resource, :delete_resource!, :declare_resource, :build_resource ] + methods = %i{resources find_resource find_resource! edit_resource edit_resource! delete_resource delete_resource! declare_resource build_resource} expect(Chef::Resource.instance_methods).to include(*methods) expect(Chef::Recipe.instance_methods).to include(*methods) expect(Chef::Provider.instance_methods).to include(*methods) diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb index 51123ba930..7af233a769 100644 --- a/spec/unit/dsl/platform_introspection_spec.rb +++ b/spec/unit/dsl/platform_introspection_spec.rb @@ -40,7 +40,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do before do platform_hash = { :openbsd => { default: "free, functional, secure" }, - [:redhat, :centos, :fedora, :scientific] => { default: '"stable"' }, + %i{redhat centos fedora scientific} => { default: '"stable"' }, :ubuntu => { "10.04" => "using upstart more", :default => "using init more" }, :default => "bork da bork", } @@ -84,7 +84,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do end describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do before do - @array_values = [:stop, :start, :reload] + @array_values = %i{stop start reload} @platform_family_hash = { "debian" => "debian value", diff --git a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb index 7e885f8818..f8fcb654d9 100644 --- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb @@ -47,7 +47,8 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do "a1" => [1, 2, 3], "a2" => { "b1" => true }, }, - } end + } + end let(:version) { 1 } let(:encoded_data) do diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 14b5d9eb28..f406aa2ad0 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -325,7 +325,8 @@ describe Chef::EncryptedDataBagItem do "id" => "item_name", "greeting" => "hello", "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } }, - } end + } + end let(:secret) { "abc123SECRET" } let(:encoded_data) { subject.encrypt_data_bag_item(plaintext_data, secret) } diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb index 483ee615a2..becec412c7 100644 --- a/spec/unit/environment_spec.rb +++ b/spec/unit/environment_spec.rb @@ -48,8 +48,8 @@ describe Chef::Environment do end it "should not accept anything but strings" do - expect { @environment.name(Array.new) }.to raise_error(ArgumentError) - expect { @environment.name(Hash.new) }.to raise_error(ArgumentError) + expect { @environment.name([]) }.to raise_error(ArgumentError) + expect { @environment.name({}) }.to raise_error(ArgumentError) expect { @environment.name(2) }.to raise_error(ArgumentError) end end @@ -65,8 +65,8 @@ describe Chef::Environment do end it "should not accept anything but strings" do - expect { @environment.description(Array.new) }.to raise_error(ArgumentError) - expect { @environment.description(Hash.new) }.to raise_error(ArgumentError) + expect { @environment.description([]) }.to raise_error(ArgumentError) + expect { @environment.description({}) }.to raise_error(ArgumentError) expect { @environment.description(42) }.to raise_error(ArgumentError) end end @@ -82,7 +82,7 @@ describe Chef::Environment do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @environment.default_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @environment.default_attributes([]) }.to raise_error(ArgumentError) end end @@ -97,15 +97,15 @@ describe Chef::Environment do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @environment.override_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @environment.override_attributes([]) }.to raise_error(ArgumentError) end end describe "cookbook_versions" do before(:each) do @cookbook_versions = { - "apt" => "= 1.0.0", - "god" => "= 2.0.0", + "apt" => "= 1.0.0", + "god" => "= 2.0.0", "apache2" => "= 4.2.0", } end @@ -121,7 +121,7 @@ describe Chef::Environment do it "should not accept anything but a hash" do expect { @environment.cookbook_versions("I am a string!") }.to raise_error(ArgumentError) - expect { @environment.cookbook_versions(Array.new) }.to raise_error(ArgumentError) + expect { @environment.cookbook_versions([]) }.to raise_error(ArgumentError) expect { @environment.cookbook_versions(42) }.to raise_error(ArgumentError) end @@ -243,8 +243,8 @@ describe Chef::Environment do describe "self.validate_cookbook_versions" do before(:each) do @cookbook_versions = { - "apt" => "= 1.0.0", - "god" => "= 2.0.0", + "apt" => "= 1.0.0", + "god" => "= 2.0.0", "apache2" => "= 4.2.0", } end @@ -257,7 +257,7 @@ describe Chef::Environment do end it "should return false if anything other than a hash is passed as the argument" do - expect(Chef::Environment.validate_cookbook_versions(Array.new)).to eq(false) + expect(Chef::Environment.validate_cookbook_versions([])).to eq(false) expect(Chef::Environment.validate_cookbook_versions(42)).to eq(false) expect(Chef::Environment.validate_cookbook_versions(Chef::CookbookVersion.new("meta"))).to eq(false) expect(Chef::Environment.validate_cookbook_versions("cookbook => 1.2.3")).to eq(false) @@ -299,7 +299,7 @@ describe Chef::Environment do expect do Chef::Environment.validate_cookbook_version("= 1.2.3.4") end.to raise_error Chef::Exceptions::IllegalVersionConstraint, - "Environment cookbook version constraints not allowed in chef-solo" + "Environment cookbook version constraints not allowed in chef-solo" end end diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb index 979b067fb6..009242f4fb 100644 --- a/spec/unit/event_dispatch/dsl_spec.rb +++ b/spec/unit/event_dispatch/dsl_spec.rb @@ -63,7 +63,7 @@ describe Chef::EventDispatch::DSL do resource = Chef::Resource::RubyBlock.new("foo", run_context) resource.block {} resource.run_action(:run) - expect(calls).to eq([:started, :updated]) + expect(calls).to eq(%i{started updated}) end it "preserve instance variables across handler callbacks" do diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb index a31074e4bd..491457e8c6 100644 --- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb @@ -38,9 +38,9 @@ describe Chef::FileContentManagement::Deploy::MvUnix do let(:target_file_mode) { 0644 } let(:target_file_stat) do double "File::Stat struct for target file", - mode: target_file_mode, - uid: target_file_uid, - gid: target_file_gid + mode: target_file_mode, + uid: target_file_uid, + gid: target_file_gid end before do diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb index 80155f131c..1aadf89d2d 100644 --- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb @@ -84,8 +84,8 @@ describe Chef::FileContentManagement::Deploy::MvWindows do let(:target_file_security_descriptor) do double "security descriptor for target file", - group: original_target_file_group, - owner: original_target_file_owner + group: original_target_file_group, + owner: original_target_file_owner end let(:updated_target_security_descriptor) do diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb index 0cdb06c3b3..7add65150a 100644 --- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb @@ -60,7 +60,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do @trace = [ "/var/chef/cache/cookbooks/syntax-err/recipes/default.rb:14:in `from_file'", "/var/chef/cache/cookbooks/syntax-err/recipes/default.rb:11:in `from_file'", - "/usr/local/lib/ruby/gems/chef/lib/chef/client.rb:123:in `run'" # should not display + "/usr/local/lib/ruby/gems/chef/lib/chef/client.rb:123:in `run'", # should not display ] @exception = Chef::Exceptions::Package.new("No such package 'non-existing-package'") @exception.set_backtrace(@trace) @@ -122,7 +122,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do source_line = "C:/Users/btm/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)" @resource.source_line = source_line @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception) - expect(@inspector.recipe_snippet).to match(/^# In C:\/Users\/btm/) + expect(@inspector.recipe_snippet).to match(%r{^# In C:/Users/btm}) end it "parses a Windows path" do @@ -136,7 +136,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do source_line = "/home/btm/src/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)" @resource.source_line = source_line @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception) - expect(@inspector.recipe_snippet).to match(/^# In \/home\/btm/) + expect(@inspector.recipe_snippet).to match(%r{^# In /home/btm}) end context "when the recipe file does not exist" do diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index b2ca8704b0..6d7f31c6f1 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -22,7 +22,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do let(:node) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" node diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb index 4a919ad492..0713aacc24 100644 --- a/spec/unit/http/authenticator_spec.rb +++ b/spec/unit/http/authenticator_spec.rb @@ -23,7 +23,7 @@ describe Chef::HTTP::Authenticator do let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") } let(:method) { "GET" } let(:url) { URI("https://chef.example.com/organizations/test") } - let(:headers) { Hash.new } + let(:headers) { {} } let(:data) { "" } context "when handle_request is called" do @@ -92,7 +92,8 @@ describe Chef::HTTP::Authenticator do it "calls authentication_headers with the proper input" do expect(class_instance).to receive(:authentication_headers).with( method, url, data, - { "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION }).and_return({}) + { "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION } + ).and_return({}) class_instance.handle_request(method, url, headers, data) end end @@ -108,7 +109,7 @@ describe Chef::HTTP::Authenticator do wxpGV4dGtdcahwXNE4601aXPra+xPcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1Q YwIDAQAB -----END PUBLIC KEY----- -EOH + EOH let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test", raw_key: public_key, ssh_agent_signing: true) } diff --git a/spec/unit/http/json_input_spec.rb b/spec/unit/http/json_input_spec.rb index a76c8d1dc7..cddad20f55 100644 --- a/spec/unit/http/json_input_spec.rb +++ b/spec/unit/http/json_input_spec.rb @@ -21,7 +21,7 @@ require "chef/http/json_input" describe Chef::HTTP::JSONInput do - let(:json_encoder) { described_class.new() } + let(:json_encoder) { described_class.new } let(:url) { URI.parse("http://example.com") } let(:headers) { {} } diff --git a/spec/unit/http/socketless_chef_zero_client_spec.rb b/spec/unit/http/socketless_chef_zero_client_spec.rb index 4f3aed13c5..4bbc4f6768 100644 --- a/spec/unit/http/socketless_chef_zero_client_spec.rb +++ b/spec/unit/http/socketless_chef_zero_client_spec.rb @@ -38,13 +38,13 @@ describe Chef::HTTP::SocketlessChefZeroClient do let(:expected_rack_req) do { - "SCRIPT_NAME" => "", - "SERVER_NAME" => "localhost", - "REQUEST_METHOD" => method.to_s.upcase, - "PATH_INFO" => uri.path, - "QUERY_STRING" => uri.query, - "SERVER_PORT" => uri.port, - "HTTP_HOST" => "localhost:#{uri.port}", + "SCRIPT_NAME" => "", + "SERVER_NAME" => "localhost", + "REQUEST_METHOD" => method.to_s.upcase, + "PATH_INFO" => uri.path, + "QUERY_STRING" => uri.query, + "SERVER_PORT" => uri.port, + "HTTP_HOST" => "localhost:#{uri.port}", "rack.url_scheme" => "chefzero", } end @@ -137,16 +137,16 @@ describe Chef::HTTP::SocketlessChefZeroClient do let(:expected_rack_req) do { - "SCRIPT_NAME" => "", - "SERVER_NAME" => "localhost", - "REQUEST_METHOD" => method.to_s.upcase, - "PATH_INFO" => uri.path, - "QUERY_STRING" => uri.query, - "SERVER_PORT" => uri.port, - "HTTP_HOST" => "localhost:#{uri.port}", + "SCRIPT_NAME" => "", + "SERVER_NAME" => "localhost", + "REQUEST_METHOD" => method.to_s.upcase, + "PATH_INFO" => uri.path, + "QUERY_STRING" => uri.query, + "SERVER_PORT" => uri.port, + "HTTP_HOST" => "localhost:#{uri.port}", "HTTP_X_OPS_SERVER_API_VERSION" => "2", "rack.url_scheme" => "chefzero", - "rack.input" => an_instance_of(StringIO), + "rack.input" => an_instance_of(StringIO), } end diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb index ea2eae3df7..efae549490 100644 --- a/spec/unit/key_spec.rb +++ b/spec/unit/key_spec.rb @@ -34,7 +34,7 @@ describe Chef::Key do Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo 0wIDAQAB -----END PUBLIC KEY----- -EOS + EOS end shared_examples_for "fields with username type validation" do @@ -66,7 +66,7 @@ EOS context "when you feed it anything but a string" do it "should raise an ArgumentError" do - expect { key.send(field, Hash.new) }.to raise_error(ArgumentError) + expect { key.send(field, {}) }.to raise_error(ArgumentError) end end end @@ -406,9 +406,9 @@ EOS it "creates a new key via the API with the fingerprint as the name" do expect(rest).to receive(:post).with(url, - { "name" => "12:3e:33:73:0b:f4:ec:72:dc:f0:4c:51:62:27:08:76:96:24:f4:4a", - "public_key" => key.public_key, - "expiration_date" => key.expiration_date }).and_return({}) + { "name" => "12:3e:33:73:0b:f4:ec:72:dc:f0:4c:51:62:27:08:76:96:24:f4:4a", + "public_key" => key.public_key, + "expiration_date" => key.expiration_date }).and_return({}) key.create end end @@ -424,9 +424,9 @@ EOS context "when create_key is false" do it "creates a new key via the API" do expect(rest).to receive(:post).with(url, - { "name" => key.name, - "public_key" => key.public_key, - "expiration_date" => key.expiration_date }).and_return({}) + { "name" => key.name, + "public_key" => key.public_key, + "expiration_date" => key.expiration_date }).and_return({}) key.create end end diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index e4e89b2db3..96e6d39625 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -72,7 +72,7 @@ describe Chef::Knife::Bootstrap do expect(knife).to receive(:read_secret).and_return("secrets") expect(rendered_template).to match("cat > /etc/chef/encrypted_data_bag_secret <<'EOP'") expect(rendered_template).to match('{"run_list":\[\]}') - expect(rendered_template).to match(%r{secrets}) + expect(rendered_template).to match(/secrets/) end end end @@ -92,7 +92,7 @@ describe Chef::Knife::Bootstrap do knife.render_template end it "configures the preinstall command in the bootstrap template correctly" do - expect(rendered_template).to match(%r{command}) + expect(rendered_template).to match(/command/) end end @@ -103,7 +103,7 @@ describe Chef::Knife::Bootstrap do knife.render_template end it "configures the https_proxy environment variable in the bootstrap template correctly" do - expect(rendered_template).to match(%r{https_proxy="1.1.1.1" export https_proxy}) + expect(rendered_template).to match(/https_proxy="1.1.1.1" export https_proxy/) end end @@ -114,7 +114,7 @@ describe Chef::Knife::Bootstrap do knife.render_template end it "configures the https_proxy environment variable in the bootstrap template correctly" do - expect(rendered_template).to match(%r{no_proxy="localserver" export no_proxy}) + expect(rendered_template).to match(/no_proxy="localserver" export no_proxy/) end end @@ -324,7 +324,7 @@ describe Chef::Knife::Bootstrap do it "should create a hint file when told to" do knife.parse_options(["--hint", "openstack"]) knife.merge_configs - expect(knife.render_template).to match(/\/etc\/chef\/ohai\/hints\/openstack.json/) + expect(knife.render_template).to match(%r{/etc/chef/ohai/hints/openstack.json}) end it "should populate a hint file with JSON when given a file to read" do @@ -354,7 +354,7 @@ describe Chef::Knife::Bootstrap do let(:setting) { "api.opscode.com" } it "renders the client.rb with a single FQDN no_proxy entry" do - expect(rendered_template).to match(%r{.*no_proxy\s*"api.opscode.com".*}) + expect(rendered_template).to match(/.*no_proxy\s*"api.opscode.com".*/) end end @@ -362,7 +362,7 @@ describe Chef::Knife::Bootstrap do let(:setting) { "api.opscode.com,172.16.10.*" } it "renders the client.rb with comma-separated FQDN and wildcard IP address no_proxy entries" do - expect(rendered_template).to match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*}) + expect(rendered_template).to match(/.*no_proxy\s*"api.opscode.com,172.16.10.\*".*/) end end @@ -420,7 +420,7 @@ describe Chef::Knife::Bootstrap do it "creates a secret file" do expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true) expect(knife).to receive(:read_secret).and_return(secret) - expect(rendered_template).to match(%r{#{secret}}) + expect(rendered_template).to match(/#{secret}/) end it "renders the client.rb with an encrypted_data_bag_secret entry" do @@ -528,7 +528,9 @@ describe Chef::Knife::Bootstrap do context "when client_d_dir is set" do let(:client_d_dir) do Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_00")) end + File.join(File.dirname(__FILE__), "../../data/client.d_00") + ) + end it "creates /etc/chef/client.d" do expect(rendered_template).to match("mkdir -p /etc/chef/client\.d") @@ -553,7 +555,9 @@ describe Chef::Knife::Bootstrap do context "a nested directory structure" do let(:client_d_dir) do Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_01")) end + File.join(File.dirname(__FILE__), "../../data/client.d_01") + ) + end it "creates a file foo/bar.rb" do expect(rendered_template).to match("cat > /etc/chef/client.d/foo/bar.rb <<'EOP'") expect(rendered_template).to match("1 / 0") diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb index feebab4986..770ba8762f 100644 --- a/spec/unit/knife/client_bulk_delete_spec.rb +++ b/spec/unit/knife/client_bulk_delete_spec.rb @@ -42,10 +42,10 @@ describe Chef::Knife::ClientBulkDelete do let(:nonvalidator_client_names) { %w{tim dan stephen} } let(:nonvalidator_clients) do - clients = Hash.new + clients = {} nonvalidator_client_names.each do |client_name| - client = Chef::ApiClientV1.new() + client = Chef::ApiClientV1.new client.name(client_name) allow(client).to receive(:destroy).and_return(true) clients[client_name] = client @@ -56,10 +56,10 @@ describe Chef::Knife::ClientBulkDelete do let(:validator_client_names) { %w{myorg-validator} } let(:validator_clients) do - clients = Hash.new + clients = {} validator_client_names.each do |validator_client_name| - validator_client = Chef::ApiClientV1.new() + validator_client = Chef::ApiClientV1.new validator_client.name(validator_client_name) allow(validator_client).to receive(:validator).and_return(true) allow(validator_client).to receive(:destroy).and_return(true) diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb index c83ceed6cb..be76250e7c 100644 --- a/spec/unit/knife/configure_client_spec.rb +++ b/spec/unit/knife/configure_client_spec.rb @@ -58,7 +58,7 @@ describe Chef::Knife::ConfigureClient do it "should write out the config file" do allow(FileUtils).to receive(:mkdir_p) @knife.run - expect(@client_file.string).to match /chef_server_url\s+'https\:\/\/chef\.example\.com'/ + expect(@client_file.string).to match %r{chef_server_url\s+'https\://chef\.example\.com'} expect(@client_file.string).to match /validation_client_name\s+'chef-validator'/ end diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 1cdad0cd0e..6b41e54778 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -159,7 +159,7 @@ describe Chef::Knife::Configure do @knife.run expect(config_file.string).to match(/^client_name[\s]+=[\s]+'#{Etc.getlogin}'$/) expect(config_file.string).to match(%r{^client_key[\s]+=[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$}) - expect(config_file.string).to match(%r{^chef_server_url\s+=[\s]+'#{default_server_url}'$}) + expect(config_file.string).to match(/^chef_server_url\s+=[\s]+'#{default_server_url}'$/) end it "creates a new client when given the --initial option" do diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index c8c1873081..d01213227b 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -31,7 +31,7 @@ describe Chef::Knife::CookbookBulkDelete do allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:stderr).and_return(@stderr) allow(@knife.ui).to receive(:confirm).and_return(true) - @cookbooks = Hash.new + @cookbooks = {} %w{cheezburger pizza lasagna}.each do |cookbook_name| cookbook = Chef::CookbookVersion.new(cookbook_name) @cookbooks[cookbook_name] = cookbook diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb index f65a26c455..4de907e94d 100644 --- a/spec/unit/knife/cookbook_delete_spec.rb +++ b/spec/unit/knife/cookbook_delete_spec.rb @@ -76,8 +76,8 @@ describe Chef::Knife::CookbookDelete do @knife.cookbook_name = "foobar" @knife.version = "1.0.0" expect(@knife).to receive(:delete_object).with(Chef::CookbookVersion, - "foobar version 1.0.0", - "cookbook").and_yield() + "foobar version 1.0.0", + "cookbook").and_yield expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0") @knife.delete_explicit_version end diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index 122c284b93..78dd20e2d2 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -112,7 +112,7 @@ describe Chef::Knife::CookbookDownload do it "should print an error and exit if the cookbook download directory already exists" do expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true) - expect(@knife.ui).to receive(:fatal).with(/\/var\/tmp\/chef\/foobar-1\.0\.0 exists/i) + expect(@knife.ui).to receive(:fatal).with(%r{/var/tmp/chef/foobar-1\.0\.0 exists}i) expect { @knife.run }.to raise_error(SystemExit) end @@ -141,7 +141,7 @@ describe Chef::Knife::CookbookDownload do expect(@stderr.string).to match /downloading #{segment}/im end expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im - expect(@stderr.string).to match /cookbook downloaded to \/var\/tmp\/chef\/foobar-1\.0\.0/im + expect(@stderr.string).to match %r{cookbook downloaded to /var/tmp/chef/foobar-1\.0\.0}im end describe "with -f or --force" do diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb index c19fc5ae2d..04d851be6a 100644 --- a/spec/unit/knife/cookbook_metadata_spec.rb +++ b/spec/unit/knife/cookbook_metadata_spec.rb @@ -98,8 +98,8 @@ describe Chef::Knife::CookbookMetadata do it "should generate the metadata for each cookbook" do expect(Chef::CookbookLoader).to receive(:new).with(cookbook_dir).and_call_original knife.run - expect(stderr.string).to match /generating metadata for foo from #{cookbook_dir}\/foo\/metadata\.rb/im - expect(stderr.string).to match /generating metadata for bar from #{cookbook_dir}\/bar\/metadata\.rb/im + expect(stderr.string).to match %r{generating metadata for foo from #{cookbook_dir}/foo/metadata\.rb}im + expect(stderr.string).to match %r{generating metadata for bar from #{cookbook_dir}/bar/metadata\.rb}im end it "with -o or --cookbook_path should look in the provided path and generate cookbook metadata" do @@ -107,8 +107,8 @@ describe Chef::Knife::CookbookMetadata do knife.config[:cookbook_path] = cookbook_dir expect(Chef::CookbookLoader).to receive(:new).with(cookbook_dir).and_call_original knife.run - expect(stderr.string).to match /generating metadata for foo from #{cookbook_dir}\/foo\/metadata\.rb/im - expect(stderr.string).to match /generating metadata for bar from #{cookbook_dir}\/bar\/metadata\.rb/im + expect(stderr.string).to match %r{generating metadata for foo from #{cookbook_dir}/foo/metadata\.rb}im + expect(stderr.string).to match %r{generating metadata for bar from #{cookbook_dir}/bar/metadata\.rb}im end end diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb index 74612f520d..e4a7cf5943 100644 --- a/spec/unit/knife/cookbook_upload_spec.rb +++ b/spec/unit/knife/cookbook_upload_spec.rb @@ -122,7 +122,7 @@ describe Chef::Knife::CookbookUpload do test_cookbook: /path/one/test_cookbook /path/two/test_cookbook -E + E expect(output.string).to include(expected_message) end end @@ -198,7 +198,7 @@ E before(:each) do cookbook.metadata.depends("dependency") allow(cookbook_loader).to receive(:[]) do |ckbk| - { "test_cookbook" => cookbook, + { "test_cookbook" => cookbook, "dependency" => cookbook_dependency }[ckbk] end allow(knife).to receive(:cookbook_names).and_return(%w{cookbook_dependency test_cookbook}) @@ -225,7 +225,7 @@ E cookbook_dependency2 = Chef::CookbookVersion.new("dependency2") cookbook.metadata.depends("dependency2") allow(cookbook_loader).to receive(:[]) do |ckbk| - { "test_cookbook" => cookbook, + { "test_cookbook" => cookbook, "dependency" => cookbook_dependency, "dependency2" => cookbook_dependency2 }[ckbk] end @@ -291,7 +291,8 @@ E it "should warn users that no cookbooks exist" do knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"] expect(knife.ui).to receive(:warn).with( - /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./) + /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./ + ) knife.run end end @@ -300,7 +301,8 @@ E it "should warn users that no cookbooks exist" do knife.config[:cookbook_path] = "/chef-repo/cookbooks" expect(knife.ui).to receive(:warn).with( - /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./) + /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./ + ) knife.run end end diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index bd48709a93..5aa176557f 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -75,7 +75,7 @@ describe Chef::Knife::Core::BootstrapContext do log_level :info log_location "/tmp/log" # Using default node name (fqdn) -EXPECTED + EXPECTED expect(bootstrap_context.config_content).to eq expected end diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb index a530dbcdaa..a72c184f19 100644 --- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb +++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb @@ -35,7 +35,7 @@ describe Chef::Knife::CookbookSCMRepo do chef-vendor-graphite chef-vendor-python chef-vendor-absent-new -BRANCHES + BRANCHES end it "has a path to the cookbook repo" do @@ -84,7 +84,7 @@ BRANCHES @dirty_status = Mixlib::ShellOut.new @dirty_status.stdout.replace(<<-DIRTY) M chef/lib/chef/knife/cookbook_site_install.rb -DIRTY + DIRTY expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", cwd: @repo_path).and_return(@dirty_status) expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb index 689426de1b..c8bd34d4a9 100644 --- a/spec/unit/knife/core/gem_glob_loader_spec.rb +++ b/spec/unit/knife/core/gem_glob_loader_spec.rb @@ -34,7 +34,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do it "builds a list of the core subcommand file require paths" do expect(loader.subcommand_files).not_to be_empty loader.subcommand_files.each do |require_path| - expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/) + expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*}) end end @@ -52,7 +52,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do expect($LOAD_PATH).to receive(:map).and_return([]) if Gem::Specification.respond_to? :latest_specs expect(Gem::Specification).to receive(:latest_specs).with(true).and_return(gems) - expect(gems[0]).to receive(:matches_for_glob).with(/chef\/knife\/\*\.rb\{(.*),\.rb,(.*)\}/).and_return(gem_files) + expect(gems[0]).to receive(:matches_for_glob).with(%r{chef/knife/\*\.rb\{(.*),\.rb,(.*)\}}).and_return(gem_files) else expect(Gem.source_index).to receive(:latest_specs).with(true).and_return(gems) expect(gems[0]).to receive(:require_paths).twice.and_return(["lib"]) @@ -185,7 +185,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do expect(Gem.source_index).to receive(:latest_specs).and_call_original end loader.subcommand_files.each do |require_path| - expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/) + expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*}) end end @@ -201,7 +201,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do expect(Gem.source_index).to receive(:latest_specs).and_call_original end loader.subcommand_files.each do |require_path| - expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/) + expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*}) end end end diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb index e866f13a9c..c463a36fb4 100644 --- a/spec/unit/knife/core/hashed_command_loader_spec.rb +++ b/spec/unit/knife/core/hashed_command_loader_spec.rb @@ -43,8 +43,10 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do let(:loader) do Chef::Knife::SubcommandLoader::HashedCommandLoader.new( - File.join(CHEF_SPEC_DATA, "knife-site-subcommands"), - plugin_manifest) end + File.join(CHEF_SPEC_DATA, "knife-site-subcommands"), + plugin_manifest + ) + end describe "#list_commands" do before do diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb index a3dd63177d..493de3c5b1 100644 --- a/spec/unit/knife/core/node_editor_spec.rb +++ b/spec/unit/knife/core/node_editor_spec.rb @@ -24,10 +24,10 @@ describe Chef::Knife::NodeEditor do { "name" => "test_node", "chef_environment" => "production", "automatic" => { "foo" => "bar" }, - "default" => { "alpha" => { "bravo" => "charlie", "delta" => "echo" } }, - "normal" => { "alpha" => { "bravo" => "hotel" }, "tags" => [] }, - "override" => { "alpha" => { "bravo" => "foxtrot", "delta" => "golf" } }, - "policy_name" => nil, + "default" => { "alpha" => { "bravo" => "charlie", "delta" => "echo" } }, + "normal" => { "alpha" => { "bravo" => "hotel" }, "tags" => [] }, + "override" => { "alpha" => { "bravo" => "foxtrot", "delta" => "golf" } }, + "policy_name" => nil, "policy_group" => nil, "run_list" => %w{role[comedy] role[drama] recipe[mystery]}, } @@ -44,13 +44,13 @@ describe Chef::Knife::NodeEditor do describe "#view" do it "returns a Hash with only the name, chef_environment, normal, " + "policy_name, policy_group, and run_list properties" do - expected = node_data.select do |key,| - %w{ name chef_environment normal - policy_name policy_group run_list }.include?(key) - end + expected = node_data.select do |key,| + %w{ name chef_environment normal + policy_name policy_group run_list }.include?(key) + end - expect(subject.view).to eq(expected) - end + expect(subject.view).to eq(expected) + end context "when config[:all_attributes] == true" do let(:config) { base_config.merge(all_attributes: true) } @@ -190,8 +190,8 @@ describe Chef::Knife::NodeEditor do it "returns an array of property names that doesn't include " + "the non-editable properties" do - expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list } - end + expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list } + end end end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 025c1ecd91..e5f19a4837 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -214,7 +214,7 @@ describe Chef::Knife::UI do expect(@out.string).to eq <<~EOM hi: a lo: b -EOM + EOM end it "formats empty hashes appropriately" do @@ -227,7 +227,7 @@ EOM expect(@out.string).to eq <<~EOM a b -EOM + EOM end it "formats empty arrays appropriately" do @@ -253,7 +253,7 @@ EOM c d -EOM + EOM end it "formats nested arrays with single- and empty subarrays appropriately" do @@ -267,7 +267,7 @@ EOM d e -EOM + EOM end it "formats arrays of hashes with extra lines in between for readability" do @@ -280,7 +280,7 @@ EOM m: n o: p -EOM + EOM end it "formats hashes with empty array members appropriately" do @@ -288,7 +288,7 @@ EOM expect(@out.string).to eq <<~EOM a: b: c -EOM + EOM end it "formats hashes with single-member array values appropriately" do @@ -296,7 +296,7 @@ EOM expect(@out.string).to eq <<~EOM a: foo b: c -EOM + EOM end it "formats hashes with array members appropriately" do @@ -306,7 +306,7 @@ EOM foo bar b: c -EOM + EOM end it "formats hashes with single-member nested array values appropriately" do @@ -315,7 +315,7 @@ EOM a: foo b: c -EOM + EOM end it "formats hashes with nested array values appropriately" do @@ -332,7 +332,7 @@ EOM aa: bb cc: dd b: c -EOM + EOM end it "formats hashes with empty hash values appropriately" do @@ -340,7 +340,7 @@ EOM expect(@out.string).to eq <<~EOM a: b: c -EOM + EOM end end diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb index 3bea392ae2..bc0ca330e8 100644 --- a/spec/unit/knife/data_bag_from_file_spec.rb +++ b/spec/unit/knife/data_bag_from_file_spec.rb @@ -77,7 +77,8 @@ describe Chef::Knife::DataBagFromFile do "id" => "item_name", "greeting" => "hello", "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } }, - } end + } + end let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) } let(:rest) { double("Chef::ServerAPI") } diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb index 8dd0669993..6ac6dd3c95 100644 --- a/spec/unit/knife/data_bag_show_spec.rb +++ b/spec/unit/knife/data_bag_show_spec.rb @@ -47,7 +47,8 @@ describe Chef::Knife::DataBagShow do let(:data_bag_contents) do { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz", - "qux" => "http://localhost:4000/data/bag_o_data/qux" } end + "qux" => "http://localhost:4000/data/bag_o_data/qux" } + end let(:enc_hash) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(data_bag_contents, secret) } let(:data_bag) { Chef::DataBagItem.from_hash(data_bag_contents) } let(:data_bag_with_encoded_hash) { Chef::DataBagItem.from_hash(enc_hash) } diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb index fcbfd40381..6437ba2bcd 100644 --- a/spec/unit/knife/key_create_spec.rb +++ b/spec/unit/knife/key_create_spec.rb @@ -84,7 +84,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo 0wIDAQAB -----END PUBLIC KEY-----" end - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb index 87969198dc..a22b30cf61 100644 --- a/spec/unit/knife/key_delete_spec.rb +++ b/spec/unit/knife/key_delete_spec.rb @@ -37,7 +37,7 @@ describe "key delete commands that inherit knife" do end context "after apply_params! is called with valid args" do - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } before do command.apply_params!(params) end @@ -59,7 +59,7 @@ describe "key delete commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyDelete) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end @@ -69,7 +69,7 @@ describe "key delete commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyDelete) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end end diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb index 1650386da6..1f8067c160 100644 --- a/spec/unit/knife/key_edit_spec.rb +++ b/spec/unit/knife/key_edit_spec.rb @@ -37,7 +37,7 @@ describe "key edit commands that inherit knife" do end context "after apply_params! is called with valid args" do - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } before do command.apply_params!(params) end @@ -59,7 +59,7 @@ describe "key edit commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyEdit) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end @@ -69,7 +69,7 @@ describe "key edit commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyEdit) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end end @@ -86,7 +86,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo 0wIDAQAB -----END PUBLIC KEY-----" end - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:keyname) { "charmander-key" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb index e221a4da72..c65a11b08c 100644 --- a/spec/unit/knife/key_list_spec.rb +++ b/spec/unit/knife/key_list_spec.rb @@ -73,7 +73,7 @@ describe "key list commands that inherit knife" do end describe Chef::Knife::KeyList do - let(:config) { Hash.new } + let(:config) { {} } let(:actor) { "charmander" } let(:ui) { instance_double("Chef::Knife::UI") } diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb index f2eb244b23..83ddb4d6aa 100644 --- a/spec/unit/knife/key_show_spec.rb +++ b/spec/unit/knife/key_show_spec.rb @@ -37,7 +37,7 @@ describe "key show commands that inherit knife" do end context "after apply_params! is called with valid args" do - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } before do command.apply_params!(params) end @@ -59,7 +59,7 @@ describe "key show commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyShow) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end @@ -69,7 +69,7 @@ describe "key show commands that inherit knife" do it_should_behave_like "a knife key command with a keyname as the second arg" it_should_behave_like "a knife key command" do let(:service_object) { instance_double(Chef::Knife::KeyShow) } - let(:params) { ["charmander", "charmander-key"] } + let(:params) { %w{charmander charmander-key} } end end end diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb index 2a3563e563..db9e2caab1 100644 --- a/spec/unit/knife/node_bulk_delete_spec.rb +++ b/spec/unit/knife/node_bulk_delete_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::NodeBulkDelete do @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:confirm).and_return(true) - @nodes = Hash.new + @nodes = {} %w{adam brent jacob}.each do |node_name| @nodes[node_name] = "http://localhost:4000/nodes/#{node_name}" end @@ -44,14 +44,14 @@ describe Chef::Knife::NodeBulkDelete do # I hate not having == defined for anything :( actual = @knife.all_nodes expect(actual.keys).to match_array(expected.keys) - expect(actual.values.map { |n| n.name }).to match_array(%w{adam brent jacob}) + expect(actual.values.map(&:name)).to match_array(%w{adam brent jacob}) end end describe "run" do before do @inflatedish_list = @nodes.keys.inject({}) do |nodes_by_name, name| - node = Chef::Node.new() + node = Chef::Node.new node.name(name) allow(node).to receive(:destroy).and_return(true) nodes_by_name[name] = node diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb index cc2e0b23af..c5b8925fb5 100644 --- a/spec/unit/knife/node_delete_spec.rb +++ b/spec/unit/knife/node_delete_spec.rb @@ -29,8 +29,8 @@ describe Chef::Knife::NodeDelete do allow(@knife).to receive(:output).and_return(true) allow(@knife).to receive(:confirm).and_return(true) - @adam_node = Chef::Node.new() - @ben_node = Chef::Node.new() + @adam_node = Chef::Node.new + @ben_node = Chef::Node.new allow(@ben_node).to receive(:destroy).and_return(true) allow(@adam_node).to receive(:destroy).and_return(true) allow(Chef::Node).to receive(:load).with("adam").and_return(@adam_node) diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb index dfc0986ebe..83d78b68f1 100644 --- a/spec/unit/knife/node_edit_spec.rb +++ b/spec/unit/knife/node_edit_spec.rb @@ -35,7 +35,7 @@ describe Chef::Knife::NodeEdit do print_after: nil, } @knife.name_args = [ "adam" ] - @node = Chef::Node.new() + @node = Chef::Node.new end it "should load the node" do diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb index 7ceafdad78..5b704c4219 100644 --- a/spec/unit/knife/node_environment_set_spec.rb +++ b/spec/unit/knife/node_environment_set_spec.rb @@ -24,7 +24,7 @@ describe Chef::Knife::NodeEnvironmentSet do @knife = Chef::Knife::NodeEnvironmentSet.new @knife.name_args = %w{adam bar} allow(@knife).to receive(:output).and_return(true) - @node = Chef::Node.new() + @node = Chef::Node.new @node.name("knifetest-node") @node.chef_environment << "foo" allow(@node).to receive(:save).and_return(true) diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb index cf128a80a0..524780c0b8 100644 --- a/spec/unit/knife/node_from_file_spec.rb +++ b/spec/unit/knife/node_from_file_spec.rb @@ -30,7 +30,7 @@ describe Chef::Knife::NodeFromFile do @knife.name_args = [ "adam.rb" ] allow(@knife).to receive(:output).and_return(true) allow(@knife).to receive(:confirm).and_return(true) - @node = Chef::Node.new() + @node = Chef::Node.new allow(@node).to receive(:save) allow(@knife.loader).to receive(:load_from).and_return(@node) @stdout = StringIO.new diff --git a/spec/unit/knife/node_policy_set_spec.rb b/spec/unit/knife/node_policy_set_spec.rb index 35306937d8..da84019fe1 100644 --- a/spec/unit/knife/node_policy_set_spec.rb +++ b/spec/unit/knife/node_policy_set_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodePolicySet do let(:node) do - node = Chef::Node.new() + node = Chef::Node.new node.name("adam") node.run_list = ["role[base]"] node diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb index 03c89ff9eb..b793333c99 100644 --- a/spec/unit/knife/node_run_list_add_spec.rb +++ b/spec/unit/knife/node_run_list_add_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::NodeRunListAdd do } @knife.name_args = [ "adam", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @node = Chef::Node.new() + @node = Chef::Node.new allow(@node).to receive(:save).and_return(true) allow(Chef::Node).to receive(:load).and_return(@node) end diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb index 4f753d7991..a62b6f4b71 100644 --- a/spec/unit/knife/node_run_list_remove_spec.rb +++ b/spec/unit/knife/node_run_list_remove_spec.rb @@ -24,7 +24,7 @@ describe Chef::Knife::NodeRunListRemove do @knife = Chef::Knife::NodeRunListRemove.new @knife.config[:print_after] = nil @knife.name_args = [ "adam", "role[monkey]" ] - @node = Chef::Node.new() + @node = Chef::Node.new @node.name("knifetest-node") @node.run_list << "role[monkey]" allow(@node).to receive(:save).and_return(true) diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb index bd55edb997..6246dfce6a 100644 --- a/spec/unit/knife/node_run_list_set_spec.rb +++ b/spec/unit/knife/node_run_list_set_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::NodeRunListSet do @knife.config = {} @knife.name_args = [ "adam", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @node = Chef::Node.new() + @node = Chef::Node.new allow(@node).to receive(:save).and_return(true) allow(Chef::Node).to receive(:load).and_return(@node) end diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb index 2f684b27f4..f26bae4233 100644 --- a/spec/unit/knife/node_show_spec.rb +++ b/spec/unit/knife/node_show_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::NodeShow do let(:node) do - node = Chef::Node.new() + node = Chef::Node.new node.name("adam") node.run_list = ["role[base]"] node diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb index 9202998fb9..d1300e9437 100644 --- a/spec/unit/knife/raw_spec.rb +++ b/spec/unit/knife/raw_spec.rb @@ -35,8 +35,8 @@ describe Chef::Knife::Raw do it "should set the x-ops-request-source header when --proxy-auth is set" do knife.config[:proxy_auth] = true expect(rest).to receive(:request).with(:GET, "/nodes", - { "Content-Type" => "application/json", - "x-ops-request-source" => "web" }, false) + { "Content-Type" => "application/json", + "x-ops-request-source" => "web" }, false) knife.run end end diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb index d49adb9354..07a9b484c4 100644 --- a/spec/unit/knife/role_bulk_delete_spec.rb +++ b/spec/unit/knife/role_bulk_delete_spec.rb @@ -29,9 +29,9 @@ describe Chef::Knife::RoleBulkDelete do @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:confirm).and_return(true) - @roles = Hash.new + @roles = {} %w{dev staging production}.each do |role_name| - role = Chef::Role.new() + role = Chef::Role.new role.name(role_name) allow(role).to receive(:destroy).and_return(true) @roles[role_name] = role diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb index 5e2b2caeb5..fa3ef1c9e8 100644 --- a/spec/unit/knife/role_create_spec.rb +++ b/spec/unit/knife/role_create_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::RoleCreate do } @knife.name_args = [ "adam" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:save) allow(Chef::Role).to receive(:new).and_return(@role) allow(@knife).to receive(:edit_data).and_return(@role) diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb index 98c0cde9b2..889287fd04 100644 --- a/spec/unit/knife/role_delete_spec.rb +++ b/spec/unit/knife/role_delete_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::RoleDelete do @knife.name_args = [ "adam" ] allow(@knife).to receive(:output).and_return(true) allow(@knife).to receive(:confirm).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:destroy).and_return(true) allow(Chef::Role).to receive(:load).and_return(@role) @stdout = StringIO.new diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb index 5e03b7aef3..3828bc51b9 100644 --- a/spec/unit/knife/role_edit_spec.rb +++ b/spec/unit/knife/role_edit_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::RoleEdit do @knife.config[:print_after] = nil @knife.name_args = [ "adam" ] allow(@knife.ui).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:save) allow(Chef::Role).to receive(:load).and_return(@role) allow(@knife.ui).to receive(:edit_data).and_return(@role) diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb index 242beeb4a2..39c9740f50 100644 --- a/spec/unit/knife/role_env_run_list_add_spec.rb +++ b/spec/unit/knife/role_env_run_list_add_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::RoleEnvRunListAdd do } @knife.name_args = [ "will", "QA", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:save).and_return(true) allow(Chef::Role).to receive(:load).and_return(@role) end diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb index 7a580ecd4a..14d818fa66 100644 --- a/spec/unit/knife/role_env_run_list_clear_spec.rb +++ b/spec/unit/knife/role_env_run_list_clear_spec.rb @@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListClear do @knife.name_args = %w{will QA} allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb index afbabec528..a9eedf9aa1 100644 --- a/spec/unit/knife/role_env_run_list_remove_spec.rb +++ b/spec/unit/knife/role_env_run_list_remove_spec.rb @@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListRemove do @knife.name_args = [ "will", "QA", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb index c4d231d638..94ef75fa07 100644 --- a/spec/unit/knife/role_env_run_list_replace_spec.rb +++ b/spec/unit/knife/role_env_run_list_replace_spec.rb @@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListReplace do @knife.name_args = [ "will", "QA", "role[dude]", "role[person]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb index 79bd3b152e..4fdef5729f 100644 --- a/spec/unit/knife/role_env_run_list_set_spec.rb +++ b/spec/unit/knife/role_env_run_list_set_spec.rb @@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListSet do @knife.name_args = [ "will", "QA", "role[owen]", "role[mauntel]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb index 827b8ae04d..65a152c1f0 100644 --- a/spec/unit/knife/role_from_file_spec.rb +++ b/spec/unit/knife/role_from_file_spec.rb @@ -30,7 +30,7 @@ describe Chef::Knife::RoleFromFile do @knife.name_args = [ "adam.rb" ] allow(@knife).to receive(:output).and_return(true) allow(@knife).to receive(:confirm).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:save) allow(@knife.loader).to receive(:load_from).and_return(@role) @stdout = StringIO.new diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb index a38b6de9da..38ead92d86 100644 --- a/spec/unit/knife/role_run_list_add_spec.rb +++ b/spec/unit/knife/role_run_list_add_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::RoleRunListAdd do } @knife.name_args = [ "will", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new allow(@role).to receive(:save).and_return(true) allow(Chef::Role).to receive(:load).and_return(@role) end diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb index 8bbc816d6f..b62cc06571 100644 --- a/spec/unit/knife/role_run_list_clear_spec.rb +++ b/spec/unit/knife/role_run_list_clear_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListClear do @knife.name_args = [ "will" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb index c18416feca..c4f0e6d32e 100644 --- a/spec/unit/knife/role_run_list_remove_spec.rb +++ b/spec/unit/knife/role_run_list_remove_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListRemove do @knife.name_args = [ "will", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb index 9b212de0ae..aa76efe249 100644 --- a/spec/unit/knife/role_run_list_replace_spec.rb +++ b/spec/unit/knife/role_run_list_replace_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListReplace do @knife.name_args = [ "will", "role[dude]", "role[person]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb index f8e440f524..69543dbda4 100644 --- a/spec/unit/knife/role_run_list_set_spec.rb +++ b/spec/unit/knife/role_run_list_set_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListSet do @knife.name_args = [ "will", "role[owen]", "role[mauntel]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new @role.name("will") allow(@role).to receive(:save).and_return(true) diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb index 9092110b95..58eae312f6 100644 --- a/spec/unit/knife/ssl_check_spec.rb +++ b/spec/unit/knife/ssl_check_spec.rb @@ -69,10 +69,10 @@ describe Chef::Knife::SslCheck do expect { ssl_check.run }.to raise_error(SystemExit) expected_stdout = <<~E USAGE: knife ssl check [URL] (options) -E + E expected_stderr = <<~E ERROR: Given URI: `foo.test' is invalid -E + E expect(stdout_io.string).to eq(expected_stdout) expect(stderr_io.string).to eq(expected_stderr) end @@ -85,10 +85,10 @@ E expect { ssl_check.run }.to raise_error(SystemExit) expected_stdout = <<~E USAGE: knife ssl check [URL] (options) -E + E expected_stderr = <<~E ERROR: Given URI: `#{name_args[0]}' is invalid -E + E expect(stdout_io.string).to eq(expected_stdout) expect(stderr_io.string).to eq(expected_stderr) end diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb index 45dd27ceec..fb904074b3 100644 --- a/spec/unit/knife/ssl_fetch_spec.rb +++ b/spec/unit/knife/ssl_fetch_spec.rb @@ -70,10 +70,10 @@ describe Chef::Knife::SslFetch do expect { ssl_fetch.run }.to raise_error(SystemExit) expected_stdout = <<~E USAGE: knife ssl fetch [URL] (options) -E + E expected_stderr = <<~E ERROR: Given URI: `foo.test' is invalid -E + E expect(stdout_io.string).to eq(expected_stdout) expect(stderr_io.string).to eq(expected_stderr) end @@ -86,10 +86,10 @@ E expect { ssl_fetch.run }.to raise_error(SystemExit) expected_stdout = <<~E USAGE: knife ssl fetch [URL] (options) -E + E expected_stderr = <<~E ERROR: Given URI: `#{name_args[0]}' is invalid -E + E expect(stdout_io.string).to eq(expected_stdout) expect(stderr_io.string).to eq(expected_stderr) end @@ -190,7 +190,7 @@ E expected_error_text = <<~ERROR_TEXT ERROR: The service at the given URI (http://foo.example.com) does not accept SSL connections ERROR: Perhaps you meant to connect to 'https://foo.example.com'? -ERROR_TEXT + ERROR_TEXT run expect(stderr).to include(expected_error_text) diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb index 929a0f742b..8af3b3e871 100644 --- a/spec/unit/knife/status_spec.rb +++ b/spec/unit/knife/status_spec.rb @@ -30,7 +30,7 @@ describe Chef::Knife::Status do @query = double("Chef::Search::Query") allow(@query).to receive(:search).and_yield(node) allow(Chef::Search::Query).to receive(:new).and_return(@query) - @knife = Chef::Knife::Status.new + @knife = Chef::Knife::Status.new @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end @@ -40,7 +40,8 @@ describe Chef::Knife::Status do { filter_result: { name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"], ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"], - platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } end + platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } + end it "should default to searching for everything" do expect(@query).to receive(:search).with(:node, "*:*", opts) diff --git a/spec/unit/knife/supermarket_download_spec.rb b/spec/unit/knife/supermarket_download_spec.rb index 0332bd4390..71120007e3 100644 --- a/spec/unit/knife/supermarket_download_spec.rb +++ b/spec/unit/knife/supermarket_download_spec.rb @@ -31,8 +31,8 @@ describe Chef::Knife::SupermarketDownload do @cookbook_api_url = "https://supermarket.chef.io/api/v1/cookbooks" @version = "1.0.2" @version_us = @version.tr ".", "_" - @current_data = { "deprecated" => false, - "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}", + @current_data = { "deprecated" => false, + "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}", "replacement" => "other_apache2" } allow(@knife.ui).to receive(:stderr).and_return(@stderr) @@ -60,7 +60,7 @@ describe Chef::Knife::SupermarketDownload do context "when" do before do @cookbook_data = { "version" => @version, - "file" => "http://example.com/apache2_#{@version_us}.tgz" } + "file" => "http://example.com/apache2_#{@version_us}.tgz" } @temp_file = double( path: "/tmp/apache2_#{@version_us}.tgz" ) @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") end @@ -125,7 +125,7 @@ describe Chef::Knife::SupermarketDownload do @version = "1.0.1" @version_us = @version.tr ".", "_" @cookbook_data = { "version" => @version, - "file" => "http://example.com/apache2_#{@version_us}.tgz" } + "file" => "http://example.com/apache2_#{@version_us}.tgz" } @temp_file = double(path: "/tmp/apache2_#{@version_us}.tgz") @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") @knife.name_args << @version diff --git a/spec/unit/knife/supermarket_install_spec.rb b/spec/unit/knife/supermarket_install_spec.rb index 68c8af1028..9c969106fc 100644 --- a/spec/unit/knife/supermarket_install_spec.rb +++ b/spec/unit/knife/supermarket_install_spec.rb @@ -23,12 +23,13 @@ describe Chef::Knife::SupermarketInstall do let(:knife) { Chef::Knife::SupermarketInstall.new } let(:stdout) { StringIO.new } let(:stderr) { StringIO.new } - let(:downloader) { Hash.new } + let(:downloader) { {} } let(:archive) { double(Mixlib::Archive, extract: true) } let(:repo) do double(sanity_check: true, reset_to_default_state: true, prepare_to_import: true, finalize_updates_to: true, - merge_updates_from: true) end + merge_updates_from: true) + end let(:install_path) do if Chef::Platform.windows? "C:/tmp/chef" @@ -81,7 +82,7 @@ describe Chef::Knife::SupermarketInstall do end it "raises an error if the second argument is not a version" do - knife.name_args = ["getting-started", "1pass"] + knife.name_args = %w{getting-started 1pass} expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.") expect { knife.run }.to raise_error(SystemExit) end @@ -93,7 +94,7 @@ describe Chef::Knife::SupermarketInstall do end it "raises an error if the second argument is a one-digit version" do - knife.name_args = ["getting-started", "1"] + knife.name_args = %w{getting-started 1} expect(knife.ui).to receive(:error).with("Installing multiple cookbooks at once is not supported.") expect { knife.run }.to raise_error(SystemExit) end diff --git a/spec/unit/knife/supermarket_share_spec.rb b/spec/unit/knife/supermarket_share_spec.rb index 6601cdcd31..6fdcc6c92f 100644 --- a/spec/unit/knife/supermarket_share_spec.rb +++ b/spec/unit/knife/supermarket_share_spec.rb @@ -175,7 +175,7 @@ describe Chef::Knife::SupermarketShare do response_text = Chef::JSONCompat.to_json({ uri: "https://supermarket.chef.io/cookbooks/cookbook_name" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(201) - expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything()) + expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything, anything, anything) @knife.run end diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index fceb00aa09..c48c87919b 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -35,9 +35,9 @@ describe Chef::Knife do let(:config_loader) do instance_double("WorkstationConfigLoader", - load: nil, no_config_found?: false, - config_location: config_location, - chef_config_dir: "/etc/chef") + load: nil, no_config_found?: false, + config_location: config_location, + chef_config_dir: "/etc/chef") end before(:each) do @@ -55,7 +55,7 @@ describe Chef::Knife do allow(knife.ui).to receive(:print) allow(Chef::Log).to receive(:init) allow(Chef::Log).to receive(:level) - [:debug, :info, :warn, :error, :crit].each do |level_sym| + %i{debug info warn error crit}.each do |level_sym| allow(Chef::Log).to receive(level_sym) end allow(Chef::Knife).to receive(:puts) @@ -166,7 +166,8 @@ describe Chef::Knife do "X-Chef-Version" => Chef::VERSION, "Host" => "api.opscode.piab", "X-REMOTE-REQUEST-ID" => request_id, - } end + } + end let(:request_id) { "1234" } @@ -205,7 +206,7 @@ describe Chef::Knife do KnifeSpecs.send :remove_const, :TestYourself end Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb")) - Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) } + Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.is_a?(Class) } end it "confirms that the headers include X-Remote-Request-Id" do @@ -220,7 +221,7 @@ describe Chef::Knife do KnifeSpecs.send :remove_const, :TestYourself end Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb")) - Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) } + Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.is_a?(Class) } end it "merges the global knife CLI options" do @@ -283,8 +284,8 @@ describe Chef::Knife do describe "merging configuration options" do before do KnifeSpecs::TestYourself.option(:opt_with_default, - short: "-D VALUE", - default: "default-value") + short: "-D VALUE", + default: "default-value") end it "sets the default log_location to STDERR for Chef::Log warnings" do @@ -440,8 +441,8 @@ describe Chef::Knife do allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response)) allow(knife).to receive(:username).and_return("sadpanda") knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action}) - expect(stderr.string).to match(%r{Response: y u no administrator}) + expect(stderr.string).to match(/ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action/) + expect(stderr.string).to match(/Response: y u no administrator/) end context "when proxy servers are set" do @@ -460,9 +461,9 @@ describe Chef::Knife do allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response)) allow(knife).to receive(:username).and_return("sadpanda") knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action}) - expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your Chef server may need to be added to NO_PROXY.}) - expect(stderr.string).to match(%r{Response: y u no administrator}) + expect(stderr.string).to match(/ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action/) + expect(stderr.string).to match(/ERROR: There are proxy servers configured, your Chef server may need to be added to NO_PROXY./) + expect(stderr.string).to match(/Response: y u no administrator/) end end @@ -472,8 +473,8 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong")) allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("400 Bad Request", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: The data in your request was invalid}) - expect(stderr.string).to match(%r{Response: y u search wrong}) + expect(stderr.string).to match(/ERROR: The data in your request was invalid/) + expect(stderr.string).to match(/Response: y u search wrong/) end it "formats 404s nicely" do @@ -482,8 +483,8 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here")) allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("404 Not Found", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: The object you are looking for could not be found}) - expect(stderr.string).to match(%r{Response: nothing to see here}) + expect(stderr.string).to match(/ERROR: The object you are looking for could not be found/) + expect(stderr.string).to match(/Response: nothing to see here/) end it "formats 406s (non-supported API version error) nicely" do @@ -508,8 +509,8 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("500 Internal Server Error", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: internal server error}) - expect(stderr.string).to match(%r{Response: sad trombone}) + expect(stderr.string).to match(/ERROR: internal server error/) + expect(stderr.string).to match(/Response: sad trombone/) end it "formats 502s nicely" do @@ -518,8 +519,8 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sadder trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("502 Bad Gateway", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: bad gateway}) - expect(stderr.string).to match(%r{Response: sadder trombone}) + expect(stderr.string).to match(/ERROR: bad gateway/) + expect(stderr.string).to match(/Response: sadder trombone/) end it "formats 503s nicely" do @@ -528,8 +529,8 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "saddest trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("503 Service Unavailable", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: Service temporarily unavailable}) - expect(stderr.string).to match(%r{Response: saddest trombone}) + expect(stderr.string).to match(/ERROR: Service temporarily unavailable/) + expect(stderr.string).to match(/Response: saddest trombone/) end it "formats other HTTP errors nicely" do @@ -538,16 +539,16 @@ describe Chef::Knife do allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy")) allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("402 Payment Required", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: Payment Required}) - expect(stderr.string).to match(%r{Response: nobugfixtillyoubuy}) + expect(stderr.string).to match(/ERROR: Payment Required/) + expect(stderr.string).to match(/Response: nobugfixtillyoubuy/) end it "formats NameError and NoMethodError nicely" do allow(knife).to receive(:run).and_raise(NameError.new("Undefined constant FUUU")) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: knife encountered an unexpected error}) - expect(stderr.string).to match(%r{This may be a bug in the 'knife' knife command or plugin}) - expect(stderr.string).to match(%r{Exception: NameError: Undefined constant FUUU}) + expect(stderr.string).to match(/ERROR: knife encountered an unexpected error/) + expect(stderr.string).to match(/This may be a bug in the 'knife' knife command or plugin/) + expect(stderr.string).to match(/Exception: NameError: Undefined constant FUUU/) end it "formats missing private key errors nicely" do @@ -555,7 +556,7 @@ describe Chef::Knife do allow(knife).to receive(:api_key).and_return("/home/root/.chef/no-key-here.pem") knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem}) - expect(stderr.string).to match(%r{Check your configuration file and ensure that your private key is readable}) + expect(stderr.string).to match(/Check your configuration file and ensure that your private key is readable/) end it "formats connection refused errors nicely" do @@ -564,8 +565,8 @@ describe Chef::Knife do # Errno::ECONNREFUSED message differs by platform # *nix = Errno::ECONNREFUSED: Connection refused # win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - expect(stderr.string).to match(%r{ERROR: Network Error: .* - y u no shut up}) - expect(stderr.string).to match(%r{Check your knife configuration and network settings}) + expect(stderr.string).to match(/ERROR: Network Error: .* - y u no shut up/) + expect(stderr.string).to match(/Check your knife configuration and network settings/) end it "formats SSL errors nicely and suggests to use `knife ssl check` and `knife ssl fetch`" do @@ -579,7 +580,7 @@ describe Chef::Knife do Use `knife ssl check` to troubleshoot your SSL configuration. If your Chef Server uses a self-signed certificate, you can use `knife ssl fetch` to make knife trust the server's certificates. -MSG + MSG expect(stderr.string).to include(expected_message) end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index a7f95f8bfd..def981801e 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -199,7 +199,7 @@ describe "LWRP" do end it "should create a method for each attribute" do - expect(get_lwrp(:lwrp_foo).new("blah").methods.map { |m| m.to_sym }).to include(:monkey) + expect(get_lwrp(:lwrp_foo).new("blah").methods.map(&:to_sym)).to include(:monkey) end it "should build attribute methods that respect validation rules" do @@ -264,12 +264,12 @@ describe "LWRP" do let(:lwrp) do Class.new(Chef::Resource::LWRPBase) do actions :eat, :sleep - default_action [:eat, :sleep] + default_action %i{eat sleep} end end it "returns the array of default actions" do - expect(lwrp.default_action).to eq([:eat, :sleep]) + expect(lwrp.default_action).to eq(%i{eat sleep}) end end @@ -287,7 +287,7 @@ describe "LWRP" do end it "delegates #actions to the parent" do - expect(child.actions).to eq([:nothing, :eat, :sleep]) + expect(child.actions).to eq(%i{nothing eat sleep}) end it "delegates #default_action to the parent" do @@ -304,7 +304,7 @@ describe "LWRP" do end it "does not delegate #actions to the parent" do - expect(child.actions).to eq([:nothing, :dont_eat, :dont_sleep]) + expect(child.actions).to eq(%i{nothing dont_eat dont_sleep}) end it "does not delegate #default_action to the parent" do @@ -322,7 +322,7 @@ describe "LWRP" do end it "amends actions when they are already defined" do - expect(child.actions).to eq([:nothing, :eat, :sleep, :drink]) + expect(child.actions).to eq(%i{nothing eat sleep drink}) end end end @@ -330,40 +330,40 @@ describe "LWRP" do describe "when actions is set to an array" do let(:resource_class) do Class.new(Chef::Resource::LWRPBase) do - actions [ :eat, :sleep ] + actions %i{eat sleep} end end let(:resource) do resource_class.new("blah") end it "actions includes those actions" do - expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.actions).to eq %i{nothing eat sleep} end it "allowed_actions includes those actions" do - expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.allowed_actions).to eq %i{nothing eat sleep} end it "resource.allowed_actions includes those actions" do - expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource.allowed_actions).to eq %i{nothing eat sleep} end end describe "when allowed_actions is set to an array" do let(:resource_class) do Class.new(Chef::Resource::LWRPBase) do - allowed_actions [ :eat, :sleep ] + allowed_actions %i{eat sleep} end end let(:resource) do resource_class.new("blah") end it "actions includes those actions" do - expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.actions).to eq %i{nothing eat sleep} end it "allowed_actions includes those actions" do - expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource_class.allowed_actions).to eq %i{nothing eat sleep} end it "resource.allowed_actions includes those actions" do - expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ] + expect(resource.allowed_actions).to eq %i{nothing eat sleep} end end end @@ -590,7 +590,7 @@ describe "LWRP" do it "get_lwrp(:lwrp_once).new is an instance of the LWRP class" do lwrp = get_lwrp(:lwrp_once).new("hi") - expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy + expect(lwrp.is_a?(test_lwrp_class)).to be_truthy expect(lwrp.is_a?(test_lwrp_class)).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy expect(test_lwrp_class === lwrp).to be_truthy @@ -603,28 +603,28 @@ describe "LWRP" do it "subclass.new is a subclass" do lwrp = subclass.new("hi") - expect(lwrp.kind_of?(subclass)).to be_truthy + expect(lwrp.is_a?(subclass)).to be_truthy expect(lwrp.is_a?(subclass)).to be_truthy expect(subclass === lwrp).to be_truthy expect(lwrp.class === subclass) end it "subclass.new is an instance of the LWRP class" do lwrp = subclass.new("hi") - expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy + expect(lwrp.is_a?(test_lwrp_class)).to be_truthy expect(lwrp.is_a?(test_lwrp_class)).to be_truthy expect(test_lwrp_class === lwrp).to be_truthy expect(lwrp.class === test_lwrp_class) end it "subclass.new is a get_lwrp(:lwrp_once)" do lwrp = subclass.new("hi") - expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy + expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy expect(lwrp.class === get_lwrp(:lwrp_once)) end it "get_lwrp(:lwrp_once).new is *not* a subclass" do lwrp = get_lwrp(:lwrp_once).new("hi") - expect(lwrp.kind_of?(subclass)).to be_falsey + expect(lwrp.is_a?(subclass)).to be_falsey expect(lwrp.is_a?(subclass)).to be_falsey expect(subclass === lwrp.class).to be_falsey expect(subclass === get_lwrp(:lwrp_once)).to be_falsey diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb index df89962cce..7d2da85e2d 100644 --- a/spec/unit/mixin/homebrew_user_spec.rb +++ b/spec/unit/mixin/homebrew_user_spec.rb @@ -48,7 +48,7 @@ describe Chef::Mixin::HomebrewUser do let(:brew_owner) { 2001 } let(:default_brew_path) { "/usr/local/bin/brew" } let(:stat_double) do - d = double() + d = double expect(d).to receive(:uid).and_return(brew_owner) d end diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 62d6b3e117..489742cb7d 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -30,7 +30,7 @@ end describe Chef::Mixin::ParamsValidate do before(:each) do - @vo = TinyClass.new() + @vo = TinyClass.new end it "should allow a hash and a hash as arguments to validate" do @@ -44,7 +44,7 @@ describe Chef::Mixin::ParamsValidate do it "should require validation map keys to be symbols or strings" do expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error expect { @vo.validate({ one: "two" }, { "one" => true }) }.not_to raise_error - expect { @vo.validate({ one: "two" }, { Hash.new => true }) }.to raise_error(ArgumentError) + expect { @vo.validate({ one: "two" }, { {} => true }) }.to raise_error(ArgumentError) end it "should allow options to be required with true" do @@ -163,7 +163,7 @@ describe Chef::Mixin::ParamsValidate do end it "should let you set a default value with default => value" do - arguments = Hash.new + arguments = {} @vo.validate(arguments, { one: { default: "is the loneliest number", @@ -236,7 +236,7 @@ describe Chef::Mixin::ParamsValidate do { one: { kind_of: String, - respond_to: [ :to_s, :upcase ], + respond_to: %i{to_s upcase}, regex: /^is good/, callbacks: { "should be your friend" => lambda do |a| @@ -260,7 +260,7 @@ describe Chef::Mixin::ParamsValidate do { one: { kind_of: String, - respond_to: [ :to_s, :upcase ], + respond_to: %i{to_s upcase}, regex: /^is good/, callbacks: { "should be your friend" => lambda do |a| @@ -321,7 +321,7 @@ describe Chef::Mixin::ParamsValidate do end.not_to raise_error expect do @vo.validate( - { one: Hash.new }, + { one: {} }, { one: { kind_of: [ String, Array ], @@ -334,22 +334,22 @@ describe Chef::Mixin::ParamsValidate do it "asserts that a value returns false from a predicate method" do expect do @vo.validate({ not_blank: "should pass" }, - { not_blank: { cannot_be: [ :nil, :empty ] } }) + { not_blank: { cannot_be: %i{nil empty} } }) end.not_to raise_error expect do @vo.validate({ not_blank: "" }, - { not_blank: { cannot_be: [ :nil, :empty ] } }) + { not_blank: { cannot_be: %i{nil empty} } }) end.to raise_error(Chef::Exceptions::ValidationFailed) end it "allows a custom validation message" do expect do @vo.validate({ not_blank: "should pass" }, - { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) + { not_blank: { cannot_be: %i{nil empty}, validation_message: "my validation message" } }) end.not_to raise_error expect do @vo.validate({ not_blank: "" }, - { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } }) + { not_blank: { cannot_be: %i{nil empty}, validation_message: "my validation message" } }) end.to raise_error(Chef::Exceptions::ValidationFailed, "my validation message") end diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb index ee0c252381..25b94178e5 100644 --- a/spec/unit/mixin/properties_spec.rb +++ b/spec/unit/mixin/properties_spec.rb @@ -31,7 +31,7 @@ module ChefMixinPropertiesSpec end it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do - expect(A.properties.keys).to eq [ :a, :ab, :ac, :d ] + expect(A.properties.keys).to eq %i{a ab ac d} expect(A.properties[:a].validation_options[:is]).to eq "a" expect(A.properties[:ab].validation_options[:is]).to eq %w{a b} expect(A.properties[:ac].validation_options[:is]).to eq %w{a c} @@ -46,13 +46,13 @@ module ChefMixinPropertiesSpec end it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do - expect(B.properties.keys).to eq [ :b, :ab, :bc ] + expect(B.properties.keys).to eq %i{b ab bc} expect(B.properties[:b].validation_options[:is]).to eq "b" expect(B.properties[:ab].validation_options[:is]).to be_nil expect(B.properties[:bc].validation_options[:is]).to eq %w{b c} end it "C.properties has a, b, c, ac and bc with merged types" do - expect(C.properties.keys).to eq [ :a, :ab, :ac, :d, :b, :bc, :c ] + expect(C.properties.keys).to eq %i{a ab ac d b bc c} expect(C.properties[:a].validation_options[:is]).to eq "a" expect(C.properties[:b].validation_options[:is]).to eq "b" expect(C.properties[:c].validation_options[:is]).to eq "c" @@ -99,7 +99,7 @@ module ChefMixinPropertiesSpec end it "Outerest.properties.validation_options[:is] inner, outer, outerest" do - expect(Outerest.properties.keys).to eq [:inner, :outer, :outerest] + expect(Outerest.properties.keys).to eq %i{inner outer outerest} end end end diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 7f6021d911..ac34256741 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -51,7 +51,7 @@ describe Chef::Mixin::ShellOut do let(:retobj) { instance_double(Mixlib::ShellOut, "error!" => false) } let(:cmd) { "echo '#{rand(1000)}'" } - [ :shell_out, :shell_out_compact, :shell_out_compact_timeout, :shell_out!, :shell_out_compact!, :shell_out_compact_timeout! ].each do |method| + %i{shell_out shell_out_compact shell_out_compact_timeout shell_out! shell_out_compact! shell_out_compact_timeout!}.each do |method| describe "##{method}" do before do Chef::Config[:treat_deprecation_warnings_as_errors] = false @@ -75,11 +75,11 @@ describe Chef::Mixin::ShellOut do options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { environment: { - "HOME" => "/Users/morty", - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) @@ -89,11 +89,11 @@ describe Chef::Mixin::ShellOut do options = { environment: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { environment: { - "HOME" => "/Users/morty", - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) @@ -118,11 +118,11 @@ describe Chef::Mixin::ShellOut do options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { env: { - "HOME" => "/Users/morty", - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) @@ -132,11 +132,11 @@ describe Chef::Mixin::ShellOut do options = { env: { "HOME" => "/Users/morty" } } expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { env: { - "HOME" => "/Users/morty", - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) @@ -150,10 +150,10 @@ describe Chef::Mixin::ShellOut do expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { user: "morty", environment: { - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) @@ -165,10 +165,10 @@ describe Chef::Mixin::ShellOut do it "should set environment language settings to the configured internal locale" do expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, { environment: { - "LC_ALL" => Chef::Config[:internal_locale], - "LANG" => Chef::Config[:internal_locale], + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => sanitized_path, + env_path => sanitized_path, }, }).and_return(retobj) shell_out_obj.send(method, cmd) @@ -301,7 +301,7 @@ describe Chef::Mixin::ShellOut do end describe "deprecations" do - [ :shell_out_with_systems_locale, :shell_out_compact, :shell_out_compact_timeout, :shell_out_with_systems_locale!, :shell_out_compact!, :shell_out_compact_timeout! ].each do |method| + %i{shell_out_with_systems_locale shell_out_compact shell_out_compact_timeout shell_out_with_systems_locale! shell_out_compact! shell_out_compact_timeout!}.each do |method| it "should not respond to #{method} in Chef-15", chef: ">= 15" do expect(shell_out_obj.respond_to?(method)).to be false end @@ -341,7 +341,7 @@ describe Chef::Mixin::ShellOut do end describe "on Chef-15", chef: ">= 15" do - [ :shell_out, :shell_out! ].each do |method| + %i{shell_out shell_out!}.each do |method| stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted! it "#{method} defaults to 900 seconds" do expect(provider).to receive(stubbed_method).with("foo", timeout: 900) @@ -377,7 +377,7 @@ describe Chef::Mixin::ShellOut do let(:new_resource) { Chef::Resource::Package.new("foo") } let(:provider) { new_resource.provider_for_action(:install) } - [ :shell_out, :shell_out! ].each do |method| + %i{shell_out shell_out!}.each do |method| stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted! it "#{method} defaults to 900 seconds" do expect(provider).to receive(stubbed_method).with("foo", timeout: 900) @@ -416,7 +416,7 @@ describe Chef::Mixin::ShellOut do Chef::Config[:treat_deprecation_warnings_as_errors] = false end - [ :shell_out_compact_timeout, :shell_out_compact_timeout! ].each do |method| + %i{shell_out_compact_timeout shell_out_compact_timeout!}.each do |method| stubbed_method = (method == :shell_out_compact_timeout) ? :shell_out_compacted : :shell_out_compacted! it "#{method} defaults to 900 seconds" do expect(provider).to receive(stubbed_method).with("foo", timeout: 900) diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb index 96b983a9dd..04071988ad 100644 --- a/spec/unit/mixin/template_spec.rb +++ b/spec/unit/mixin/template_spec.rb @@ -242,17 +242,13 @@ describe Chef::Mixin::Template, "render_template" do it "emits a warning when overriding 'core' methods" do mod = Module.new do - def render - end + def render; end - def node - end + def node; end - def render_template - end + def render_template; end - def render_template_from_string - end + def render_template_from_string; end end %w{node render render_template render_template_from_string}.each do |method_name| expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/) diff --git a/spec/unit/mixin/unformatter_spec.rb b/spec/unit/mixin/unformatter_spec.rb index b2b57c150c..3c8dba1962 100644 --- a/spec/unit/mixin/unformatter_spec.rb +++ b/spec/unit/mixin/unformatter_spec.rb @@ -22,8 +22,7 @@ require "chef/mixin/unformatter" class Chef::UnformatterTest include Chef::Mixin::Unformatter - def foo - end + def foo; end end diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb index 896241f173..31e182d042 100644 --- a/spec/unit/mixin/user_context_spec.rb +++ b/spec/unit/mixin/user_context_spec.rb @@ -56,8 +56,7 @@ describe "a class that mixes in user_context" do let(:block_object) do class BlockClass - def block_method - end + def block_method; end end BlockClass.new end diff --git a/spec/unit/mixin/which.rb b/spec/unit/mixin/which.rb index 1764b3b89f..c47eaf37ab 100644 --- a/spec/unit/mixin/which.rb +++ b/spec/unit/mixin/which.rb @@ -88,11 +88,13 @@ describe Chef::Mixin::Which do test_which("passes in the filename as the arg", "foo1", finds: "/dir1/foo1") do |f| raise "bad arg to block" unless f == "/dir1/foo1" + true end test_which("arrays with blocks", "foo1", "foo2", finds: "/dir2/foo1", others: [ "/dir1/foo2" ]) do |f| raise "bad arg to block" unless f == "/dir2/foo1" || f == "/dir1/foo2" + true end end diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index 4559702e1c..ad7bee0ec9 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -23,7 +23,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do include Chef::Mixin::WindowsArchitectureHelper before do - @valid_architectures = [ :i386, :x86_64 ] + @valid_architectures = %i{i386 x86_64} @invalid_architectures = [ "i386", "x86_64", :x64, :x86, :arm ] @node_i386 = Chef::Node.new @@ -67,14 +67,14 @@ describe Chef::Mixin::WindowsArchitectureHelper do it "returns true only when forced_32bit_override_required? has 64-bit node architecture and 32-bit desired architecture" do with_node_architecture_combinations do |node, desired_arch| expect(forced_32bit_override_required?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows? - expect(forced_32bit_override_required?(node, desired_arch)).to be false if ! ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386)) + expect(forced_32bit_override_required?(node, desired_arch)).to be false unless (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) end end def with_node_architecture_combinations @valid_architectures.each do |node_architecture| new_node = Chef::Node.new - new_node.default["kernel"] = Hash.new + new_node.default["kernel"] = {} new_node.default["kernel"][:machine] = node_architecture.to_s @valid_architectures.each do |architecture| diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 36827215f0..328b71f0c0 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -63,16 +63,16 @@ describe Chef::Node::Attribute do "mtu" => "1280", "type" => "gif", "encapsulation" => "IPIP" }, - "vmnet8" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "8", - "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255", - "netmask" => "255.255.255.0", - "family" => "inet" }, - "00:50:56:c0:00:08" => { "family" => "lladdr" } }, - "mtu" => "1500", - "type" => "vmnet", - "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" }, - "encapsulation" => "Ethernet" }, + "vmnet8" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "8", + "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255", + "netmask" => "255.255.255.0", + "family" => "inet" }, + "00:50:56:c0:00:08" => { "family" => "lladdr" } }, + "mtu" => "1500", + "type" => "vmnet", + "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" }, + "encapsulation" => "Ethernet" }, "en0" => { "status" => "inactive", "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, "number" => "0", @@ -80,9 +80,9 @@ describe Chef::Node::Attribute do "mtu" => "1500", "media" => { "supported" => { "autoselect" => { "options" => [] }, "none" => { "options" => [] }, - "1000baseT" => { "options" => ["full-duplex", "flow-control", "hw-loopback"] }, - "10baseT/UTP" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] }, - "100baseTX" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] } }, + "1000baseT" => { "options" => %w{full-duplex flow-control hw-loopback} }, + "10baseT/UTP" => { "options" => %w{half-duplex full-duplex flow-control hw-loopback} }, + "100baseTX" => { "options" => %w{half-duplex full-duplex flow-control hw-loopback} } }, "selected" => { "autoselect" => { "options" => [] } } }, "type" => "en", "encapsulation" => "Ethernet" }, @@ -118,28 +118,28 @@ describe Chef::Node::Attribute do "selected" => { "autoselect" => { "options" => [] } } }, "type" => "en", "encapsulation" => "Ethernet" }, - "fw0" => { "status" => "inactive", - "flags" => %w{BROADCAST SIMPLEX MULTICAST}, - "number" => "0", - "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } }, - "mtu" => "4078", - "media" => { "supported" => { "autoselect" => { "options" => ["full-duplex"] } }, - "selected" => { "autoselect" => { "options" => ["full-duplex"] } } }, - "type" => "fw", - "encapsulation" => "1394" }, - "en3" => { "status" => "active", - "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "3", - "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", - "netmask" => "255.255.0.0", - "family" => "inet" }, - "00:1c:42:00:00:00" => { "family" => "lladdr" }, - "fe80::21c:42ff:fe00:0" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, - "mtu" => "1500", - "media" => { "supported" => { "autoselect" => { "options" => [] } }, - "selected" => { "autoselect" => { "options" => [] } } }, - "type" => "en", - "encapsulation" => "Ethernet" } } }, + "fw0" => { "status" => "inactive", + "flags" => %w{BROADCAST SIMPLEX MULTICAST}, + "number" => "0", + "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } }, + "mtu" => "4078", + "media" => { "supported" => { "autoselect" => { "options" => ["full-duplex"] } }, + "selected" => { "autoselect" => { "options" => ["full-duplex"] } } }, + "type" => "fw", + "encapsulation" => "1394" }, + "en3" => { "status" => "active", + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "3", + "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", + "netmask" => "255.255.0.0", + "family" => "inet" }, + "00:1c:42:00:00:00" => { "family" => "lladdr" }, + "fe80::21c:42ff:fe00:0" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, + "mtu" => "1500", + "media" => { "supported" => { "autoselect" => { "options" => [] } }, + "selected" => { "autoselect" => { "options" => [] } } }, + "type" => "en", + "encapsulation" => "Ethernet" } } }, "fqdn" => "latte.local", "ohai_time" => 1249065590.90391, "domain" => "local", @@ -182,7 +182,7 @@ describe Chef::Node::Attribute do expect { Chef::Node::Attribute.new({}, {}, {}, {}) }.not_to raise_error end - [ :normal, :default, :override, :automatic ].each do |accessor| + %i{normal default override automatic}.each do |accessor| it "should set #{accessor}" do na = Chef::Node::Attribute.new({ normal: true }, { default: true }, { override: true }, { automatic: true }) expect(na.send(accessor)).to eq({ accessor.to_s => true }) @@ -546,7 +546,7 @@ describe Chef::Node::Attribute do expect(@attributes["music"]["this"]).not_to have_key("must") end - [:include?, :key?, :member?].each do |method| + %i{include? key? member?}.each do |method| it "should alias the method #{method} to itself" do expect(@attributes).to respond_to(method) end @@ -572,8 +572,8 @@ describe Chef::Node::Attribute do before(:each) do @attributes = Chef::Node::Attribute.new( { - "one" => { "two" => "three" }, - "hut" => { "two" => "three" }, + "one" => { "two" => "three" }, + "hut" => { "two" => "three" }, "place" => {}, }, { @@ -589,7 +589,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key" do - collect = Array.new + collect = [] @attributes.each_key do |k| collect << k end @@ -602,7 +602,7 @@ describe Chef::Node::Attribute do end it "should yield lower if we go deeper" do - collect = Array.new + collect = [] @attributes["one"].each_key do |k| collect << k end @@ -621,11 +621,11 @@ describe Chef::Node::Attribute do before(:each) do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -637,7 +637,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key and value, post merge rules" do - collect = Hash.new + collect = {} @attributes.each do |k, v| collect[k] = v end @@ -659,11 +659,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -679,7 +679,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key, post merge rules" do - collect = Array.new + collect = [] @attributes.each_key do |k| collect << k end @@ -695,11 +695,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -715,7 +715,7 @@ describe Chef::Node::Attribute do end it "should yield each top level key and value pair, post merge rules" do - collect = Hash.new + collect = {} @attributes.each_pair do |k, v| collect[k] = v end @@ -731,11 +731,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -751,7 +751,7 @@ describe Chef::Node::Attribute do end it "should yield each value, post merge rules" do - collect = Array.new + collect = [] @attributes.each_value do |v| collect << v end @@ -762,7 +762,7 @@ describe Chef::Node::Attribute do end it "should yield four elements" do - collect = Array.new + collect = [] @attributes.each_value do |v| collect << v end @@ -775,11 +775,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -809,11 +809,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -866,11 +866,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -911,11 +911,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -952,11 +952,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -988,11 +988,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { @@ -1038,11 +1038,11 @@ describe Chef::Node::Attribute do before do @attributes = Chef::Node::Attribute.new( { - "one" => "two", - "hut" => "three", + "one" => "two", + "hut" => "three", }, { - "one" => "four", + "one" => "four", "snakes" => "on a plane", }, { diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 273c3d2704..a6a5c507ce 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -145,25 +145,25 @@ describe Chef::Node::ImmutableMash do end end - [ - :[]=, - :clear, - :default=, - :default_proc=, - :delete, - :delete_if, - :keep_if, - :merge!, - :update, - :reject!, - :replace, - :select!, - :shift, - :write, - :write!, - :unlink, - :unlink!, - ].each do |mutator| + %i{ + []= + clear + default= + default_proc= + delete + delete_if + keep_if + merge! + update + reject! + replace + select! + shift + write + write! + unlink + unlink! + }.each do |mutator| it "doesn't allow mutation via `#{mutator}'" do expect { @immutable_mash.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end @@ -190,37 +190,37 @@ describe Chef::Node::ImmutableArray do # with ImmutableMash, above ### - [ - :<<, - :[]=, - :clear, - :collect!, - :compact!, - :default=, - :default_proc=, - :delete, - :delete_at, - :delete_if, - :fill, - :flatten!, - :insert, - :keep_if, - :map!, - :merge!, - :pop, - :push, - :update, - :reject!, - :reverse!, - :replace, - :select!, - :shift, - :slice!, - :sort!, - :sort_by!, - :uniq!, - :unshift, - ].each do |mutator| + %i{ + << + []= + clear + collect! + compact! + default= + default_proc= + delete + delete_at + delete_if + fill + flatten! + insert + keep_if + map! + merge! + pop + push + update + reject! + reverse! + replace + select! + shift + slice! + sort! + sort_by! + uniq! + unshift + }.each do |mutator| it "does not allow mutation via `#{mutator}" do expect { @immutable_array.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 0901fa2682..15824c212c 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -21,7 +21,7 @@ require "ostruct" describe Chef::Node do - let(:node) { Chef::Node.new() } + let(:node) { Chef::Node.new } let(:platform_introspector) { node } it_behaves_like "a platform introspector" @@ -103,7 +103,7 @@ describe Chef::Node do end it "should always have a string for name" do - expect { node.name(Hash.new) }.to raise_error(ArgumentError) + expect { node.name({}) }.to raise_error(ArgumentError) end it "cannot be blank" do @@ -126,7 +126,7 @@ describe Chef::Node do end it "should disallow non-strings" do - expect { node.chef_environment(Hash.new) }.to raise_error(ArgumentError) + expect { node.chef_environment({}) }.to raise_error(ArgumentError) expect { node.chef_environment(42) }.to raise_error(ArgumentError) end @@ -162,7 +162,7 @@ describe Chef::Node do end it "disallows non-strings" do - expect { node.policy_name(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { node.policy_name({}) }.to raise_error(Chef::Exceptions::ValidationFailed) expect { node.policy_name(42) }.to raise_error(Chef::Exceptions::ValidationFailed) end @@ -198,7 +198,7 @@ describe Chef::Node do end it "disallows non-strings" do - expect { node.policy_group(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { node.policy_group({}) }.to raise_error(Chef::Exceptions::ValidationFailed) expect { node.policy_group(42) }.to raise_error(Chef::Exceptions::ValidationFailed) end @@ -769,7 +769,7 @@ describe Chef::Node do it "caches both strings and symbols correctly" do node.force_default[:solr][:version] = "4.10.2" - node.force_default[:solr][:data_dir] = "/opt/solr-#{node['solr'][:version]}/example/solr" + node.force_default[:solr][:data_dir] = "/opt/solr-#{node["solr"][:version]}/example/solr" node.force_default[:solr][:xms] = "512M" expect(node[:solr][:xms]).to eql("512M") expect(node["solr"][:xms]).to eql("512M") @@ -778,8 +778,8 @@ describe Chef::Node do it "method interpolation syntax also works" do Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["passenger"]["version"] = "4.0.57" - node.default["passenger"]["root_path"] = "passenger-#{node['passenger']['version']}" - node.default["passenger"]["root_path_2"] = "passenger-#{node[:passenger]['version']}" + node.default["passenger"]["root_path"] = "passenger-#{node["passenger"]["version"]}" + node.default["passenger"]["root_path_2"] = "passenger-#{node[:passenger]["version"]}" expect(node["passenger"]["root_path_2"]).to eql("passenger-4.0.57") expect(node[:passenger]["root_path_2"]).to eql("passenger-4.0.57") end @@ -793,7 +793,7 @@ describe Chef::Node do it "should allow you to iterate over attributes with each_attribute" do node.default["sunshine"] = "is bright" node.default["canada"] = "is a nice place" - seen_attributes = Hash.new + seen_attributes = {} node.each_attribute do |a, v| seen_attributes[a] = v end @@ -1196,7 +1196,7 @@ describe Chef::Node do expect(node.name).to eql("test.example.com-short") expect(node["sunshine"]).to eql("in") expect(node["something"]).to eql("else") - expect(node.run_list).to eq(["operations-master", "operations-monitoring"]) + expect(node.run_list).to eq(%w{operations-master operations-monitoring}) end it "should raise an exception if the file cannot be found or read" do @@ -1215,7 +1215,7 @@ describe Chef::Node do node.run_list << "role[leninist]" node.run_list << "recipe[stalinist]" - @example = Chef::Node.new() + @example = Chef::Node.new @example.name("newname") @example.chef_environment("prod") @example.default_attrs = { "alpha" => { "bravo" => "charlie", "delta" => "echo" } } @@ -1476,7 +1476,7 @@ describe Chef::Node do node.default = { "filesystem" => { - "/dev/disk0s2" => { "size" => "10mb" }, + "/dev/disk0s2" => { "size" => "10mb" }, "map - autohome" => { "size" => "10mb" }, }, "network" => { @@ -1549,7 +1549,7 @@ describe Chef::Node do node.default = { "filesystem" => { - "/dev/disk0s2" => { "size" => "10mb" }, + "/dev/disk0s2" => { "size" => "10mb" }, "map - autohome" => { "size" => "10mb" }, }, } @@ -1576,7 +1576,7 @@ describe Chef::Node do node.default = { "filesystem" => { - "/dev/disk0s2" => { "size" => "10mb" }, + "/dev/disk0s2" => { "size" => "10mb" }, "map - autohome" => { "size" => "10mb" }, }, "network" => { @@ -1613,7 +1613,7 @@ describe Chef::Node do node.default = { "filesystem" => { - "/dev/disk0s2" => { "size" => "10mb" }, + "/dev/disk0s2" => { "size" => "10mb" }, "map - autohome" => { "size" => "10mb" }, }, } @@ -1624,7 +1624,7 @@ describe Chef::Node do selected_data = { "default" => { "filesystem" => { - "/dev/disk0s2" => { "size" => "10mb" }, + "/dev/disk0s2" => { "size" => "10mb" }, "map - autohome" => { "size" => "10mb" }, }, }, diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb index 79a29b1fff..b291b7cb86 100644 --- a/spec/unit/org_spec.rb +++ b/spec/unit/org_spec.rb @@ -52,7 +52,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it anything but a string" do - expect { org.name Hash.new }.to raise_error(ArgumentError) + expect { org.name({}) }.to raise_error(ArgumentError) end end @@ -63,7 +63,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it anything but a string" do - expect { org.name Hash.new }.to raise_error(ArgumentError) + expect { org.name({}) }.to raise_error(ArgumentError) end end @@ -74,7 +74,7 @@ describe Chef::Org do end it "raises an ArgumentError if you feed it something lame" do - expect { org.private_key Hash.new }.to raise_error(ArgumentError) + expect { org.private_key({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index f22e2a74b3..d08a9f5b33 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -403,9 +403,9 @@ describe Chef::PolicyBuilder::Policyfile do before do allow(policy_builder).to receive(:run_list) - .and_return(run_list) + .and_return(run_list) allow(policy_builder).to receive(:cookbook_lock_for) - .and_return(version_hash) + .and_return(version_hash) end it "sends the run_list_expanded event" do diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb index be19dd7ec2..a6428e8617 100644 --- a/spec/unit/property/state_spec.rb +++ b/spec/unit/property/state_spec.rb @@ -28,7 +28,8 @@ describe "Chef::Resource#identity and #state" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 - "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" + + "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}" end def self.with_property(*properties, &block) @@ -254,31 +255,31 @@ describe "Chef::Resource#identity and #state" do end with_property ":x, identity: true, default: 'xxx'", - ":y, identity: true, default: 'yyy'", - ":z, identity: true, default: 'zzz'" do - it "identity_property raises an error if multiple identity values are defined" do - expect { resource_class.identity_property }.to raise_error Chef::Exceptions::MultipleIdentityError - end - it "identity_attr raises an error if multiple identity values are defined" do - expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError - end - it "identity returns all identity values in a hash if multiple are defined" do - resource.x "foo" - resource.y "bar" - resource.z "baz" - expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz") - end - it "identity returns all values whether any value is set or not" do - expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz") - end - it "identity_properties wipes out any other identity attributes if multiple are defined" do - resource_class.identity_properties :y - resource.x "foo" - resource.y "bar" - resource.z "baz" - expect(resource.identity).to eq "bar" + ":y, identity: true, default: 'yyy'", + ":z, identity: true, default: 'zzz'" do + it "identity_property raises an error if multiple identity values are defined" do + expect { resource_class.identity_property }.to raise_error Chef::Exceptions::MultipleIdentityError + end + it "identity_attr raises an error if multiple identity values are defined" do + expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError + end + it "identity returns all identity values in a hash if multiple are defined" do + resource.x "foo" + resource.y "bar" + resource.z "baz" + expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz") + end + it "identity returns all values whether any value is set or not" do + expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz") + end + it "identity_properties wipes out any other identity attributes if multiple are defined" do + resource_class.identity_properties :y + resource.x "foo" + resource.y "bar" + resource.z "baz" + expect(resource.identity).to eq "bar" + end end - end with_property ":x, identity: true, name_property: true" do it "identity when x is not defined returns the value of x" do diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index b05d8c4e17..dab2be8000 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -55,7 +55,8 @@ describe "Chef::Resource.property validation" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 - "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" + + "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}" end def self.with_property(*properties, &block) @@ -231,19 +232,19 @@ describe "Chef::Resource.property validation" do [ :b ] validation_test ":a, is: :b", - [ :a, :b ], + %i{a b}, [ :c ] validation_test ":a, is: [ :b, :c ]", - [ :a, :b, :c ], + %i{a b c}, [ :d ] validation_test "[ :a, :b ], is: :c", - [ :a, :b, :c ], + %i{a b c}, [ :d ] validation_test "[ :a, :b ], is: [ :c, :d ]", - [ :a, :b, :c, :d ], + %i{a b c d}, [ :e ] validation_test "nil", @@ -279,12 +280,12 @@ describe "Chef::Resource.property validation" do [ :b ] validation_test "is: [ :a, :b ]", - [ :a, :b ], - [ [ :a, :b ] ] + %i{a b}, + [ %i{a b} ] validation_test "is: [ [ :a, :b ] ]", - [ [ :a, :b ] ], - [ :a, :b ] + [ %i{a b} ], + %i{a b} # Regex validation_test "is: /abc/", @@ -352,13 +353,13 @@ describe "Chef::Resource.property validation" do :nil_is_valid validation_test "equal_to: [ :a, :b ]", - [ :a, :b ], - [ [ :a, :b ] ], + %i{a b}, + [ %i{a b} ], :nil_is_valid validation_test "equal_to: [ [ :a, :b ] ]", - [ [ :a, :b ] ], - [ :a, :b ], + [ %i{a b} ], + %i{a b}, :nil_is_valid validation_test "equal_to: nil", diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 793bb3248f..fe339713dd 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -51,7 +51,8 @@ describe "Chef::Resource.property" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 - "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" + + "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}" end def self.with_property(*properties, &block) @@ -1051,19 +1052,19 @@ describe "Chef::Resource.property" do context "default ordering deprecation warnings" do it "emits an error for property :x, default: 10, #{name}: true" do expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error ArgumentError, - /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/ + %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)} end it "emits an error for property :x, default: nil, #{name}: true" do expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error ArgumentError, - /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/ + %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)} end it "emits an error for property :x, #{name}: true, default: 10" do expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error ArgumentError, - /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/ + %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)} end it "emits an error for property :x, #{name}: true, default: nil" do expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error ArgumentError, - /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/ + %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)} end end end @@ -1085,13 +1086,13 @@ describe "Chef::Resource.property" do expect do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - property_type(is: [:a, :b], default: :c) + property_type(is: %i{a b}, default: :c) end end.to raise_error(Chef::Exceptions::ValidationFailed) expect do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - property_type(is: [:a, :b], default: :b) + property_type(is: %i{a b}, default: :b) end end.not_to raise_error end @@ -1100,8 +1101,8 @@ describe "Chef::Resource.property" do before :all do module ::PropertySpecPropertyTypes include Chef::Mixin::Properties - ABType = property_type(is: [:a, :b]) - CDType = property_type(is: [:c, :d]) + ABType = property_type(is: %i{a b}) + CDType = property_type(is: %i{c d}) end end diff --git a/spec/unit/provider/apt_update_spec.rb b/spec/unit/provider/apt_update_spec.rb index 5cd327b66b..ed91131aff 100644 --- a/spec/unit/provider/apt_update_spec.rb +++ b/spec/unit/provider/apt_update_spec.rb @@ -47,7 +47,7 @@ describe Chef::Provider::AptUpdate do before do FileUtils.rmdir config_dir expect(File.exist?(config_dir)).to be false - allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) end it "should create the directory" do @@ -66,7 +66,7 @@ describe Chef::Provider::AptUpdate do describe "#action_update" do it "should update the apt cache" do provider.load_current_resource - expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) provider.run_action(:update) expect(new_resource).to be_updated_by_last_action end @@ -81,14 +81,14 @@ describe Chef::Provider::AptUpdate do it "should run if the time stamp is old" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 86_500) - expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) provider.run_action(:periodic) expect(new_resource).to be_updated_by_last_action end it "should not run if the time stamp is new" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now) - expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) provider.run_action(:periodic) expect(new_resource).to_not be_updated_by_last_action end @@ -100,14 +100,14 @@ describe Chef::Provider::AptUpdate do it "should run if the time stamp is old" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 500) - expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) provider.run_action(:periodic) expect(new_resource).to be_updated_by_last_action end it "should not run if the time stamp is new" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 300) - expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything()) + expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything) provider.run_action(:periodic) expect(new_resource).to_not be_updated_by_last_action end diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index 2377fe7dbc..4cd8a140af 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -51,7 +51,7 @@ describe Chef::Provider::Cron do 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB end it "should set cron_exists" do @@ -80,7 +80,7 @@ CRONTAB 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("foo@example.com") expect(cron.shell).to eq("/bin/foosh") @@ -97,7 +97,7 @@ CRONTAB TEST=lol FLAG=1 @reboot /bin/true -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("warn@example.com") @@ -112,7 +112,7 @@ CRONTAB TEST=lol ENVIRONMENT=production @reboot /bin/true -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.time).to eq(:reboot) @@ -175,7 +175,7 @@ CRONTAB * 5 * * * /bin/true # Another comment -CRONTAB + CRONTAB end it "should not set cron_exists or cron_empty" do @@ -193,7 +193,7 @@ CRONTAB allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB) # Chef Name: foo[bar] (baz) 21 */4 * * * some_prog 1234567 -CRONTAB + CRONTAB expect do @provider.load_current_resource end.not_to raise_error @@ -211,7 +211,7 @@ CRONTAB 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB end it "should set cron_exists" do @@ -245,7 +245,7 @@ CRONTAB 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("foo@example.com") expect(cron.shell).to eq("/bin/foosh") @@ -267,7 +267,7 @@ CRONTAB TEST=lol FLAG=1 * 5 * * * /bin/true -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.mailto).to eq("warn@example.com") @@ -282,7 +282,7 @@ CRONTAB TEST=lol ENVIRONMENT=production * 5 * * * /bin/true -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(cron.minute).to eq("*") @@ -307,7 +307,7 @@ CRONTAB 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB end it "should set cron_exists" do @@ -338,7 +338,7 @@ CRONTAB 0 2 * * * /some/other/command # Chef Name: cronhole some stuff -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) expect(cron.minute).to eq("*") @@ -356,7 +356,7 @@ CRONTAB # Chef Name: cronhole some stuff #* 5 * 1 * /bin/true param1 param2 -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) expect(cron.minute).to eq("*") @@ -378,7 +378,7 @@ CRONTAB 2 * 1 * * /bin/false # Another comment -CRONTAB + CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) expect(cron.minute).to eq("*") @@ -401,7 +401,7 @@ CRONTAB @provider.current_resource = @current_resource end - [:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home].each do |property| + %i{minute hour day month weekday command mailto path shell home}.each do |property| it "should return true if #{property} doesn't match" do @new_resource.send(property, "something_else") expect(@provider.cron_different?).to eql(true) diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 82ee5a40b3..cf6ab88eb4 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -36,7 +36,8 @@ describe Chef::Provider::DscResource do it "raises a ProviderNotFound exception" do expect(provider).not_to receive(:meta_configuration) expect { provider.run_action(:run) }.to raise_error( - Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/) + Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/ + ) end end @@ -52,7 +53,8 @@ describe Chef::Provider::DscResource do it "raises an exception" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false) expect { provider.run_action(:run) }.to raise_error( - Chef::Exceptions::ProviderNotFound, /Disabled/) + Chef::Exceptions::ProviderNotFound, /Disabled/ + ) end end context "and the WMF is 5 RTM or newer" do @@ -157,7 +159,8 @@ describe Chef::Provider::DscResource do [ { "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } }, { "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } }, - ] end + ] + end it "raises MultipleDscResourcesFound" do expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::MultipleDscResourcesFound) diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index c880683a0f..a1115150e8 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -99,7 +99,7 @@ describe Chef::Provider::DscScript do it "should noop if neither code or command are provided" do allow(provider).to receive(:load_current_resource) generator = double("Chef::Util::DSC::ConfigurationGenerator") - expect(generator).to receive(:configuration_document_from_script_code).with("", anything(), anything(), anything()) + expect(generator).to receive(:configuration_document_from_script_code).with("", anything, anything, anything) allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator) provider.send(:generate_configuration_document, "tmp", nil) end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 9718a012da..11eb70e396 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -30,11 +30,11 @@ describe Chef::Provider::Execute do let(:opts) do { - timeout: 3600, - returns: 0, - log_level: :info, - default_env: false, - log_tag: new_resource.to_s, + timeout: 3600, + returns: 0, + log_level: :info, + default_env: false, + log_tag: new_resource.to_s, } end diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 4a6266b58a..9a6ae31397 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -259,7 +259,7 @@ describe Chef::Provider::Git do d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8 b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package -SHAS + SHAS @resource.revision "" expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout)) expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a") @@ -377,7 +377,7 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.9" } expect(@provider).to receive(:shell_out!).with("git --version", - log_tag: "git[web2.0 app]").and_return(version_response) + log_tag: "git[web2.0 app]").and_return(version_response) expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end @@ -388,7 +388,7 @@ SHAS version_response = double("shell_out") allow(version_response).to receive(:stdout) { "git version 1.7.10" } expect(@provider).to receive(:shell_out!).with("git --version", - log_tag: "git[web2.0 app]").and_return(version_response) + log_tag: "git[web2.0 app]").and_return(version_response) expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]") @provider.clone end @@ -489,13 +489,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -507,19 +507,19 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - user: "whois", - group: "thisis", - environment: { "HOME" => "/home/whois" }, - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }, + returns: [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - user: "whois", - group: "thisis", - environment: { "HOME" => "/home/whois" }) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + user: "whois", + group: "thisis", + environment: { "HOME" => "/home/whois" }) @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -529,13 +529,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 1 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end @@ -547,13 +547,13 @@ SHAS allow(command_response).to receive(:stdout) { "some_other_url" } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -563,13 +563,13 @@ SHAS allow(command_response).to receive(:stdout) { @resource.repository } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) unexpected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).not_to receive(:shell_out!).with(unexpected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -578,13 +578,13 @@ SHAS allow(command_response).to receive(:exitstatus) { 2 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]", - returns: [0, 1, 2]).and_return(command_response) + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]", + returns: [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\"" expect(@provider).to receive(:shell_out!).with(expected_command, - cwd: "/my/deploy/dir", - log_tag: "git[web2.0 app]") + cwd: "/my/deploy/dir", + log_tag: "git[web2.0 app]") @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end end diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 8bd6485740..910470b1b7 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -120,8 +120,8 @@ describe Chef::Provider::Group::Dscl do someprogram somethingElse:gid = ( 500 ) - EOS - ) + EOS + ) end it "should run safe_dscl with search /Groups gid" do @@ -322,7 +322,7 @@ describe "Test DSCL loading" do RecordName: com.apple.aj RecordType: dsRecTypeStandard:Groups GroupMembership: waka bar -EOF + EOF allow(@provider).to receive(:safe_dscl).with(*"read /Groups/aj".split(" ")).and_return(@output) @current_resource = @provider.load_current_resource diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index 84997a258d..79586eac71 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -155,7 +155,7 @@ describe Chef::Provider::Group::Groupadd do end end - [:add_member, :remove_member, :set_members].each do |m| + %i{add_member remove_member set_members}.each do |m| it "should raise an error when calling #{m}" do expect { provider.send(m, [ ]) }.to raise_error(Chef::Exceptions::Group, "you must override #{m} in #{provider}") end diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index bacb711d1b..d7fdfb299c 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -39,8 +39,7 @@ describe Chef::Provider::User do @pw_group = double("Struct::Group", name: "wheel", gid: 20, - mem: %w{root aj} - ) + mem: %w{root aj}) allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end @@ -85,7 +84,7 @@ describe Chef::Provider::User do end describe "when determining if the system is already in the target state" do - [ :gid, :members ].each do |property| + %i{gid members}.each do |property| it "should return true if #{property} doesn't match" do allow(@current_resource).to receive(property).and_return("looooooooooooooooooool") expect(@provider.compare_group).to be_truthy diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 6acfddbedb..8baf3e437d 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -32,7 +32,7 @@ describe Chef::Provider::Ifconfig::Aix do lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN> inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255 inet6 ::1%1/0 -IFCONFIG + IFCONFIG end before(:each) do diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 93b0008e8b..308435dea2 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -123,7 +123,7 @@ describe Chef::Provider::Ifconfig::Debian do a line source #{tempdir_path}/* another line -EOF + EOF end before do @@ -146,7 +146,7 @@ EOF a line another line source #{tempdir_path}/* -EOF + EOF end before do diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index b25c8f70ca..38561d6e49 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -44,7 +44,7 @@ describe Chef::Provider::Ifconfig do let(:net_tools_version) { StringIO.new <<~EOS } net-tools 1.60 ifconfig 1.42 (2001-04-13) -EOS + EOS before do ifconfig = double(stdout: "", exitstatus: 1) diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb index 3031ea36c3..53b56b4960 100644 --- a/spec/unit/provider/launchd_spec.rb +++ b/spec/unit/provider/launchd_spec.rb @@ -49,7 +49,7 @@ describe Chef::Provider::Launchd do \t<integer>300</integer> </dict> </plist> -XML + XML let(:test_plist_multiple_intervals) { String.new <<~XML } <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> @@ -78,7 +78,7 @@ XML \t<integer>300</integer> </dict> </plist> -XML + XML let(:test_hash) do { @@ -89,7 +89,8 @@ XML "Weekday" => 7, }, "TimeOut" => 300, - } end + } + end before(:each) do provider.load_current_resource @@ -139,7 +140,7 @@ XML it "should allow array of Hashes" do allowed = (1..2).collect do |num| { - "Hour" => 10 + num, + "Hour" => 10 + num, "Weekday" => num, } end @@ -152,11 +153,11 @@ XML it "should allow all StartCalendarInterval keys" do allowed = { - "Minute" => 1, - "Hour" => 1, - "Day" => 1, + "Minute" => 1, + "Hour" => 1, + "Day" => 1, "Weekday" => 1, - "Month" => 1, + "Month" => 1, } new_resource.program "/Library/scripts/call_mom.sh" new_resource.time_out 300 @@ -197,9 +198,11 @@ XML describe "and the file has been updated" do before(:each) do allow(provider).to receive( - :manage_plist).with(:create).and_return(true) + :manage_plist + ).with(:create).and_return(true) allow(provider).to receive( - :manage_service).with(:restart).and_return(true) + :manage_service + ).with(:restart).and_return(true) end it "should call manage_service with a :restart action" do @@ -215,9 +218,11 @@ XML describe "and the file has not been updated" do before(:each) do allow(provider).to receive( - :manage_plist).with(:create).and_return(nil) + :manage_plist + ).with(:create).and_return(nil) allow(provider).to receive( - :manage_service).with(:enable).and_return(true) + :manage_service + ).with(:enable).and_return(true) end it "should call manage_service with a :enable action" do @@ -236,9 +241,11 @@ XML before(:each) do allow(File).to receive(:exists?).and_return(true) allow(provider).to receive( - :manage_service).with(:disable).and_return(true) + :manage_service + ).with(:disable).and_return(true) allow(provider).to receive( - :manage_plist).with(:delete).and_return(true) + :manage_plist + ).with(:delete).and_return(true) end it "should call manage_service with a :disable action" do @@ -255,7 +262,8 @@ XML before(:each) do allow(File).to receive(:exists?).and_return(false) allow(provider).to receive( - :manage_plist).with(:delete).and_return(true) + :manage_plist + ).with(:delete).and_return(true) end it "works with action :delete" do diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 027b318c7e..fff2c1ffa8 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -259,7 +259,8 @@ describe Chef::Resource::Link do allow(stat).to receive(:gid).and_return(501) allow(stat).to receive(:mode).and_return(0755) allow(provider.file_class).to receive(:stat).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(stat) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(stat) provider.load_current_resource end @@ -267,7 +268,8 @@ describe Chef::Resource::Link do shared_context "delete link to directories on Windows" do before do allow(::File).to receive(:directory?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(true) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(true) end it "invokes Dir.delete method to delete the link" do @@ -280,7 +282,8 @@ describe Chef::Resource::Link do shared_context "delete link to directories on Linux" do before do allow(::File).to receive(:directory?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(true) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(true) end it "invokes File.delete method to delete the link" do @@ -293,7 +296,8 @@ describe Chef::Resource::Link do shared_context "delete link to files" do before do allow(::File).to receive(:directory?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(false) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(false) end it "invokes File.delete method to delete the link" do @@ -306,9 +310,11 @@ describe Chef::Resource::Link do shared_context "soft links prerequisites" do before(:each) do allow(provider.file_class).to receive(:symlink?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(true) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(true) allow(provider.file_class).to receive(:readlink).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile") + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return("#{CHEF_SPEC_DATA}/fofile") end end @@ -327,15 +333,19 @@ describe Chef::Resource::Link do allow(stat).to receive(:mode).and_return(0644) allow(provider.file_class).to receive(:symlink?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(false) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(false) allow(File).to receive(:exists?).with( - "#{CHEF_SPEC_DATA}/fofile-link").and_return(true) + "#{CHEF_SPEC_DATA}/fofile-link" + ).and_return(true) allow(File).to receive(:exists?).with( - "#{CHEF_SPEC_DATA}/fofile").and_return(true) + "#{CHEF_SPEC_DATA}/fofile" + ).and_return(true) allow(provider.file_class).to receive(:stat).with( - "#{CHEF_SPEC_DATA}/fofile").and_return(stat) + "#{CHEF_SPEC_DATA}/fofile" + ).and_return(stat) end end @@ -346,7 +356,8 @@ describe Chef::Resource::Link do before(:each) do allow(Chef::Resource::Link).to receive(:new).with( - provider.new_resource.name).and_return(resource_link) + provider.new_resource.name + ).and_return(resource_link) allow(resource_link).to receive(:verify_links_supported!) allow(Chef::Platform).to receive(:windows?).and_return(true) end diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 69dd8a3b25..8af22368ea 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -26,29 +26,29 @@ describe Chef::Provider::Mount::Aix do node mounted mounted over vfs date options -------- --------------- --------------- ------ ------------ --------------- /dev/sdz1 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 -MOUNT + MOUNT @unmounted_output = <<~UNMOUNTED node mounted mounted over vfs date options -------- --------------- --------------- ------ ------------ --------------- /dev/sdz2 / jfs2 Jul 17 13:22 rw,log=/dev/hd8 -UNMOUNTED + UNMOUNTED @conflict_mounted_output = <<~MOUNT node mounted mounted over vfs date options -------- --------------- --------------- ------ ------------ --------------- /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8 -MOUNT + MOUNT @enabled_output = <<~ENABLED #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct /tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no -ENABLED + ENABLED @test_wrong_output = <<~WRONG #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct /tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no -WRONG + WRONG end before(:each) do @@ -256,7 +256,7 @@ WRONG vfs = jfs2 mount = true options = rw -ETCFILESYSTEMS + ETCFILESYSTEMS filesystems = StringIO.new allow(::File).to receive(:open).with("/etc/filesystems", "w").and_yield(filesystems) diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 2353d992d0..5e1ffbf208 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -67,23 +67,23 @@ describe Chef::Provider::Mount::Mount do describe "when dealing with network mounts" do { "nfs" => "nfsserver:/vol/path", "cifs" => "//cifsserver/share" }.each do |type, fs_spec| - it "should detect network fs_spec (#{type})" do - @new_resource.device fs_spec - expect(@provider.network_device?).to be_truthy + it "should detect network fs_spec (#{type})" do + @new_resource.device fs_spec + expect(@provider.network_device?).to be_truthy + end + + it "should ignore trailing slash and set mounted to true for network mount (#{type})" do + @new_resource.device fs_spec + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) + @provider.load_current_resource + expect(@provider.current_resource.mounted).to be_truthy + end end - - it "should ignore trailing slash and set mounted to true for network mount (#{type})" do - @new_resource.device fs_spec - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n")) - @provider.load_current_resource - expect(@provider.current_resource.mounted).to be_truthy - end - end end it "should raise an error if the mount device does not exist" do allow(::File).to receive(:exists?).with("/dev/sdz1").and_return false - expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should not call mountable? with load_current_resource - CHEF-1565" do @@ -100,36 +100,36 @@ describe Chef::Provider::Mount::Mount do @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" expect(@provider).to receive(:shell_out_compacted).with("/sbin/findfs", "UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) expect(::File).to receive(:exists?).with("").and_return(false) - expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should raise an error if the mount point does not exist" do allow(::File).to receive(:exists?).with("/tmp/foo").and_return false - expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end %w{tmpfs fuse cgroup vboxsf zfs}.each do |fstype| it "does not expect the device to exist for #{fstype}" do @new_resource.fstype(fstype) @new_resource.device("whatever") - expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error + expect { @provider.load_current_resource; @provider.mountable? }.not_to raise_error end end it "does not expect the device to exist if it's none" do @new_resource.device("none") - expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error + expect { @provider.load_current_resource; @provider.mountable? }.not_to raise_error end it "should set mounted true if the mount point is found in the mounts list" do allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foo type ext3 (rw)\n")) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end it "should set mounted false if another mount point beginning with the same path is found in the mounts list" do allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n")) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_falsey end @@ -141,7 +141,7 @@ describe Chef::Provider::Mount::Mount do allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{target} on /tmp/foo type ext3 (rw)\n")) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end @@ -155,7 +155,7 @@ describe Chef::Provider::Mount::Mount do allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target) allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{absolute_target} on /tmp/foo type ext3 (rw)\n")) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end @@ -164,7 +164,7 @@ describe Chef::Provider::Mount::Mount do mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n" allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_truthy end @@ -173,13 +173,13 @@ describe Chef::Provider::Mount::Mount do mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n" allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount)) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_falsey end it "mounted should be false if the mount point is not found in the mounts list" do allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdy1 on /tmp/foo type ext3 (rw)\n")) - @provider.load_current_resource() + @provider.load_current_resource expect(@provider.current_resource.mounted).to be_falsey end @@ -297,14 +297,14 @@ describe Chef::Provider::Mount::Mount do describe "mount_fs" do it "should mount the filesystem if it is not mounted" do expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", "ext3", "-o", "defaults", "/dev/sdz1", "/tmp/foo") - @provider.mount_fs() + @provider.mount_fs end it "should mount the filesystem with options if options were passed" do options = "rw,noexec,noauto" @new_resource.options(%w{rw noexec noauto}) expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", "ext3", "-o", "rw,noexec,noauto", "/dev/sdz1", "/tmp/foo") - @provider.mount_fs() + @provider.mount_fs end it "should mount the filesystem specified by uuid", :not_supported_on_solaris do @@ -315,13 +315,13 @@ describe Chef::Provider::Mount::Mount do @stdout_mock = double("stdout mock") allow(@stdout_mock).to receive(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}") expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", @new_resource.fstype, "-o", "defaults", "-U", @new_resource.device, @new_resource.mount_point).and_return(@stdout_mock) - @provider.mount_fs() + @provider.mount_fs end it "should not mount the filesystem if it is mounted" do allow(@current_resource).to receive(:mounted).and_return(true) expect(@provider).not_to receive(:shell_out!) - @provider.mount_fs() + @provider.mount_fs end end @@ -330,13 +330,13 @@ describe Chef::Provider::Mount::Mount do it "should umount the filesystem if it is mounted" do @current_resource.mounted(true) expect(@provider).to receive(:shell_out!).with("umount", "/tmp/foo") - @provider.umount_fs() + @provider.umount_fs end it "should not umount the filesystem if it is not mounted" do @current_resource.mounted(false) expect(@provider).not_to receive(:shell_out!) - @provider.umount_fs() + @provider.umount_fs end end @@ -363,7 +363,7 @@ describe Chef::Provider::Mount::Mount do expect(@provider).to receive(:umount_fs) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:mount_fs) - @provider.remount_fs() + @provider.remount_fs end it "should not try to remount at all if mounted is false" do @@ -371,7 +371,7 @@ describe Chef::Provider::Mount::Mount do expect(@provider).not_to receive(:shell_out!) expect(@provider).not_to receive(:umount_fs) expect(@provider).not_to receive(:mount_fs) - @provider.remount_fs() + @provider.remount_fs end end diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 4e73bc77b5..006eb690cb 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do describe "#define_resource_requirements" do before do # we're not testing the actual actions so stub them all out - [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each { |m| allow(provider).to receive(m) } + %i{mount_fs umount_fs remount_fs enable_fs disable_fs}.each { |m| allow(provider).to receive(m) } end it "run_action(:mount) should raise an error if the device does not exist" do @@ -350,7 +350,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true) expect(File).to receive(:readlink).with(device).at_least(:once).and_return(target) - provider.load_current_resource() + provider.load_current_resource end it "should set mounted true if the symlink target of the device is found in the mounts list" do @@ -387,7 +387,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true) expect(File).to receive(:readlink).with(device).at_least(:once).and_return(target) - provider.load_current_resource() + provider.load_current_resource end it "should set mounted true if the symlink target of the device is found in the mounts list" do @@ -411,7 +411,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do EOF end it "should set mounted true" do - provider.load_current_resource() + provider.load_current_resource expect(provider.current_resource.mounted).to be_truthy end end @@ -424,7 +424,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do EOF end it "should set mounted false" do - provider.load_current_resource() + provider.load_current_resource expect(provider.current_resource.mounted).to be_falsey end end @@ -436,7 +436,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do EOF end it "should set mounted false" do - provider.load_current_resource() + provider.load_current_resource expect(provider.current_resource.mounted).to be_falsey end end @@ -448,7 +448,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do EOF end it "should set mounted false" do - provider.load_current_resource() + provider.load_current_resource expect(provider.current_resource.mounted).to be_falsey end end @@ -539,28 +539,28 @@ describe Chef::Provider::Mount::Solaris, :unix_only do describe "mount_fs" do it "should mount the filesystem" do expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, device, mountpoint) - provider.mount_fs() + provider.mount_fs end it "should mount the filesystem with options if options were passed" do options = "logging,noatime,largefiles,nosuid,rw,quota" new_resource.options(options.split(/,/)) expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, "-o", options, device, mountpoint) - provider.mount_fs() + provider.mount_fs end it "should delete the 'noauto' magic option" do options = "rw,noauto" new_resource.options(%w{rw noauto}) expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, "-o", "rw", device, mountpoint) - provider.mount_fs() + provider.mount_fs end end describe "umount_fs" do it "should umount the filesystem if it is mounted" do expect(provider).to receive(:shell_out_compacted!).with("umount", mountpoint) - provider.umount_fs() + provider.umount_fs end end diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index 518523dca2..11f11e3373 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -43,7 +43,7 @@ describe Chef::Provider::Ohai do } allow(mock_ohai).to receive(:all_plugins).and_return(true) allow(mock_ohai).to receive(:data).and_return(mock_ohai[:data], - mock_ohai[:data2]) + mock_ohai[:data2]) allow(Ohai::System).to receive(:new).and_return(mock_ohai) allow(Chef::Platform).to receive(:find_platform_and_version).and_return({ "platform" => @platform, "platform_version" => @platform_version }) diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index 8f99ad6817..017041bc60 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -132,7 +132,7 @@ describe Chef::Provider::OsxProfile do provider.load_current_resource expect( provider.instance_variable_get(:@new_profile_identifier) - ).to eql(test_profile["PayloadIdentifier"]) + ).to eql(test_profile["PayloadIdentifier"]) end it "should install when not installed" do @@ -167,7 +167,7 @@ describe Chef::Provider::OsxProfile do provider.load_current_resource allow(provider).to receive(:write_profile_to_disk).and_return(profile_path) expect(provider).to receive(:shell_out_compacted).with("/usr/bin/profiles", "-I", "-F", profile_path).and_return(shell_out_success) - provider.action_install() + provider.action_install end it "should fail if there is no identifier inside the profile" do @@ -228,16 +228,14 @@ describe Chef::Provider::OsxProfile do new_resource.profile_name "com.testprofile.screensaver" new_resource.action(:remove) provider.load_current_resource - expect(provider.instance_variable_get(:@new_profile_identifier) - ).to eql(new_resource.profile_name) + expect(provider.instance_variable_get(:@new_profile_identifier)).to eql(new_resource.profile_name) end it "should use specified identifier" do new_resource.identifier "com.testprofile.screensaver" new_resource.action(:remove) provider.load_current_resource - expect(provider.instance_variable_get(:@new_profile_identifier) - ).to eql(new_resource.identifier) + expect(provider.instance_variable_get(:@new_profile_identifier)).to eql(new_resource.identifier) end it "should work with spaces in the identifier" do @@ -251,7 +249,7 @@ describe Chef::Provider::OsxProfile do new_resource.action(:remove) provider.load_current_resource expect(provider).to receive(:shell_out_compacted).with("/usr/bin/profiles", "-R", "-p", new_resource.identifier).and_return(shell_out_success) - provider.action_remove() + provider.action_remove end end end diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index 24bd642317..17dbf000f2 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -489,8 +489,8 @@ describe Chef::Provider::Package::Apt do allow(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "showhold", timeout: 900 ).and_return(instance_double( - Mixlib::ShellOut, stdout: "irssi") - ) + Mixlib::ShellOut, stdout: "irssi" + )) expect(logger).to receive(:trace).with("#{@provider.new_resource} is already locked") @provider.action_lock @@ -510,8 +510,8 @@ describe Chef::Provider::Package::Apt do allow(@provider).to receive(:shell_out_compacted!).with( "apt-mark", "showhold", timeout: 900 ).and_return(instance_double( - Mixlib::ShellOut, stdout: "") - ) + Mixlib::ShellOut, stdout: "" + )) expect(logger).to receive(:trace).with("#{@provider.new_resource} is already unlocked") @provider.action_unlock @@ -564,7 +564,7 @@ describe Chef::Provider::Package::Apt do env: { "DEBIAN_FRONTEND" => "noninteractive" }, timeout: @timeout ) - @provider.install_package(["libmysqlclient15-dev", "irssi"], ["not_a_real_version", "0.8.12-7"]) + @provider.install_package(%w{libmysqlclient15-dev irssi}, ["not_a_real_version", "0.8.12-7"]) end end diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb index 7606092762..b428ec0a72 100644 --- a/spec/unit/provider/package/bff_spec.rb +++ b/spec/unit/provider/package/bff_spec.rb @@ -81,7 +81,7 @@ describe Chef::Provider::Package::Bff do status = double("Status", stdout: info, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status) expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status) - expect(logger).to receive(:warn).once.with(%r{bff package by product name}) + expect(logger).to receive(:warn).once.with(/bff package by product name/) @provider.load_current_resource expect(@provider.current_resource.package_name).to eq("samba.base") diff --git a/spec/unit/provider/package/cab_spec.rb b/spec/unit/provider/package/cab_spec.rb index 2ed40566f4..0ffbcd4a51 100644 --- a/spec/unit/provider/package/cab_spec.rb +++ b/spec/unit/provider/package/cab_spec.rb @@ -260,7 +260,7 @@ describe Chef::Provider::Package::Cab do end before do - new_resource.source = "#{ENV['TEMP']}/test6.1-kb2664825-v3-x64.cab" + new_resource.source = "#{ENV["TEMP"]}/test6.1-kb2664825-v3-x64.cab" installed_package_list_obj = double(stdout: installed_package_list_stdout) allow(provider).to receive(:dism_command).with("/Get-Packages").and_return(installed_package_list_obj) end diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index ac800212d8..9b0cef4ef3 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -262,8 +262,8 @@ describe Chef::Provider::Package::Chocolatey do end it "should do multipackage installs when given two packages without constraints" do - allow_remote_list(["git", "munin-node"]) - new_resource.package_name(["git", "munin-node"]) + allow_remote_list(%w{git munin-node}) + new_resource.package_name(%w{git munin-node}) provider.load_current_resource expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double) provider.run_action(:install) @@ -298,8 +298,8 @@ describe Chef::Provider::Package::Chocolatey do end it "installing multiple packages with a package that does not exist throws an error" do - allow_remote_list(["git", "package-does-not-exist"]) - new_resource.package_name(["git", "package-does-not-exist"]) + allow_remote_list(%w{git package-does-not-exist}) + new_resource.package_name(%w{git package-does-not-exist}) provider.load_current_resource expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end @@ -405,8 +405,8 @@ describe Chef::Provider::Package::Chocolatey do end it "upgrading multiple packages with a package that does not exist throws an error" do - allow_remote_list(["git", "package-does-not-exist"]) - new_resource.package_name(["git", "package-does-not-exist"]) + allow_remote_list(%w{git package-does-not-exist}) + new_resource.package_name(%w{git package-does-not-exist}) provider.load_current_resource expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package) end @@ -432,8 +432,8 @@ describe Chef::Provider::Package::Chocolatey do end it "does nothing when all the packages are already removed" do - allow_remote_list(["git", "package-does-not-exist"]) - new_resource.package_name(["git", "package-does-not-exist"]) + allow_remote_list(%w{git package-does-not-exist}) + new_resource.package_name(%w{git package-does-not-exist}) provider.load_current_resource expect(provider).not_to receive(:remove_package) provider.run_action(:remove) diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb index 29a8bfef44..07157937cb 100644 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ b/spec/unit/provider/package/freebsd/pkg_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new("zsh") + @new_resource = Chef::Resource::Package.new("zsh") @current_resource = Chef::Resource::Package.new("zsh") @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index 70e1c3fe32..fc249729d1 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -40,7 +40,7 @@ describe Chef::Provider::Package::Ips do installed on the system. Try specifying -r to query remotely: crypto/gnupg -PKG_STATUS + PKG_STATUS OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 1) end @@ -56,7 +56,7 @@ PKG_STATUS Packaging Date: April 1, 2012 05:55:52 PM Size: 2.57 MB FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z -PKG_STATUS + PKG_STATUS stdin = StringIO.new stderr = "" OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 0) @@ -106,7 +106,7 @@ PKG_STATUS Packaging Date: October 19, 2011 09:14:50 AM Size: 8.07 MB FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z -INSTALLED + INSTALLED expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output) @provider.load_current_resource @@ -151,7 +151,7 @@ INSTALLED Packaging Date: April 1, 2012 05:55:52 PM Size: 2.57 MB FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z -PKG_STATUS + PKG_STATUS expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote) @provider.load_current_resource @@ -175,7 +175,7 @@ PKG_STATUS Packaging Date: October 19, 2011 09:14:50 AM Size: 8.07 MB FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z -INSTALLED + INSTALLED remote = remote_output remote.stdout = <<~REMOTE Name: crypto/gnupg @@ -191,7 +191,7 @@ INSTALLED Packaging Date: October 19, 2011 09:14:50 AM Size: 8.07 MB FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z -REMOTE + REMOTE expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local) expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote) diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index 8b75e40d72..e2769fe71d 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -73,7 +73,7 @@ describe Chef::Provider::Package::Macports do stdout = <<~EOF The following ports are currently installed: openssl @0.9.8k_0 (active) -EOF + EOF status = double(stdout: stdout, exitstatus: 0) expect(@provider).to receive(:shell_out_compacted).and_return(status) diff --git a/spec/unit/provider/package/msu_spec.rb b/spec/unit/provider/package/msu_spec.rb index b2f0b22963..905d48649f 100644 --- a/spec/unit/provider/package/msu_spec.rb +++ b/spec/unit/provider/package/msu_spec.rb @@ -243,7 +243,7 @@ describe Chef::Provider::Package::Msu, :windows_only do describe "#extract_msu_contents" do it "extracts the msu contents by using mixlib shellout" do - expect(provider).to receive(:shell_out!).with("#{ENV['SYSTEMROOT']}\\system32\\expand.exe -f:* msu_file destination") + expect(provider).to receive(:shell_out!).with("#{ENV["SYSTEMROOT"]}\\system32\\expand.exe -f:* msu_file destination") provider.extract_msu_contents("msu_file", "destination") end end diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index 01d6571f65..dee49534c3 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -45,15 +45,16 @@ describe Chef::Provider::Package::Openbsd do context "when not already installed" do before do - allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", stdout: "")) + allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything).and_return(instance_double("shellout", stdout: "")) end context "when there is a single candidate" do context "when source is not provided" do it "should run the installation command" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", stdout: "#{name}-#{version}\n")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything).and_return( + instance_double("shellout", stdout: "#{name}-#{version}\n") + ) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } @@ -69,8 +70,9 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should raise an exception" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything).and_return( + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n") + ) expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/) end end @@ -83,9 +85,10 @@ describe Chef::Provider::Package::Openbsd do context "if no version is specified" do it "should run the installation command" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", stdout: "")) - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return( - instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything).and_return(instance_double("shellout", stdout: "")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything).and_return( + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n") + ) expect(provider).to receive(:shell_out_compacted!).with( "pkg_add", "-r", "#{name}-#{version}-#{flavor}", { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 } @@ -98,8 +101,9 @@ describe Chef::Provider::Package::Openbsd do context "if a version is specified" do it "should use the flavor from the version" do - expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return( - instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n")) + expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything).and_return( + instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n") + ) new_resource.version("#{version}-#{flavor_b}") expect(provider).to receive(:shell_out_compacted!).with( @@ -116,7 +120,7 @@ describe Chef::Provider::Package::Openbsd do describe "delete a package" do before do @name = "ihavetoes" - @new_resource = Chef::Resource::Package.new(@name) + @new_resource = Chef::Resource::Package.new(@name) @current_resource = Chef::Resource::Package.new(@name) @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) @provider.current_resource = @current_resource diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index 10bb3492b2..c869992a0f 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -34,7 +34,7 @@ describe Chef::Provider::Package::Pacman do @stdin = StringIO.new @stdout = StringIO.new(<<~ERR) error: package "nano" not found -ERR + ERR @stderr = StringIO.new @pid = 2342 end @@ -86,7 +86,7 @@ ERR Install Reason : Explicitly installed Install Script : Yes Description : Pico editor clone with enhancements -PACMAN + PACMAN status = double(stdout: stdout, exitstatus: 0) allow(@provider).to receive(:shell_out_compacted).and_return(status) @@ -118,7 +118,7 @@ PACMAN [community] Include = /etc/pacman.d/mirrorlist -PACMAN_CONF + PACMAN_CONF status = double(stdout: "customrepo nano 1.2.3-4", exitstatus: 0) allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true) diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb index 10c0d0f7e8..678e2e6301 100644 --- a/spec/unit/provider/package/paludis_spec.rb +++ b/spec/unit/provider/package/paludis_spec.rb @@ -40,7 +40,7 @@ describe Chef::Provider::Package::Paludis do user/ntp 0 accounts user/ntp 0 installed-accounts net/ntp 4.2.6_p5-r1 installed -PKG_STATUS + PKG_STATUS @pid = 12345 @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0) end @@ -71,7 +71,7 @@ PKG_STATUS user/ntp 0 accounts user/ntp 0 installed-accounts net/ntp 4.2.6_p5-r1 installed -INSTALLED + INSTALLED expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out) @provider.load_current_resource expect(@current_resource.version).to eq("4.2.6_p5-r1") @@ -100,7 +100,7 @@ INSTALLED @stdout.replace(<<~PKG_STATUS) sys-process/lsof 4.87 arbor sys-process/lsof 4.87 x86_64 -PKG_STATUS + PKG_STATUS expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { timeout: @new_resource.timeout || 900 }) @provider.install_package("sys-process/lsof", "4.87") end @@ -109,7 +109,7 @@ PKG_STATUS @stdout.replace(<<~PKG_STATUS) sys-process/lsof 4.87 arbor sys-process/lsof 4.87 x86_64 -PKG_STATUS + PKG_STATUS expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out) @provider.load_current_resource expect(@current_resource.version).to be_nil diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index e1036bea74..4bfef864ff 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -138,7 +138,7 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do * dev-python/sphinx Please use a more specific atom. -EOF + EOF status = double(stdout: "", stderr: stderr_output, exitstatus: 1) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) expect(@provider).to receive(:shell_out_compacted).and_return(status) diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb index c7a16acaa2..e4adc402cb 100644 --- a/spec/unit/provider/package/powershell_spec.rb +++ b/spec/unit/provider/package/powershell_spec.rb @@ -198,7 +198,7 @@ describe Chef::Provider::Package::Powershell do end it "can build a valid command from an array" do - expect(provider.build_powershell_package_command(["Get-Package", "posh-git"])).to eql(generated_command) + expect(provider.build_powershell_package_command(%w{Get-Package posh-git})).to eql(generated_command) end context "when source is nil" do diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index cd85e1b3d9..91ccb87211 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new("varnish") + @new_resource = Chef::Resource::Package.new("varnish") @current_resource = Chef::Resource::Package.new("varnish") @status = double("Status", exitstatus: 0) @@ -75,7 +75,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end it "should lookup the candidate_version if the variable is not already set (pkgin separated by spaces)" do - search = double() + search = double expect(search).to receive(:each_line) .and_yield("something-varnish-1.1.1 something varnish like\n") .and_yield("varnish-2.3.4 actual varnish\n") @@ -85,7 +85,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end it "should lookup the candidate_version if the variable is not already set (pkgin separated by semicolons)" do - search = double() + search = double expect(search).to receive(:each_line) .and_yield("something-varnish-1.1.1;;something varnish like\n") .and_yield("varnish-2.3.4;;actual varnish\n") diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb index 2aa37fe8b3..5fc2d89a81 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -44,7 +44,7 @@ describe Chef::Provider::Package::Solaris do PSTAMP: sfw10-patch20070430084444 INSTDATE: Nov 04 2009 01:02 HOTLINE: Please contact your local service provider -PKGINFO + PKGINFO @status = double("Status", stdout: "", exitstatus: 0) end diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb index 4f6a6121bd..6fa1747b03 100644 --- a/spec/unit/provider/package/windows/exe_spec.rb +++ b/spec/unit/provider/package/windows/exe_spec.rb @@ -117,7 +117,7 @@ describe Chef::Provider::Package::Windows::Exe do context "no version given and one package installed with unquoted uninstall string" do it "removes installed package and quotes uninstall string" do allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true) - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.remove_package end end @@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do it "removes installed package and quotes uninstall string" do new_resource.timeout = 300 allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true) - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, timeout: 300, returns: [0]) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, timeout: 300, returns: [0]) provider.remove_package end end @@ -148,15 +148,15 @@ describe Chef::Provider::Package::Windows::Exe do context "version given and installed" do it "removes given version" do new_resource.version("v2") - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir2\/uninst_file2\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir2/uninst_file2\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.remove_package end end context "no version given" do it "removes both versions" do - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir1\/uninst_file1\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir2\/uninst_file2\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir1/uninst_file1\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir2/uninst_file2\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.remove_package end end @@ -167,7 +167,7 @@ describe Chef::Provider::Package::Windows::Exe do let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :nsis, uninstall_entry) } it "calls installer with the correct flags" do - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.install_package end end @@ -176,7 +176,7 @@ describe Chef::Provider::Package::Windows::Exe do let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :installshield, uninstall_entry) } it "calls installer with the correct flags" do - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/s \/sms & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /s /sms & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.install_package end end @@ -185,7 +185,7 @@ describe Chef::Provider::Package::Windows::Exe do let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :inno, uninstall_entry) } it "calls installer with the correct flags" do - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/VERYSILENT \/SUPPRESSMSGBOXES \/NORESTART & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.install_package end end @@ -194,7 +194,7 @@ describe Chef::Provider::Package::Windows::Exe do let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :wise, uninstall_entry) } it "calls installer with the correct flags" do - expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/s & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /s & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash)) provider.install_package end end diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index 0e939610db..d2902e1bb1 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -104,14 +104,14 @@ describe Chef::Provider::Package::Windows::MSI do describe "install_package" do it "calls msiexec /qn /i" do - expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/i \"#{Regexp.quote(new_resource.source)}\"/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /qn /i \"#{Regexp.quote(new_resource.source)}\"}, kind_of(Hash)) provider.install_package end end describe "remove_package" do it "calls msiexec /qn /x" do - expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/x \"#{Regexp.quote(new_resource.source)}\"/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /qn /x \"#{Regexp.quote(new_resource.source)}\"}, kind_of(Hash)) provider.remove_package end @@ -121,7 +121,7 @@ describe Chef::Provider::Package::Windows::MSI do end it "removes installed package" do - expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /q}, kind_of(Hash)) provider.remove_package end @@ -140,8 +140,8 @@ describe Chef::Provider::Package::Windows::MSI do end it "removes both installed package" do - expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash)) - expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid2} \/q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /q}, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid2} /q}, kind_of(Hash)) provider.remove_package end end @@ -150,7 +150,7 @@ describe Chef::Provider::Package::Windows::MSI do before { new_resource.options("/Q") } it "does not duplicate quiet switch" do - expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/Q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /Q}, kind_of(Hash)) provider.remove_package end end @@ -159,7 +159,7 @@ describe Chef::Provider::Package::Windows::MSI do before { new_resource.options("/qn") } it "does not duplicate quiet switch" do - expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/qn/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /qn}, kind_of(Hash)) provider.remove_package end end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index 6b85013f3d..2fafb3bd0e 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -436,7 +436,8 @@ describe Chef::Provider::Package::Windows, :windows_only do it "raises the checksum mismatch exception" do expect { provider.send(:validate_content!) }.to raise_error( - Chef::Exceptions::ChecksumMismatch) + Chef::Exceptions::ChecksumMismatch + ) end end end diff --git a/spec/unit/provider/package/yum/yum_cache_spec.rb b/spec/unit/provider/package/yum/yum_cache_spec.rb index 6b2a617ac8..9867c31c37 100644 --- a/spec/unit/provider/package/yum/yum_cache_spec.rb +++ b/spec/unit/provider/package/yum/yum_cache_spec.rb @@ -60,7 +60,7 @@ describe Chef::Provider::Package::Yum::YumCache do expect( yum_cache.version_available?("foo", "1.2.3", "x86_64") ).to be true end - [ :refresh, :reload, :reload_installed, :reload_provides, :reset, :reset_installed ].each do |method| + %i{refresh reload reload_installed reload_provides reset reset_installed}.each do |method| it "restarts the python helper when #{method} is called" do expect( python_helper ).to receive(:restart) yum_cache.send(method) diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 2d85584d69..dc02932445 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -232,7 +232,7 @@ describe Chef::Provider::Package::Zypper do context "when package version is not explicitly specified" do it "should run zypper remove with the package name" do shell_out_expectation!( - "zypper", "--non-interactive", "remove", "emacs" + "zypper", "--non-interactive", "remove", "emacs" ) provider.remove_package(["emacs"], [nil]) end @@ -248,14 +248,14 @@ describe Chef::Provider::Package::Zypper do it "should run zypper remove without gpg checks" do new_resource.gpg_check false shell_out_expectation!( - "zypper", "--non-interactive", "--no-gpg-checks", "remove", "emacs=1.0" + "zypper", "--non-interactive", "--no-gpg-checks", "remove", "emacs=1.0" ) provider.remove_package(["emacs"], ["1.0"]) end it "should run zypper remove without gpg checks when the config is false" do Chef::Config[:zypper_check_gpg] = false shell_out_expectation!( - "zypper", "--non-interactive", "--no-gpg-checks", "remove", "emacs=1.0" + "zypper", "--non-interactive", "--no-gpg-checks", "remove", "emacs=1.0" ) provider.remove_package(["emacs"], ["1.0"]) end @@ -462,7 +462,7 @@ describe Chef::Provider::Package::Zypper do describe "remove_package" do it "should run zypper remove with the package name" do shell_out_expectation!( - "zypper", "remove", "-y", "emacs" + "zypper", "remove", "-y", "emacs" ) provider.remove_package(["emacs"], ["1.0"]) end diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index 181ac40a1b..b7845b144f 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -956,7 +956,7 @@ describe "Chef::Provider::Package - Multi" do Chef::Config[:treat_deprecation_warnings_as_errors] = false end - [ :shell_out_with_timeout, :shell_out_with_timeout! ].each do |method| + %i{shell_out_with_timeout shell_out_with_timeout!}.each do |method| stubbed_method = method == :shell_out_with_timeout! ? :shell_out_compacted! : :shell_out_compacted [ %w{command arg1 arg2}, "command arg1 arg2" ].each do |command| it "#{method} defaults to 900 seconds" do diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index 79d84e61dc..c6c98e81bf 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -22,9 +22,9 @@ describe Chef::Provider::PowershellScript, "action_run" do let(:powershell_version) { nil } let(:node) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s - if ! powershell_version.nil? + unless powershell_version.nil? node.default[:languages] = { powershell: { version: powershell_version } } end node @@ -103,14 +103,14 @@ describe Chef::Provider::PowershellScript, "action_run" do "3.6" => "Bypass", "4.0" => "Bypass", "5.0" => "Bypass" }.each do |version_policy| - let(:powershell_version) { version_policy[0].to_f } - context "when running PowerShell version #{version_policy[0]}" do let(:powershell_version) { version_policy[0].to_f } - it "sets the -ExecutionPolicy flag to '#{version_policy[1]}'" do - expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase) + context "when running PowerShell version #{version_policy[0]}" do + let(:powershell_version) { version_policy[0].to_f } + it "sets the -ExecutionPolicy flag to '#{version_policy[1]}'" do + expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase) + end end end - end end end end diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb index 9a7dd9996e..2df2c917f9 100644 --- a/spec/unit/provider/registry_key_spec.rb +++ b/spec/unit/provider/registry_key_spec.rb @@ -322,7 +322,7 @@ describe Chef::Provider::RegistryKey do expect(@double_registry).to receive(:get_values).with(keyname).and_return( [ { name: "one", type: :string, data: "initial value" }, - { name: "two", type: :dword, data: 9001 } + { name: "two", type: :dword, data: 9001 }, ] ) end diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb index d391da3010..f9559d8827 100644 --- a/spec/unit/provider/remote_directory_spec.rb +++ b/spec/unit/provider/remote_directory_spec.rb @@ -90,8 +90,8 @@ describe Chef::Provider::RemoteDirectory do it "configures access control on files in the directory" do @resource.cookbook "berlin_style_tasty_cupcakes" cookbook_file = @provider.send(:cookbook_file_resource, - "/target/destination/path.txt", - "relative/source/path.txt") + "/target/destination/path.txt", + "relative/source/path.txt") expect(cookbook_file.cookbook_name).to eq("berlin_style_tasty_cupcakes") expect(cookbook_file.source).to eq("remotedir_root/relative/source/path.txt") expect(cookbook_file.mode).to eq("0640") @@ -104,14 +104,14 @@ describe Chef::Provider::RemoteDirectory do @resource.cookbook "gondola_rides" @resource.sensitive true cookbook_file = @provider.send(:cookbook_file_resource, - "/target/destination/path.txt", - "relative/source/path.txt") + "/target/destination/path.txt", + "relative/source/path.txt") expect(cookbook_file.sensitive).to eq(true) @resource.sensitive false cookbook_file = @provider.send(:cookbook_file_resource, - "/target/destination/path.txt", - "relative/source/path.txt") + "/target/destination/path.txt", + "relative/source/path.txt") expect(cookbook_file.sensitive).to eq(false) end end diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index 67311aa6f7..ad5223a04f 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -125,7 +125,7 @@ describe Chef::Provider::Route do @resource_add.action(:add) @provider.run_action(:add) expect(route_file.string.split("\n").size).to eq(1) - expect(route_file.string).to match(/^192\.168\.1\.0\/24 via 192\.168\.0\.1$/) + expect(route_file.string).to match(%r{^192\.168\.1\.0/24 via 192\.168\.0\.1$}) end end @@ -150,12 +150,12 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "generate_command for action_add" do it "should include a netmask when a one is specified" do @new_resource.netmask("255.255.0.0") - expect(@provider.generate_command(:add).join(" ")).to match(/\/\d{1,2}/) + expect(@provider.generate_command(:add).join(" ")).to match(%r{/\d{1,2}}) end it "should not include a netmask when a one is specified" do @new_resource.netmask(nil) - expect(@provider.generate_command(:add).join(" ")).not_to match(/\/\d{1,2}/) + expect(@provider.generate_command(:add).join(" ")).not_to match(%r{/\d{1,2}}) end it "should include ' via $gateway ' when a gateway is specified" do @@ -176,12 +176,12 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "generate_command for action_delete" do it "should include a netmask when a one is specified" do @new_resource.netmask("255.255.0.0") - expect(@provider.generate_command(:delete).join(" ")).to match(/\/\d{1,2}/) + expect(@provider.generate_command(:delete).join(" ")).to match(%r{/\d{1,2}}) end it "should not include a netmask when a one is specified" do @new_resource.netmask(nil) - expect(@provider.generate_command(:delete).join(" ")).not_to match(/\/\d{1,2}/) + expect(@provider.generate_command(:delete).join(" ")).not_to match(%r{/\d{1,2}}) end it "should include ' via $gateway ' when a gateway is specified" do @@ -197,11 +197,11 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "config_file_contents for action_add" do it "should include a netmask when a one is specified" do @new_resource.netmask("255.255.0.0") - expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(/\/\d{1,2}.*\n$/) + expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(%r{/\d{1,2}.*\n$}) end it "should not include a netmask when a one is specified" do - expect(@provider.config_file_contents(:add, target: @new_resource.target)).not_to match(/\/\d{1,2}.*\n$/) + expect(@provider.config_file_contents(:add, target: @new_resource.target)).not_to match(%r{/\d{1,2}.*\n$}) end it "should include ' via $gateway ' when a gateway is specified" do @@ -261,10 +261,10 @@ describe Chef::Provider::Route do @provider.action = :add @provider.generate_config expect(route_file.string.split("\n").size).to eq(4) - expect(route_file.string).to match(/^192\.168\.1\.0\/24 via 192\.168\.0\.1$/) - expect(route_file.string).to match(/^192\.168\.2\.0\/24 via 192\.168\.0\.1$/) - expect(route_file.string).to match(/^192\.168\.3\.0\/24 via 192\.168\.0\.1$/) - expect(route_file.string).to match(/^192\.168\.4\.0\/24 via 192\.168\.0\.1$/) + expect(route_file.string).to match(%r{^192\.168\.1\.0/24 via 192\.168\.0\.1$}) + expect(route_file.string).to match(%r{^192\.168\.2\.0/24 via 192\.168\.0\.1$}) + expect(route_file.string).to match(%r{^192\.168\.3\.0/24 via 192\.168\.0\.1$}) + expect(route_file.string).to match(%r{^192\.168\.4\.0/24 via 192\.168\.0\.1$}) end end end diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index a7a9602750..de2bb16a6a 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -121,7 +121,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb -DEFAULT_PS + DEFAULT_PS @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) @@ -132,7 +132,7 @@ DEFAULT_PS @stdout = StringIO.new(<<~RUNNING_PS) aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos -RUNNING_PS + RUNNING_PS allow(@status).to receive(:stdout).and_return(@stdout) @provider.load_current_resource expect(@provider.current_resource.running).to be_truthy @@ -181,7 +181,7 @@ RUNNING_PS it "should add chef to DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)") expect(@provider).to receive(:update_daemons).with(%w{network chef}) - @provider.enable_service() + @provider.enable_service end end @@ -202,7 +202,7 @@ RUNNING_PS it "should remove chef from DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)") expect(@provider).to receive(:update_daemons).with(["network", "!chef"]) - @provider.disable_service() + @provider.disable_service end end @@ -223,12 +223,12 @@ RUNNING_PS it "should call the start command if one is specified" do @new_resource.start_command("/etc/rc.d/chef startyousillysally") expect(@provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false) - @provider.start_service() + @provider.start_service end it "should call '/etc/rc.d/service_name start' if no start command is specified" do expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} start", default_env: false) - @provider.start_service() + @provider.start_service end end @@ -249,12 +249,12 @@ RUNNING_PS it "should call the stop command if one is specified" do @new_resource.stop_command("/etc/rc.d/chef itoldyoutostop") expect(@provider).to receive(:shell_out!).with("/etc/rc.d/chef itoldyoutostop", default_env: false) - @provider.stop_service() + @provider.stop_service end it "should call '/etc/rc.d/service_name stop' if no stop command is specified" do expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} stop", default_env: false) - @provider.stop_service() + @provider.stop_service end end @@ -276,20 +276,20 @@ RUNNING_PS it "should call 'restart' on the service_name if the resource supports it" do @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should call the restart_command if one has been specified" do @new_resource.restart_command("/etc/rc.d/chef restartinafire") expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) - @provider.restart_service() + @provider.restart_service end end @@ -311,13 +311,13 @@ RUNNING_PS it "should call 'reload' on the service if it supports it" do @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload", default_env: false) - @provider.reload_service() + @provider.reload_service end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.reload_command("/etc/rc.d/chef lollerpants") expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants", default_env: false) - @provider.reload_service() + @provider.reload_service end end end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index 626abb10f7..5f89605b2e 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -89,7 +89,8 @@ describe Chef::Provider::Service::Debian do "0" => [:stop, "20"], "1" => [:stop, "20"], "6" => [:stop, "20"], - }) + } + ) end end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index b4330b976c..4392786edc 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -142,7 +142,7 @@ describe Chef::Provider::Service::Freebsd do 413 ?? Ss 0:02.51 /usr/sbin/syslogd -s 539 ?? Is 0:00.14 /usr/sbin/sshd 545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail) -PS_SAMPLE + PS_SAMPLE end let(:status) { double(stdout: stdout, exitstatus: 0) } @@ -261,7 +261,8 @@ PS_SAMPLE [ %Q{thing_#{new_resource.service_name}_enable="YES"}, %Q{#{new_resource.service_name}_enable="NO"}, - ] end + ] + end it "sets enabled based on the exact match (false)" do provider.determine_enabled_status! expect(current_resource.enabled).to be false @@ -273,7 +274,8 @@ PS_SAMPLE [ %Q{#{new_resource.service_name}_thing_enable="YES"}, %Q{#{new_resource.service_name}_enable="NO"}, - ] end + ] + end it "sets enabled based on the exact match (false)" do provider.determine_enabled_status! expect(current_resource.enabled).to be false @@ -285,7 +287,8 @@ PS_SAMPLE [ %Q{thing_#{new_resource.service_name}_enable="NO"}, %Q{#{new_resource.service_name}_enable="YES"}, - ] end + ] + end it "sets enabled based on the exact match (true)" do provider.determine_enabled_status! expect(current_resource.enabled).to be true @@ -297,7 +300,8 @@ PS_SAMPLE [ %Q{#{new_resource.service_name}_thing_enable="NO"}, %Q{#{new_resource.service_name}_enable="YES"}, - ] end + ] + end it "sets enabled based on the exact match (true)" do provider.determine_enabled_status! expect(current_resource.enabled).to be true @@ -344,7 +348,7 @@ PS_SAMPLE StringIO.new(<<~EOF) name="#{new_resource.service_name}" rcvar=`set_rcvar` -EOF + EOF end it "should not raise an exception if the rcscript have a name variable" do @@ -365,7 +369,7 @@ EOF let(:rcscript) do StringIO.new <<~EOF rcvar=`set_rcvar` -EOF + EOF end before do @@ -380,7 +384,7 @@ EOF # # #{new_resource.service_name}_enable="YES" # (default: "") -EOF + EOF end it "should get the service name from rcvar if the rcscript does not have a name variable" do @@ -397,7 +401,7 @@ EOF rcvar_stdout = <<~EOF # service_with_noname # -EOF + EOF end it "should return nil" do @@ -445,12 +449,12 @@ EOF it "should call the start command if one is specified" do new_resource.start_command("/etc/rc.d/chef startyousillysally") expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false) - provider.start_service() + provider.start_service end it "should call '/usr/local/etc/rc.d/service_name faststart' if no start command is specified" do expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart", default_env: false) - provider.start_service() + provider.start_service end end @@ -458,12 +462,12 @@ EOF it "should call the stop command if one is specified" do new_resource.stop_command("/etc/init.d/chef itoldyoutostop") expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false) - provider.stop_service() + provider.stop_service end it "should call '/usr/local/etc/rc.d/service_name faststop' if no stop command is specified" do expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop", default_env: false) - provider.stop_service() + provider.stop_service end end @@ -471,19 +475,19 @@ EOF it "should call 'restart' on the service_name if the resource supports it" do new_resource.supports({ restart: true }) expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart", default_env: false) - provider.restart_service() + provider.restart_service end it "should call the restart_command if one has been specified" do new_resource.restart_command("/etc/init.d/chef restartinafire") expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire", default_env: false) - provider.restart_service() + provider.restart_service end it "otherwise it should call stop and start" do expect(provider).to receive(:stop_service) expect(provider).to receive(:start_service) - provider.restart_service() + provider.restart_service end end end @@ -550,21 +554,21 @@ EOF allow(current_resource).to receive(:enabled).and_return(false) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"NO\"", "bar" ]) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""]) - provider.enable_service() + provider.enable_service end it "should not partial match an already enabled service" do allow(current_resource).to receive(:enabled).and_return(false) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar" ]) expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar", "#{new_resource.service_name}_enable=\"YES\""]) - provider.enable_service() + provider.enable_service end it "should enable the service if it is not enabled and not already specified in the rc.conf file" do allow(current_resource).to receive(:enabled).and_return(false) expect(provider).to receive(:read_rc_conf).and_return(%w{foo bar}) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""]) - provider.enable_service() + provider.enable_service end it "should not enable the service if it is already enabled" do @@ -577,7 +581,7 @@ EOF allow(current_resource).to receive(:enabled).and_return(false) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar", "\# #{new_resource.service_name}_enable=\"YES\"", "\# #{new_resource.service_name}_enable=\"NO\""]) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""]) - provider.enable_service() + provider.enable_service end end @@ -591,27 +595,27 @@ EOF allow(current_resource).to receive(:enabled).and_return(true) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"YES\"", "bar" ]) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"NO\""]) - provider.disable_service() + provider.disable_service end it "should not disable an enabled service that partially matches" do allow(current_resource).to receive(:enabled).and_return(true) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar" ]) expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar", "#{new_resource.service_name}_enable=\"NO\""]) - provider.disable_service() + provider.disable_service end it "should not disable the service if it is already disabled" do allow(current_resource).to receive(:enabled).and_return(false) expect(provider).not_to receive(:write_rc_conf) - provider.disable_service() + provider.disable_service end it "should remove commented out versions of it being disabled or enabled" do allow(current_resource).to receive(:enabled).and_return(true) expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar", "\# #{new_resource.service_name}_enable=\"YES\"", "\# #{new_resource.service_name}_enable=\"NO\""]) expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"NO\""]) - provider.disable_service() + provider.disable_service end end end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index 6a928d849b..bc3d0b5c04 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -129,14 +129,14 @@ describe Chef::Provider::Service::Gentoo do describe Chef::Provider::Service::Gentoo, "enable_service" do it "should call rc-update add *service* default" do expect(@provider).to receive(:shell_out!).with("/sbin/rc-update add chef default") - @provider.enable_service() + @provider.enable_service end end describe Chef::Provider::Service::Gentoo, "disable_service" do it "should call rc-update del *service* default" do expect(@provider).to receive(:shell_out!).with("/sbin/rc-update del chef default") - @provider.disable_service() + @provider.disable_service end end end diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 07668ef8ab..b75d7c4981 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::Service::Init, "load_current_resource" do aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb -PS + PS @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -136,7 +136,7 @@ PS @stdout = StringIO.new(<<~RUNNING_PS) aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos -RUNNING_PS + RUNNING_PS allow(@status).to receive(:stdout).and_return(@stdout) @provider.load_current_resource expect(@current_resource.running).to be_truthy @@ -165,12 +165,12 @@ RUNNING_PS it "should call the start command if one is specified" do @new_resource.start_command("/etc/init.d/chef startyousillysally") expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef startyousillysally", default_env: false) - @provider.start_service() + @provider.start_service end it "should call '/etc/init.d/service_name start' if no start command is specified" do expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} start", default_env: false) - @provider.start_service() + @provider.start_service end end @@ -178,12 +178,12 @@ RUNNING_PS it "should call the stop command if one is specified" do @new_resource.stop_command("/etc/init.d/chef itoldyoutostop") expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false) - @provider.stop_service() + @provider.stop_service end it "should call '/etc/init.d/service_name stop' if no stop command is specified" do expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} stop", default_env: false) - @provider.stop_service() + @provider.stop_service end end @@ -191,20 +191,20 @@ RUNNING_PS it "should call 'restart' on the service_name if the resource supports it" do @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should call the restart_command if one has been specified" do @new_resource.restart_command("/etc/init.d/chef restartinafire") expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restartinafire", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) - @provider.restart_service() + @provider.restart_service end end @@ -212,13 +212,13 @@ RUNNING_PS it "should call 'reload' on the service if it supports it" do @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false) - @provider.reload_service() + @provider.reload_service end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.reload_command("/etc/init.d/chef lollerpants") expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef lollerpants", default_env: false) - @provider.reload_service() + @provider.reload_service end end diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 822062a82b..1b3344e77b 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb -PS + PS @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -121,7 +121,7 @@ PS @stdout = StringIO.new(<<~RUNNING_PS) aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos -RUNNING_PS + RUNNING_PS @status = double("Status", exitstatus: 0, stdout: @stdout) expect(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource @@ -152,12 +152,12 @@ RUNNING_PS it "should call the start command if one is specified" do @new_resource.start_command("/usr/sbin/invoke-rc.d chef startyousillysally") expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef startyousillysally", default_env: false) - @provider.start_service() + @provider.start_service end it "should call '/usr/sbin/invoke-rc.d service_name start' if no start command is specified" do expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start", default_env: false) - @provider.start_service() + @provider.start_service end end @@ -165,12 +165,12 @@ RUNNING_PS it "should call the stop command if one is specified" do @new_resource.stop_command("/usr/sbin/invoke-rc.d chef itoldyoutostop") expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop", default_env: false) - @provider.stop_service() + @provider.stop_service end it "should call '/usr/sbin/invoke-rc.d service_name stop' if no stop command is specified" do expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop", default_env: false) - @provider.stop_service() + @provider.stop_service end end @@ -178,20 +178,20 @@ RUNNING_PS it "should call 'restart' on the service_name if the resource supports it" do @new_resource.supports({ restart: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should call the restart_command if one has been specified" do @new_resource.restart_command("/usr/sbin/invoke-rc.d chef restartinafire") expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) - @provider.restart_service() + @provider.restart_service end end @@ -199,13 +199,13 @@ RUNNING_PS it "should call 'reload' on the service if it supports it" do @new_resource.supports({ reload: true }) expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload", default_env: false) - @provider.reload_service() + @provider.reload_service end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.reload_command("/usr/sbin/invoke-rc.d chef lollerpants") expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef lollerpants", default_env: false) - @provider.reload_service() + @provider.reload_service end end end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 9864fb0185..420fd329f6 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -57,7 +57,7 @@ describe Chef::Provider::Service::Macosx do <string>io.redis.redis-server</string> </dict> </plist> -XML + XML %w{Daemon Agent}.each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| @@ -85,7 +85,7 @@ XML allow(provider).to receive(:shell_out) .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false) .and_return(double("Status", - stdout: launchctl_stdout, exitstatus: 0)) + stdout: launchctl_stdout, exitstatus: 0)) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out!) .with(/plutil -convert xml1 -o/, default_env: false) @@ -150,7 +150,7 @@ XML "-f"; ); }; -SVC_LIST + SVC_LIST before do provider.load_current_resource @@ -188,7 +188,7 @@ SVC_LIST "-f"; ); }; -SVC_LIST + SVC_LIST before do provider.load_current_resource @@ -206,7 +206,7 @@ SVC_LIST context "when launchctl doesn't return service entry at all" do let(:launchctl_stdout) { StringIO.new <<~SVC_LIST } Could not find service "io.redis.redis-server" in domain for system -SVC_LIST + SVC_LIST it "sets service running state to false" do provider.load_current_resource diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 913fddc1cf..dfa491fc38 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -178,7 +178,8 @@ describe Chef::Provider::Service::Openbsd do [ %Q{thing_#{provider.builtin_service_enable_variable_name}="YES"}, %Q{#{provider.builtin_service_enable_variable_name}="NO"}, - ] end + ] + end it "sets enabled based on the exact match (false)" do provider.determine_enabled_status! expect(current_resource.enabled).to be false @@ -190,7 +191,8 @@ describe Chef::Provider::Service::Openbsd do [ %Q{#{provider.builtin_service_enable_variable_name}_thing="YES"}, (provider.builtin_service_enable_variable_name).to_s, - ] end + ] + end it "sets enabled based on the exact match (false)" do provider.determine_enabled_status! expect(current_resource.enabled).to be false @@ -202,7 +204,8 @@ describe Chef::Provider::Service::Openbsd do [ %Q{thing_#{provider.builtin_service_enable_variable_name}="NO"}, %Q{#{provider.builtin_service_enable_variable_name}="YES"}, - ] end + ] + end it "sets enabled based on the exact match (true)" do provider.determine_enabled_status! expect(current_resource.enabled).to be true @@ -214,7 +217,8 @@ describe Chef::Provider::Service::Openbsd do [ %Q{#{provider.builtin_service_enable_variable_name}_thing="NO"}, %Q{#{provider.builtin_service_enable_variable_name}="YES"}, - ] end + ] + end it "sets enabled based on the exact match (true)" do provider.determine_enabled_status! expect(current_resource.enabled).to be true @@ -286,12 +290,12 @@ describe Chef::Provider::Service::Openbsd do it "should call the start command if one is specified" do new_resource.start_command("/etc/rc.d/chef startyousillysally") expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false) - provider.start_service() + provider.start_service end it "should call '/usr/local/etc/rc.d/service_name start' if no start command is specified" do expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} start", default_env: false) - provider.start_service() + provider.start_service end end @@ -299,12 +303,12 @@ describe Chef::Provider::Service::Openbsd do it "should call the stop command if one is specified" do new_resource.stop_command("/etc/init.d/chef itoldyoutostop") expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false) - provider.stop_service() + provider.stop_service end it "should call '/usr/local/etc/rc.d/service_name stop' if no stop command is specified" do expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} stop", default_env: false) - provider.stop_service() + provider.stop_service end end @@ -313,20 +317,20 @@ describe Chef::Provider::Service::Openbsd do let(:supports) { { restart: true } } it "should call 'restart' on the service_name if the resource supports it" do expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} restart", default_env: false) - provider.restart_service() + provider.restart_service end end it "should call the restart_command if one has been specified" do new_resource.restart_command("/etc/init.d/chef restartinafire") expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire", default_env: false) - provider.restart_service() + provider.restart_service end it "otherwise it should call stop and start" do expect(provider).to receive(:stop_service) expect(provider).to receive(:start_service) - provider.restart_service() + provider.restart_service end end end diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 4ea1d520b7..2546f9cef7 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb -NOMOCKINGSTRINGSPLZ + NOMOCKINGSTRINGSPLZ @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) end @@ -78,7 +78,7 @@ NOMOCKINGSTRINGSPLZ @stdout = StringIO.new(<<~NOMOCKINGSTRINGSPLZ) aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos -NOMOCKINGSTRINGSPLZ + NOMOCKINGSTRINGSPLZ @status = double("Status", exitstatus: 0, stdout: @stdout) allow(@provider).to receive(:shell_out!).and_return(@status) @provider.load_current_resource @@ -108,7 +108,7 @@ NOMOCKINGSTRINGSPLZ it "should call the start command if one is specified" do @new_resource.start_command((@new_resource.start_command).to_s) expect(@provider).to receive(:shell_out!).with((@new_resource.start_command).to_s, default_env: false) - @provider.start_service() + @provider.start_service end it "should raise an exception if no start command is specified" do @@ -122,7 +122,7 @@ NOMOCKINGSTRINGSPLZ it "should call the stop command if one is specified" do @new_resource.stop_command("/etc/init.d/themadness stop") expect(@provider).to receive(:shell_out!).with("/etc/init.d/themadness stop", default_env: false) - @provider.stop_service() + @provider.stop_service end it "should raise an exception if no stop command is specified" do @@ -136,7 +136,7 @@ NOMOCKINGSTRINGSPLZ it "should call the restart command if one has been specified" do @new_resource.restart_command("/etc/init.d/foo restart") expect(@provider).to receive(:shell_out!).with("/etc/init.d/foo restart", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should raise an exception if the resource doesn't support restart, no restart command is provided, and no stop command is provided" do @@ -149,7 +149,7 @@ NOMOCKINGSTRINGSPLZ expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) - @provider.restart_service() + @provider.restart_service end end @@ -163,7 +163,7 @@ NOMOCKINGSTRINGSPLZ it "should should run the user specified reload command if one is specified" do @new_resource.reload_command("kill -9 1") expect(@provider).to receive(:shell_out!).with("kill -9 1", default_env: false) - @provider.reload_service() + @provider.reload_service end end end diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 365201cb38..572246a807 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -242,7 +242,7 @@ describe Chef::Provider::Service::Upstart do allow(@current_resource).to receive(:enabled).and_return(false) expect(@file).to receive(:search_file_replace) expect(@file).to receive(:write_file) - @provider.enable_service() + @provider.enable_service end it "should disable the service if it is enabled" do @@ -251,7 +251,7 @@ describe Chef::Provider::Service::Upstart do allow(@current_resource).to receive(:enabled).and_return(true) expect(@file).to receive(:search_file_replace) expect(@file).to receive(:write_file) - @provider.disable_service() + @provider.disable_service end end @@ -268,19 +268,19 @@ describe Chef::Provider::Service::Upstart do @provider.upstart_service_running = false @new_resource.start_command("/sbin/rsyslog startyousillysally") expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog startyousillysally", default_env: false) - @provider.start_service() + @provider.start_service end it "should call '/sbin/start service_name' if no start command is specified" do @provider.upstart_service_running = false expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success) - @provider.start_service() + @provider.start_service end it "should not call '/sbin/start service_name' if it is already running" do @provider.upstart_service_running = true expect(@provider).not_to receive(:shell_out!) - @provider.start_service() + @provider.start_service end it "should pass parameters to the start command if they are provided" do @@ -289,14 +289,14 @@ describe Chef::Provider::Service::Upstart do @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.current_resource = @current_resource expect(@provider).to receive(:shell_out!).with("/sbin/start rsyslog OSD_ID=2", default_env: false).and_return(shell_out_success) - @provider.start_service() + @provider.start_service end it "should call the restart command if one is specified" do allow(@current_resource).to receive(:running).and_return(true) @new_resource.restart_command("/sbin/rsyslog restartyousillysally") expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog restartyousillysally", default_env: false) - @provider.restart_service() + @provider.restart_service end it "should call start/sleep/stop if no restart command is specified" do @@ -304,47 +304,47 @@ describe Chef::Provider::Service::Upstart do expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) - @provider.restart_service() + @provider.restart_service end it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do @provider.upstart_service_running = false allow(@current_resource).to receive(:running).and_return(false) expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success) - @provider.restart_service() + @provider.restart_service end it "should call the reload command if one is specified" do allow(@current_resource).to receive(:running).and_return(true) @new_resource.reload_command("/sbin/rsyslog reloadyousillysally") expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally", default_env: false) - @provider.reload_service() + @provider.reload_service end it "should call '/sbin/reload service_name' if no reload command is specified" do allow(@current_resource).to receive(:running).and_return(true) expect(@provider).to receive(:shell_out!).with("/sbin/reload #{@new_resource.service_name}", default_env: false).and_return(shell_out_success) - @provider.reload_service() + @provider.reload_service end it "should call the stop command if one is specified" do @provider.upstart_service_running = true @new_resource.stop_command("/sbin/rsyslog stopyousillysally") expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog stopyousillysally", default_env: false) - @provider.stop_service() + @provider.stop_service end it "should call '/sbin/stop service_name' if no stop command is specified" do @provider.upstart_service_running = true expect(@provider).to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false).and_return(shell_out_success) - @provider.stop_service() + @provider.stop_service end it "should not call '/sbin/stop service_name' if it is already stopped" do @provider.upstart_service_running = false allow(@current_resource).to receive(:running).and_return(false) expect(@provider).not_to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false) - @provider.stop_service() + @provider.stop_service expect(@upstart_service_running).to be_falsey end end diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 3e40291aea..381f62b711 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -41,8 +41,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl tag_id: 0, dependencies: ["Winmgmt"], service_start_name: "LocalSystem", - display_name: "Chef Client Service" - ) + display_name: "Chef Client Service") end # Actual response from Win32::Service.services @@ -73,8 +72,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl command: nil, num_actions: 0, actions: nil, - delayed_start: 1 - ) + delayed_start: 1) end let(:provider) do @@ -98,7 +96,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl allow(Win32::Service).to receive(:start).with(any_args).and_return(Win32::Service) allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) allow(Win32::Service).to receive(:config_info).with(new_resource.service_name) .and_return(chef_service_config_info) @@ -176,8 +175,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl tag_id: 0, dependencies: %w{NSI Tdx Afd}, service_start_name: 'NT Authority\\LocalService', - display_name: "DHCP Client" - )) + display_name: "DHCP Client") + ) end context "startup_type is neither :automatic or :disabled" do @@ -192,8 +191,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl tag_id: 0, dependencies: %w{NSI Tdx Afd}, service_start_name: 'NT Authority\\LocalService', - display_name: "DHCP Client" - )) + display_name: "DHCP Client") + ) end it "does not set the current resources enabled" do @@ -385,14 +384,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl # properties that are Strings %i{binary_path_name load_order_group dependencies run_as_user display_name description}.each do |attr| - it "configures service if #{attr} has changed" do - provider.current_resource.send("#{attr}=", "old value") - provider.new_resource.send("#{attr}=", "new value") + it "configures service if #{attr} has changed" do + provider.current_resource.send("#{attr}=", "old value") + provider.new_resource.send("#{attr}=", "new value") - expect(Win32::Service).to receive(:configure) - provider.action_configure - end - end + expect(Win32::Service).to receive(:configure) + provider.action_configure + end + end # properties that are Integers %i{service_type error_control}.each do |attr| @@ -503,7 +502,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( double("StatusStruct", current_state: "stopped"), - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) end context "run_as_user user is specified" do @@ -553,7 +553,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is running" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -562,7 +563,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "paused")) + double("StatusStruct", current_state: "paused") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -573,7 +575,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( double("StatusStruct", current_state: "start pending"), double("StatusStruct", current_state: "start pending"), - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) provider.start_service @@ -582,7 +585,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in stop_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "stop pending")) + double("StatusStruct", current_state: "stop pending") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.start_service }.to raise_error( Chef::Exceptions::Service ) @@ -623,7 +627,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl before(:each) do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( double("StatusStruct", current_state: "running"), - double("StatusStruct", current_state: "stopped")) + double("StatusStruct", current_state: "stopped") + ) end it "calls the stop command if one is specified" do @@ -648,7 +653,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "does nothing if the service is stopped" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "stopped")) + double("StatusStruct", current_state: "stopped") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -657,7 +663,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "raises an error if the service is paused" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "paused")) + double("StatusStruct", current_state: "paused") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:start).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -668,7 +675,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( double("StatusStruct", current_state: "stop pending"), double("StatusStruct", current_state: "stop pending"), - double("StatusStruct", current_state: "stopped")) + double("StatusStruct", current_state: "stopped") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) provider.stop_service @@ -677,7 +685,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "fails if the service is in start_pending" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "start pending")) + double("StatusStruct", current_state: "start pending") + ) provider.load_current_resource expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name) expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service ) @@ -686,7 +695,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl it "passes custom timeout to the stop command if provided" do allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) new_resource.timeout 1 expect(Win32::Service).to receive(:stop).with(new_resource.service_name) Timeout.timeout(2) do @@ -711,7 +721,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl double("StatusStruct", current_state: "running"), double("StatusStruct", current_state: "stopped"), double("StatusStruct", current_state: "stopped"), - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) expect(Win32::Service).to receive(:stop).with(new_resource.service_name) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service @@ -722,7 +733,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return( double("StatusStruct", current_state: "stopped"), double("StatusStruct", current_state: "stopped"), - double("StatusStruct", current_state: "running")) + double("StatusStruct", current_state: "running") + ) expect(Win32::Service).to receive(:start).with(new_resource.service_name) provider.restart_service expect(new_resource.updated_by_last_action?).to be_truthy @@ -741,7 +753,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "enable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "disabled")) + double("ConfigStruct", start_type: "disabled") + ) end it "enables service" do @@ -761,14 +774,16 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_enable" do it "does nothing if the service is enabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "auto start")) + double("ConfigStruct", start_type: "auto start") + ) expect(provider).not_to receive(:enable_service) provider.action_enable end it "enables the service if it is not set to automatic start" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "disabled")) + double("ConfigStruct", start_type: "disabled") + ) expect(provider).to receive(:enable_service) provider.action_enable end @@ -777,14 +792,16 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "action_disable" do it "does nothing if the service is disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "disabled")) + double("ConfigStruct", start_type: "disabled") + ) expect(provider).not_to receive(:disable_service) provider.action_disable end it "disables the service if it is not set to disabled" do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "auto start")) + double("ConfigStruct", start_type: "auto start") + ) expect(provider).to receive(:disable_service) provider.action_disable end @@ -793,7 +810,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl describe Chef::Provider::Service::Windows, "disable_service" do before(:each) do allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return( - double("ConfigStruct", start_type: "auto start")) + double("ConfigStruct", start_type: "auto start") + ) end it "disables service" do diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index d3c5073b7e..a70b7cd48b 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -277,7 +277,8 @@ describe Chef::Provider::Subversion do allow(ChefConfig).to receive(:windows?) { false } expect(@provider).to receive(:svn_binary).and_return("svn") expect(@provider.export_command).to eql( - "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") + "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir" + ) end it "selects an svn binary with an exe extension on windows" do @@ -285,21 +286,24 @@ describe Chef::Provider::Subversion do allow(ChefConfig).to receive(:windows?) { true } expect(@provider).to receive(:svn_binary).and_return("svn.exe") expect(@provider.export_command).to eql( - "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") + "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir" + ) end it "uses a custom svn binary as part of the svn command" do @resource.svn_binary "teapot" expect(@provider).to receive(:svn_binary).and_return("teapot") expect(@provider.export_command).to eql( - "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") + "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir" + ) end it "wraps custom svn binary with quotes if it contains whitespace" do @resource.svn_binary "c:/program files (x86)/subversion/svn.exe" expect(@provider).to receive(:svn_binary).and_return("c:/program files (x86)/subversion/svn.exe") expect(@provider.export_command).to eql( - '"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir') + '"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir' + ) end end diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb index 61caaef8bf..cf26c99b77 100644 --- a/spec/unit/provider/systemd_unit_spec.rb +++ b/spec/unit/provider/systemd_unit_spec.rb @@ -83,8 +83,8 @@ describe Chef::Provider::SystemdUnit do before(:each) do allow(Etc).to receive(:getpwnam).and_return(OpenStruct.new(uid: 1000)) allow(Chef::Resource::SystemdUnit).to receive(:new) - .with(unit_name) - .and_return(current_resource) + .with(unit_name) + .and_return(current_resource) end describe "define_resource_requirements" do @@ -121,8 +121,8 @@ describe Chef::Provider::SystemdUnit do it "should create a current resource with the name of the new resource" do expect(Chef::Resource::SystemdUnit).to receive(:new) - .with(unit_name) - .and_return(current_resource) + .with(unit_name) + .and_return(current_resource) provider.load_current_resource end @@ -196,26 +196,26 @@ describe Chef::Provider::SystemdUnit do it "loads the system unit content if the file exists and user is not set" do allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(true) + .with(unit_path_system) + .and_return(true) allow(File).to receive(:read) - .with(unit_path_system) - .and_return(unit_content_string) + .with(unit_path_system) + .and_return(unit_content_string) expect(File).to receive(:exist?) - .with(unit_path_system) + .with(unit_path_system) expect(File).to receive(:read) - .with(unit_path_system) + .with(unit_path_system) provider.load_current_resource expect(current_resource.content).to eq(unit_content_string) end it "does not load the system unit content if the unit file is not present and the user is not set" do allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(false) + .with(unit_path_system) + .and_return(false) expect(File).to_not receive(:read) - .with(unit_path_system) + .with(unit_path_system) provider.load_current_resource expect(current_resource.content).to eq(nil) end @@ -223,15 +223,15 @@ describe Chef::Provider::SystemdUnit do it "loads the user unit content if the file exists and user is set" do new_resource.user("joe") allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(true) + .with(unit_path_user) + .and_return(true) allow(File).to receive(:read) - .with(unit_path_user) - .and_return(unit_content_string) + .with(unit_path_user) + .and_return(unit_content_string) expect(File).to receive(:exist?) - .with(unit_path_user) + .with(unit_path_user) expect(File).to receive(:read) - .with(unit_path_user) + .with(unit_path_user) provider.load_current_resource expect(current_resource.content).to eq(unit_content_string) end @@ -239,10 +239,10 @@ describe Chef::Provider::SystemdUnit do it "does not load the user unit if the file does not exist and user is set" do new_resource.user("joe") allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(false) + .with(unit_path_user) + .and_return(false) expect(File).to_not receive(:read) - .with(unit_path_user) + .with(unit_path_user) provider.load_current_resource expect(current_resource.content).to eq(nil) end @@ -253,27 +253,27 @@ describe Chef::Provider::SystemdUnit do before(:each) do provider.current_resource = current_resource allow(provider).to receive(:which) - .with("systemctl") - .and_return(systemctl_path) + .with("systemctl") + .and_return(systemctl_path) end describe "creates/deletes/presets/reverts the unit" do it "creates the unit file when it does not exist" do allow(provider).to receive(:manage_unit_file) - .with(:create) - .and_return(true) + .with(:create) + .and_return(true) allow(provider).to receive(:daemon_reload) - .and_return(true) + .and_return(true) expect(provider).to receive(:manage_unit_file).with(:create) provider.action_create end it "creates the file when the unit content is different" do allow(provider).to receive(:manage_unit_file) - .with(:create) - .and_return(true) + .with(:create) + .and_return(true) allow(provider).to receive(:daemon_reload) - .and_return(true) + .and_return(true) expect(provider).to receive(:manage_unit_file).with(:create) provider.action_create end @@ -282,7 +282,7 @@ describe Chef::Provider::SystemdUnit do current_resource.content(unit_content_string) allow(provider).to receive(:manage_unit_file).with(:create) allow(provider).to receive(:daemon_reload) - .and_return(true) + .and_return(true) expect(provider).to_not receive(:manage_unit_file) provider.action_create end @@ -294,20 +294,20 @@ describe Chef::Provider::SystemdUnit do expect(new_resource.triggers_reload).to eq true allow(provider).to receive(:shell_out_compacted!) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) + .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) provider.action_create end it "triggers a daemon-reload when deleting a unit with triggers_reload" do new_resource.user("joe") allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(true) + .with(unit_path_user) + .and_return(true) allow(provider).to receive(:manage_unit_file).with(:delete) expect(new_resource.triggers_reload).to eq true allow(provider).to receive(:shell_out_compacted!) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) + .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) provider.action_delete end @@ -317,7 +317,7 @@ describe Chef::Provider::SystemdUnit do allow(provider).to receive(:manage_unit_file).with(:create) allow(provider).to receive(:shell_out_compacted!) expect(provider).to_not receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) + .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) provider.action_create end @@ -325,23 +325,23 @@ describe Chef::Provider::SystemdUnit do new_resource.user("joe") new_resource.triggers_reload(false) allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(true) + .with(unit_path_user) + .and_return(true) allow(provider).to receive(:manage_unit_file).with(:delete) allow(provider).to receive(:shell_out_compacted!) expect(provider).to_not receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) + .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false) provider.action_delete end it "deletes the file when it exists" do new_resource.user("joe") allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(true) + .with(unit_path_user) + .and_return(true) allow(provider).to receive(:manage_unit_file) - .with(:delete) - .and_return(true) + .with(:delete) + .and_return(true) allow(provider).to receive(:daemon_reload) expect(provider).to receive(:manage_unit_file).with(:delete) provider.action_delete @@ -350,8 +350,8 @@ describe Chef::Provider::SystemdUnit do it "does not delete the file when it is absent" do new_resource.user("joe") allow(File).to receive(:exist?) - .with(unit_path_user) - .and_return(false) + .with(unit_path_user) + .and_return(false) allow(provider).to receive(:manage_unit_file).with(:delete) expect(provider).to_not receive(:manage_unit_file) provider.action_delete @@ -360,16 +360,16 @@ describe Chef::Provider::SystemdUnit do it "presets the unit" do new_resource.user("joe") expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "preset", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "preset", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_preset end it "reverts the unit" do new_resource.user("joe") expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "revert", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "revert", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_revert end end @@ -380,19 +380,19 @@ describe Chef::Provider::SystemdUnit do expect(new_resource.triggers_reload).to eq true allow(provider).to receive(:shell_out_compacted!) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "daemon-reload", default_env: false) + .with(systemctl_path, "--system", "daemon-reload", default_env: false) provider.action_create end it "triggers a daemon-reload when deleting a unit with triggers_reload" do allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(true) + .with(unit_path_system) + .and_return(true) allow(provider).to receive(:manage_unit_file).with(:delete) expect(new_resource.triggers_reload).to eq true allow(provider).to receive(:shell_out_compacted!) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "daemon-reload", default_env: false) + .with(systemctl_path, "--system", "daemon-reload", default_env: false) provider.action_delete end @@ -401,27 +401,27 @@ describe Chef::Provider::SystemdUnit do allow(provider).to receive(:manage_unit_file).with(:create) allow(provider).to receive(:shell_out_compacted!) expect(provider).to_not receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "daemon-reload", default_env: false) + .with(systemctl_path, "--system", "daemon-reload", default_env: false) provider.action_create end it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do new_resource.triggers_reload(false) allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(true) + .with(unit_path_system) + .and_return(true) allow(provider).to receive(:manage_unit_file).with(:delete) allow(provider).to receive(:shell_out_compacted!) expect(provider).to_not receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "daemon-reload", default_env: false) + .with(systemctl_path, "--system", "daemon-reload", default_env: false) provider.action_delete end it "deletes the file when it exists" do allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(true) + .with(unit_path_system) + .and_return(true) allow(provider).to receive(:manage_unit_file) - .with(:delete) + .with(:delete) allow(provider).to receive(:daemon_reload) expect(provider).to receive(:manage_unit_file).with(:delete) provider.action_delete @@ -429,8 +429,8 @@ describe Chef::Provider::SystemdUnit do it "does not delete the file when it is absent" do allow(File).to receive(:exist?) - .with(unit_path_system) - .and_return(false) + .with(unit_path_system) + .and_return(false) allow(provider).to receive(:manage_unit_file).with(:delete) allow(provider).to receive(:daemon_reload) expect(provider).to_not receive(:manage_unit_file) @@ -439,15 +439,15 @@ describe Chef::Provider::SystemdUnit do it "presets the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "preset", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "preset", unit_name) + .and_return(shell_out_success) provider.action_preset end it "reverts the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "revert", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "revert", unit_name) + .and_return(shell_out_success) provider.action_revert end end @@ -458,8 +458,8 @@ describe Chef::Provider::SystemdUnit do it "reenables the unit" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "reenable", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "reenable", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_reenable end @@ -467,8 +467,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.enabled(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "enable", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "enable", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_enable end @@ -490,8 +490,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.enabled(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "disable", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "disable", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_disable end @@ -513,16 +513,16 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "reenables the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "reenable", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "reenable", unit_name) + .and_return(shell_out_success) provider.action_reenable end it "enables the unit when it is disabled" do current_resource.enabled(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "enable", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "enable", unit_name) + .and_return(shell_out_success) provider.action_enable end @@ -541,8 +541,8 @@ describe Chef::Provider::SystemdUnit do it "disables the unit when it is enabled" do current_resource.enabled(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "disable", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "disable", unit_name) + .and_return(shell_out_success) provider.action_disable end @@ -567,8 +567,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.masked(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "mask", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "mask", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_mask end @@ -583,8 +583,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.masked(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "unmask", unit_name, **user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "unmask", unit_name, **user_cmd_opts) + .and_return(shell_out_success) provider.action_unmask end @@ -600,8 +600,8 @@ describe Chef::Provider::SystemdUnit do it "masks the unit when it is unmasked" do current_resource.masked(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "mask", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "mask", unit_name) + .and_return(shell_out_success) provider.action_mask end @@ -614,8 +614,8 @@ describe Chef::Provider::SystemdUnit do it "unmasks the unit when it is masked" do current_resource.masked(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "unmask", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "unmask", unit_name) + .and_return(shell_out_success) provider.action_unmask end @@ -633,8 +633,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.active(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "start", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "start", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_start end @@ -649,8 +649,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.active(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "stop", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "stop", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_stop end @@ -666,8 +666,8 @@ describe Chef::Provider::SystemdUnit do it "starts the unit when it is inactive" do current_resource.active(false) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "start", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "start", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_start end @@ -680,8 +680,8 @@ describe Chef::Provider::SystemdUnit do it "stops the unit when it is active" do current_resource.active(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "stop", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "stop", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_stop end @@ -698,8 +698,8 @@ describe Chef::Provider::SystemdUnit do it "restarts the unit" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "restart", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "restart", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_restart end @@ -707,8 +707,8 @@ describe Chef::Provider::SystemdUnit do current_resource.user(user_name) current_resource.active(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "reload", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "reload", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_reload end @@ -723,16 +723,16 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "restarts the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "restart", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "restart", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_restart end it "reloads the unit if active" do current_resource.active(true) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "reload", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "reload", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_reload end @@ -749,8 +749,8 @@ describe Chef::Provider::SystemdUnit do it "try-restarts the unit" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "try-restart", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "try-restart", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_try_restart end end @@ -758,8 +758,8 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "try-restarts the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "try-restart", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "try-restart", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_try_restart end end @@ -770,8 +770,8 @@ describe Chef::Provider::SystemdUnit do it "reload-or-restarts the unit" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "reload-or-restart", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "reload-or-restart", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_reload_or_restart end end @@ -779,8 +779,8 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "reload-or-restarts the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "reload-or-restart", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "reload-or-restart", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_reload_or_restart end end @@ -791,8 +791,8 @@ describe Chef::Provider::SystemdUnit do it "reload-or-try-restarts the unit" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--user", "reload-or-try-restart", unit_name, **user_cmd_opts, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "reload-or-try-restart", unit_name, **user_cmd_opts, default_env: false) + .and_return(shell_out_success) provider.action_reload_or_try_restart end end @@ -800,8 +800,8 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "reload-or-try-restarts the unit" do expect(provider).to receive(:shell_out_compacted!) - .with(systemctl_path, "--system", "reload-or-try-restart", unit_name, default_env: false) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "reload-or-try-restart", unit_name, default_env: false) + .and_return(shell_out_success) provider.action_reload_or_try_restart end end @@ -817,16 +817,16 @@ describe Chef::Provider::SystemdUnit do it "returns true when unit is active" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts) + .and_return(shell_out_success) expect(provider.active?).to be true end it "returns false when unit is inactive" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts) - .and_return(shell_out_failure) + .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts) + .and_return(shell_out_failure) expect(provider.active?).to be false end end @@ -834,15 +834,15 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "returns true when unit is active" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "is-active", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "is-active", unit_name) + .and_return(shell_out_success) expect(provider.active?).to be true end it "returns false when unit is not active" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "is-active", unit_name) - .and_return(shell_out_failure) + .with(systemctl_path, "--system", "is-active", unit_name) + .and_return(shell_out_failure) expect(provider.active?).to be false end end @@ -858,8 +858,8 @@ describe Chef::Provider::SystemdUnit do it "returns true when unit is enabled" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) - .and_return(shell_out_success) + .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) + .and_return(shell_out_success) expect(provider.enabled?).to be true end @@ -875,8 +875,8 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "returns true when unit is enabled" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "is-enabled", unit_name) - .and_return(shell_out_success) + .with(systemctl_path, "--system", "is-enabled", unit_name) + .and_return(shell_out_success) expect(provider.enabled?).to be true end @@ -899,16 +899,16 @@ describe Chef::Provider::SystemdUnit do it "returns true when the unit is masked" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts) - .and_return(shell_out_masked) + .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts) + .and_return(shell_out_masked) expect(provider.masked?).to be true end it "returns false when the unit is not masked" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts) - .and_return(shell_out_static) + .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts) + .and_return(shell_out_static) expect(provider.masked?).to be false end end @@ -916,15 +916,15 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "returns true when the unit is masked" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "status", unit_name) - .and_return(shell_out_masked) + .with(systemctl_path, "--system", "status", unit_name) + .and_return(shell_out_masked) expect(provider.masked?).to be true end it "returns false when the unit is not masked" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "status", unit_name) - .and_return(shell_out_static) + .with(systemctl_path, "--system", "status", unit_name) + .and_return(shell_out_static) expect(provider.masked?).to be false end end @@ -940,16 +940,16 @@ describe Chef::Provider::SystemdUnit do it "returns true when the unit is static" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) - .and_return(shell_out_static) + .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) + .and_return(shell_out_static) expect(provider.static?).to be true end it "returns false when the unit is not static" do current_resource.user(user_name) expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) - .and_return(shell_out_masked) + .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts) + .and_return(shell_out_masked) expect(provider.static?).to be false end end @@ -957,15 +957,15 @@ describe Chef::Provider::SystemdUnit do context "when no user is specified" do it "returns true when the unit is static" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "is-enabled", unit_name) - .and_return(shell_out_static) + .with(systemctl_path, "--system", "is-enabled", unit_name) + .and_return(shell_out_static) expect(provider.static?).to be true end it "returns false when the unit is not static" do expect(provider).to receive(:shell_out_compacted) - .with(systemctl_path, "--system", "is-enabled", unit_name) - .and_return(shell_out_masked) + .with(systemctl_path, "--system", "is-enabled", unit_name) + .and_return(shell_out_masked) expect(provider.static?).to be false end end diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 67d4eba138..60ff18c123 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -30,20 +30,20 @@ describe Chef::Provider::Template::Content do let(:new_resource) do double("Chef::Resource::Template (new)", - cookbook_name: "openldap", - recipe_name: "default", - source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", - source_line_number: "2", - source: "openldap_stuff.conf.erb", - name: "openldap_stuff.conf", - path: resource_path, - local: false, - cookbook: nil, - variables: {}, - inline_helper_blocks: {}, - inline_helper_modules: [], - helper_modules: []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "openldap_stuff.conf.erb", + name: "openldap_stuff.conf", + path: resource_path, + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end let(:rendered_file_locations) do @@ -130,20 +130,20 @@ describe Chef::Provider::Template::Content do describe "when using location helpers" do let(:new_resource) do double("Chef::Resource::Template (new)", - cookbook_name: "openldap", - recipe_name: "default", - source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", - source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", - source_line_number: "2", - source: "helpers.erb", - name: "helpers.erb", - path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", - local: false, - cookbook: nil, - variables: {}, - inline_helper_blocks: {}, - inline_helper_modules: [], - helper_modules: []) + cookbook_name: "openldap", + recipe_name: "default", + source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", + source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", + source_line_number: "2", + source: "helpers.erb", + name: "helpers.erb", + path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", + local: false, + cookbook: nil, + variables: {}, + inline_helper_blocks: {}, + inline_helper_modules: [], + helper_modules: []) end it "creates the template with the rendered content" do @@ -162,7 +162,7 @@ describe Chef::Provider::Template::Content do 2 helpers.erb #{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb -EOF + EOF end end diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb index 8cce861f2a..74e1dc1de7 100644 --- a/spec/unit/provider/windows_task_spec.rb +++ b/spec/unit/provider/windows_task_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Provider::WindowsTask, :windows_only do let(:new_resource) { Chef::Resource::WindowsTask.new("sample_task") } - let(:current_resource) { Chef::Resource::WindowsTask.new() } + let(:current_resource) { Chef::Resource::WindowsTask.new } let(:provider) do node = Chef::Node.new diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index a3f2801adf..7996e3ae23 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -553,60 +553,60 @@ describe Chef::ProviderResolver do PROVIDERS = { - aix_user: [ Chef::Resource::User::AixUser, Chef::Provider::User::Aix ], - apt_package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], - bash: [ Chef::Resource::Bash, Chef::Provider::Script ], - bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Bff ], - breakpoint: [ Chef::Resource::Breakpoint, Chef::Resource::Breakpoint.action_class ], - chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ], - cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ], - csh: [ Chef::Resource::Csh, Chef::Provider::Script ], - directory: [ Chef::Resource::Directory, Chef::Provider::Directory ], - dpkg_package: [ Chef::Resource::DpkgPackage, Chef::Provider::Package::Dpkg ], - dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], - dscl_user: [ Chef::Resource::User::DsclUser, Chef::Provider::User::Dscl ], - execute: [ Chef::Resource::Execute, Chef::Provider::Execute ], - file: [ Chef::Resource::File, Chef::Provider::File ], - gem_package: [ Chef::Resource::GemPackage, Chef::Provider::Package::Rubygems ], - git: [ Chef::Resource::Git, Chef::Provider::Git ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], - homebrew_package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], - http_request: [ Chef::Resource::HttpRequest, Chef::Provider::HttpRequest ], - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], - link: [ Chef::Resource::Link, Chef::Provider::Link ], - linux_user: [ Chef::Resource::User::LinuxUser, Chef::Provider::User::Linux ], - log: [ Chef::Resource::Log, Chef::Provider::Log::ChefLog ], - macports_package: [ Chef::Resource::MacportsPackage, Chef::Provider::Package::Macports ], - mdadm: [ Chef::Resource::Mdadm, Chef::Provider::Mdadm ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Mount ], - pacman_package: [ Chef::Resource::PacmanPackage, Chef::Provider::Package::Pacman ], - paludis_package: [ Chef::Resource::PaludisPackage, Chef::Provider::Package::Paludis ], - perl: [ Chef::Resource::Perl, Chef::Provider::Script ], - portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], - pw_user: [ Chef::Resource::User::PwUser, Chef::Provider::User::Pw ], - python: [ Chef::Resource::Python, Chef::Provider::Script ], - remote_directory: [ Chef::Resource::RemoteDirectory, Chef::Provider::RemoteDirectory ], - route: [ Chef::Resource::Route, Chef::Provider::Route ], - rpm_package: [ Chef::Resource::Package::RpmPackage, Chef::Provider::Package::Rpm ], - ruby_block: [ Chef::Resource::RubyBlock, Chef::Provider::RubyBlock ], - ruby: [ Chef::Resource::Ruby, Chef::Provider::Script ], - script: [ Chef::Resource::Script, Chef::Provider::Script ], - smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], - solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], - solaris_user: [ Chef::Resource::User::SolarisUser, Chef::Provider::User::Solaris ], - subversion: [ Chef::Resource::Subversion, Chef::Provider::Subversion ], - template: [ Chef::Resource::Template, Chef::Provider::Template ], + aix_user: [ Chef::Resource::User::AixUser, Chef::Provider::User::Aix ], + apt_package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], + bash: [ Chef::Resource::Bash, Chef::Provider::Script ], + bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Bff ], + breakpoint: [ Chef::Resource::Breakpoint, Chef::Resource::Breakpoint.action_class ], + chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ], + cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ], + csh: [ Chef::Resource::Csh, Chef::Provider::Script ], + directory: [ Chef::Resource::Directory, Chef::Provider::Directory ], + dpkg_package: [ Chef::Resource::DpkgPackage, Chef::Provider::Package::Dpkg ], + dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], + dscl_user: [ Chef::Resource::User::DsclUser, Chef::Provider::User::Dscl ], + execute: [ Chef::Resource::Execute, Chef::Provider::Execute ], + file: [ Chef::Resource::File, Chef::Provider::File ], + gem_package: [ Chef::Resource::GemPackage, Chef::Provider::Package::Rubygems ], + git: [ Chef::Resource::Git, Chef::Provider::Git ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], + homebrew_package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], + http_request: [ Chef::Resource::HttpRequest, Chef::Provider::HttpRequest ], + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], + link: [ Chef::Resource::Link, Chef::Provider::Link ], + linux_user: [ Chef::Resource::User::LinuxUser, Chef::Provider::User::Linux ], + log: [ Chef::Resource::Log, Chef::Provider::Log::ChefLog ], + macports_package: [ Chef::Resource::MacportsPackage, Chef::Provider::Package::Macports ], + mdadm: [ Chef::Resource::Mdadm, Chef::Provider::Mdadm ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Mount ], + pacman_package: [ Chef::Resource::PacmanPackage, Chef::Provider::Package::Pacman ], + paludis_package: [ Chef::Resource::PaludisPackage, Chef::Provider::Package::Paludis ], + perl: [ Chef::Resource::Perl, Chef::Provider::Script ], + portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], + pw_user: [ Chef::Resource::User::PwUser, Chef::Provider::User::Pw ], + python: [ Chef::Resource::Python, Chef::Provider::Script ], + remote_directory: [ Chef::Resource::RemoteDirectory, Chef::Provider::RemoteDirectory ], + route: [ Chef::Resource::Route, Chef::Provider::Route ], + rpm_package: [ Chef::Resource::Package::RpmPackage, Chef::Provider::Package::Rpm ], + ruby_block: [ Chef::Resource::RubyBlock, Chef::Provider::RubyBlock ], + ruby: [ Chef::Resource::Ruby, Chef::Provider::Script ], + script: [ Chef::Resource::Script, Chef::Provider::Script ], + smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], + solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], + solaris_user: [ Chef::Resource::User::SolarisUser, Chef::Provider::User::Solaris ], + subversion: [ Chef::Resource::Subversion, Chef::Provider::Subversion ], + template: [ Chef::Resource::Template, Chef::Provider::Template ], whyrun_safe_ruby_block: [ Chef::Resource::WhyrunSafeRubyBlock, Chef::Provider::WhyrunSafeRubyBlock ], - windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], - windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], - windows_user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ], - yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], + windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], + windows_user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ], + yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], "linux" => { "debian" => { ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ], - package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], + package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], # service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ], "debian" => { @@ -672,7 +672,7 @@ describe Chef::ProviderResolver do "opensuse" => { # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], package: [ Chef::Resource::ZypperPackage, Chef::Provider::Package::Zypper ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], "12.3" => { }, "12.2" => { @@ -683,7 +683,7 @@ describe Chef::ProviderResolver do "gentoo" => { # TODO should be Chef::Resource::PortagePackage - package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ], + package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ], portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], # service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ], @@ -695,21 +695,21 @@ describe Chef::ProviderResolver do "rhel" => { # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ], - package: [ Chef::Resource::DnfPackage, Chef::Provider::Package::Dnf ], + package: [ Chef::Resource::DnfPackage, Chef::Provider::Package::Dnf ], ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ], %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => { "3.1.4" => { - package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], }, }, %w{redhat centos scientific oracle} => { "7.0" => { - package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], }, "6.0" => { - package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], }, }, @@ -727,7 +727,7 @@ describe Chef::ProviderResolver do "freebsd" => { "freebsd" => { group: [ Chef::Resource::Group, Chef::Provider::Group::Pw ], - user: [ Chef::Resource::User::PwUser, Chef::Provider::User::Pw ], + user: [ Chef::Resource::User::PwUser, Chef::Provider::User::Pw ], "freebsd" => { "10.3" => { @@ -738,10 +738,10 @@ describe Chef::ProviderResolver do "darwin" => { %w{mac_os_x mac_os_x_server} => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Dscl ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Dscl ], package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], osx_profile: [ Chef::Resource::OsxProfile, Chef::Provider::OsxProfile], - user: [ Chef::Resource::User::DsclUser, Chef::Provider::User::Dscl ], + user: [ Chef::Resource::User::DsclUser, Chef::Provider::User::Dscl ], "mac_os_x" => { "10.9.2" => { @@ -751,17 +751,17 @@ describe Chef::ProviderResolver do }, "windows" => { - batch: [ Chef::Resource::Batch, Chef::Provider::Batch ], - dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], - windows_env: [ Chef::Resource::WindowsEnv, Chef::Provider::WindowsEnv ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ], - package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], + batch: [ Chef::Resource::Batch, Chef::Provider::Batch ], + dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], + windows_env: [ Chef::Resource::WindowsEnv, Chef::Provider::WindowsEnv ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ], + package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], powershell_script: [ Chef::Resource::PowershellScript, Chef::Provider::PowershellScript ], - service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], - user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ], - windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], - windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], + service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], + user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ], + windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], + windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], "windows" => { %w{mswin mingw32 windows} => { @@ -822,15 +822,15 @@ describe Chef::ProviderResolver do }, "solaris2" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], - ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], - package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Solaris ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], + package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Solaris ], solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], "smartos" => { smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], - package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], + package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], "smartos" => { "3.1.4" => { @@ -892,7 +892,7 @@ describe Chef::ProviderResolver do def self.create_provider_tests(providers, test, expected, filter) expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) }) providers.each do |key, value| - if !key.is_a?(Symbol) + unless key.is_a?(Symbol) next_test = test.merge({ filter => key }) next_filter = case filter @@ -911,7 +911,7 @@ describe Chef::ProviderResolver do end end # If there is no filter, we're as deep as we need to go - if !filter + unless filter on_platform test.delete(:platform), test do expect_providers(expected) end diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb index 496871614a..d7db8e8c1c 100644 --- a/spec/unit/provider_spec.rb +++ b/spec/unit/provider_spec.rb @@ -24,8 +24,7 @@ class NoWhyrunDemonstrator < Chef::Provider false end - def load_current_resource - end + def load_current_resource; end def action_foo @system_state_altered = true @@ -39,8 +38,7 @@ class ConvergeActionDemonstrator < Chef::Provider true end - def load_current_resource - end + def load_current_resource; end def action_foo converge_by("running a state changing action") do diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 3b16edaa4a..37d36e7e74 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -94,7 +94,7 @@ describe Chef::Recipe do end end - expect(run_context.resource_collection.map { |r| r.name }).to eql(%w{monkey dog cat}) + expect(run_context.resource_collection.map(&:name)).to eql(%w{monkey dog cat}) end it "should return the new resource after creating it" do @@ -115,7 +115,7 @@ describe Chef::Recipe do node.automatic[:platform_version] = "123" res = recipe.laughter "timmy" expect(res.name).to eql("timmy") - res.kind_of?(ShaunTheSheep) + res.is_a?(ShaunTheSheep) end it "locate a resource for all platforms" do @@ -124,7 +124,7 @@ describe Chef::Recipe do YourMom.provides :love_and_caring res = recipe.love_and_caring "mommy" expect(res.name).to eql("mommy") - res.kind_of?(YourMom) + res.is_a?(YourMom) end describe "when there is more than one resource that resolves on a node" do @@ -390,7 +390,7 @@ describe Chef::Recipe do zen_master "gnome" do peace = true end - CODE + CODE expect { recipe.instance_eval(code) }.not_to raise_error expect(recipe.resources(zen_master: "gnome").name).to eql("gnome") end diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb index c161428a13..dd3082100e 100644 --- a/spec/unit/resource/batch_spec.rb +++ b/spec/unit/resource/batch_spec.rb @@ -22,7 +22,7 @@ describe Chef::Resource::Batch do let(:node) { Chef::Node.new } before(:each) do - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb index d4c94b0ac7..2a8efcdb67 100644 --- a/spec/unit/resource/chef_gem_spec.rb +++ b/spec/unit/resource/chef_gem_spec.rb @@ -53,7 +53,7 @@ describe Chef::Resource::ChefGem, "gem_binary" do end it "sets the gem_binary based on computing it from RbConfig" do - expect(resource.gem_binary).to eql("#{RbConfig::CONFIG['bindir']}/gem") + expect(resource.gem_binary).to eql("#{RbConfig::CONFIG["bindir"]}/gem") end it "sets compile_time to false by default" do diff --git a/spec/unit/resource/chocolatey_config_spec.rb b/spec/unit/resource/chocolatey_config_spec.rb index 3c50642487..b6bb0e94e7 100644 --- a/spec/unit/resource/chocolatey_config_spec.rb +++ b/spec/unit/resource/chocolatey_config_spec.rb @@ -35,7 +35,7 @@ describe Chef::Resource::ChocolateyConfig do </features> <apiKeys /> </chocolatey> -CONFIG + CONFIG end # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs diff --git a/spec/unit/resource/chocolatey_source_spec.rb b/spec/unit/resource/chocolatey_source_spec.rb index 237eb5b787..0d786e0988 100644 --- a/spec/unit/resource/chocolatey_source_spec.rb +++ b/spec/unit/resource/chocolatey_source_spec.rb @@ -35,7 +35,7 @@ describe Chef::Resource::ChocolateySource do </features> <apiKeys /> </chocolatey> -CONFIG + CONFIG end # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb index 3dd68211db..0c0c0d8287 100644 --- a/spec/unit/resource/directory_spec.rb +++ b/spec/unit/resource/directory_spec.rb @@ -38,7 +38,7 @@ describe Chef::Resource::Directory do it "accepts a string as the path" do expect { resource.path "/tmp" }.not_to raise_error expect(resource.path).to eql("/tmp") - expect { resource.path Hash.new }.to raise_error(ArgumentError) + expect { resource.path({}) }.to raise_error(ArgumentError) end it "allows you to have specify whether the action is recursive with true/false" do diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb index f4262a0396..70d949c340 100644 --- a/spec/unit/resource/dnf_package_spec.rb +++ b/spec/unit/resource/dnf_package_spec.rb @@ -64,7 +64,7 @@ describe Chef::Resource::DnfPackage, "flush_cache" do end it "allows you to set the flush timing with an array" do - flush_array = [ :before, :after ] + flush_array = %i{before after} flush_hash = { before: true, after: true } resource.flush_cache(flush_array) expect(resource.flush_cache).to eq(flush_hash) diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb index 04e1305163..e0beb309ab 100644 --- a/spec/unit/resource/dsc_resource_spec.rb +++ b/spec/unit/resource/dsc_resource_spec.rb @@ -41,7 +41,7 @@ describe Chef::Resource::DscResource do end it "has an ed_actions property with only the `:run` and `:nothing` properties" do - expect(dsc_test_resource.allowed_actions.to_set).to eq([:run, :nothing].to_set) + expect(dsc_test_resource.allowed_actions.to_set).to eq(%i{run nothing}.to_set) end it "allows the resource property to be set" do diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index f0ec999019..57c58249eb 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -128,8 +128,7 @@ describe Chef::Resource::File::Verification do before(:each) do class Chef::Resource::File::Verification::Turtle < Chef::Resource::File::Verification provides :cats - def verify(path, opts) - end + def verify(path, opts); end end allow(Chef::Resource::File::Verification::Turtle).to receive(:new).and_return(registered_verification) end diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb index 54dc8ab92b..b49fc4564b 100644 --- a/spec/unit/resource/file_spec.rb +++ b/spec/unit/resource/file_spec.rb @@ -85,7 +85,7 @@ describe Chef::Resource::File do it "accepts a string as the path" do expect { resource.path "/tmp" }.not_to raise_error expect(resource.path).to eql("/tmp") - expect { resource.path Hash.new }.to raise_error(ArgumentError) + expect { resource.path({}) }.to raise_error(ArgumentError) end describe "when it has a path, owner, group, mode, and checksum" do diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 6d9df79299..ae7103b9b5 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -96,7 +96,7 @@ end describe Chef::Resource::Group, "members" do let(:resource) { Chef::Resource::Group.new("fakey_fakerton") } - [ :users, :members].each do |method| + %i{users members}.each do |method| it "(#{method}) allows a String and coerces it to an Array" do resource.send(method, "some_user") expect(resource.send(method)).to eql(["some_user"]) diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb index 05a39835d8..ae32e4aa30 100644 --- a/spec/unit/resource/link_spec.rb +++ b/spec/unit/resource/link_spec.rb @@ -63,7 +63,7 @@ describe Chef::Resource::Link do end it "does not accept a Hash for the link source via 'to'" do - expect { resource.to Hash.new }.to raise_error(ArgumentError) + expect { resource.to({}) }.to raise_error(ArgumentError) end it "allows you to set a link source via 'to'" do diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb index 41a6071893..5653044358 100644 --- a/spec/unit/resource/osx_profile_spec.rb +++ b/spec/unit/resource/osx_profile_spec.rb @@ -21,7 +21,8 @@ require "spec_helper" describe Chef::Resource::OsxProfile do let(:resource) do Chef::Resource::OsxProfile.new( - "fakey_fakerton") + "fakey_fakerton" + ) end it "has a resource name of profile" do diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index c4f468e419..107fd79419 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -23,7 +23,7 @@ describe Chef::Resource::PowershellScript do before(:each) do node = Chef::Node.new - node.default["kernel"] = Hash.new + node.default["kernel"] = {} node.default["kernel"][:machine] = :x86_64.to_s node.automatic[:os] = "windows" @@ -61,7 +61,7 @@ describe Chef::Resource::PowershellScript do it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated properties from a parent resource class" do inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes - - [:cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated ] + %i{cwd environment group path user umask architecture elevated} expect(inherited_difference).to eq([]) end @@ -87,7 +87,8 @@ describe Chef::Resource::PowershellScript do it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" } + ).and_return(Proc.new {}) resource.only_if("$true") end @@ -98,21 +99,24 @@ describe Chef::Resource::PowershellScript do file_resource.guard_interpreter :powershell_script allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" } + ).and_return(Proc.new {}) resource.only_if("$true") end it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }.merge(guard_parameters) + ).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do guard_parameters = { cwd: "/etc/chef", convert_boolean_return: true, architecture: :x86_64 } allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {}) + { convert_boolean_return: true, code: "$true" }.merge(guard_parameters) + ).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end @@ -120,7 +124,8 @@ describe Chef::Resource::PowershellScript do other_guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 } parameters_with_boolean_disabled = other_guard_parameters.merge({ convert_boolean_return: false, code: "$true" }) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( - parameters_with_boolean_disabled).and_return(Proc.new {}) + parameters_with_boolean_disabled + ).and_return(Proc.new {}) resource.only_if("$true", parameters_with_boolean_disabled) end end diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 47d624a758..c674e3eddd 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -152,7 +152,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end it "does not allow an array" do - expect { resource.recursive([:nose, :chin]) }.to raise_error(ArgumentError) + expect { resource.recursive(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do @@ -167,7 +167,7 @@ end describe Chef::Resource::RegistryKey, "architecture" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } - [ :i386, :x86_64, :machine ].each do |arch| + %i{i386 x86_64 machine}.each do |arch| it "allows #{arch} as a symbol" do resource.architecture(arch) expect(resource.architecture).to eql(arch) @@ -183,7 +183,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end it "does not allow an array" do - expect { resource.architecture([:nose, :chin]) }.to raise_error(ArgumentError) + expect { resource.architecture(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do diff --git a/spec/unit/resource/rhsm_subscription_spec.rb b/spec/unit/resource/rhsm_subscription_spec.rb index 6de65a427f..00d61c9ff5 100644 --- a/spec/unit/resource/rhsm_subscription_spec.rb +++ b/spec/unit/resource/rhsm_subscription_spec.rb @@ -74,7 +74,7 @@ describe Chef::Resource::RhsmSubscription do Pool ID: pool2 Serial: serial2 Key2: value2 -EOL + EOL end it "parses the output correctly" do diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 963c2b2d89..a9f09d3dca 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -173,7 +173,7 @@ describe Chef::Resource::Service do end it "allows you to set what features this resource supports as a array" do - support_array = [ :status, :restart ] + support_array = %i{status restart} support_hash = { status: true, restart: true } resource.supports(support_array) expect(resource.supports).to eq(support_hash) diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb index 9ca1f7617f..2f8e234c85 100644 --- a/spec/unit/resource/template_spec.rb +++ b/spec/unit/resource/template_spec.rb @@ -147,7 +147,7 @@ describe Chef::Resource::Template do end it "compiles helper methods with arguments into a module" do - resource.helper(:shout) { |quiet| quiet.upcase } + resource.helper(:shout, &:upcase) modules = resource.helper_modules o = Object.new modules.each { |m| o.extend(m) } @@ -186,7 +186,7 @@ describe Chef::Resource::Template do end it "raises an error when no block or module name is given for helpers definition" do - expect { resource.helpers() }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { resource.helpers }.to raise_error(Chef::Exceptions::ValidationFailed) end it "raises an error when a non-module is given for helpers definition" do diff --git a/spec/unit/resource/windows_env_spec.rb b/spec/unit/resource/windows_env_spec.rb index 06b5af630a..3ba5b18881 100644 --- a/spec/unit/resource/windows_env_spec.rb +++ b/spec/unit/resource/windows_env_spec.rb @@ -47,7 +47,7 @@ describe Chef::Resource::WindowsEnv do end it "does not accept a Hash for the env value via 'to'" do - expect { resource.value Hash.new }.to raise_error(ArgumentError) + expect { resource.value({}) }.to raise_error(ArgumentError) end it "allows you to set an env value via 'to'" do diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb index 8648b52a17..31cf5966e8 100644 --- a/spec/unit/resource/windows_service_spec.rb +++ b/spec/unit/resource/windows_service_spec.rb @@ -69,11 +69,11 @@ describe Chef::Resource::WindowsService, "initialize" do # Properties that are Strings %i{description service_name binary_path_name load_order_group dependencies run_as_user run_as_password display_name}.each do |prop| - it "support setting #{prop}" do - resource.send("#{prop}=", "some value") - expect(resource.send(prop)).to eq("some value") - end - end + it "support setting #{prop}" do + resource.send("#{prop}=", "some value") + expect(resource.send(prop)).to eq("some value") + end + end # Properties that are Integers %i{desired_access error_control service_type}.each do |prop| diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb index 96482d3d56..ac4b2b8c99 100644 --- a/spec/unit/resource/windows_task_spec.rb +++ b/spec/unit/resource/windows_task_spec.rb @@ -352,7 +352,7 @@ describe Chef::Resource::WindowsTask, :windows_only do context "#validate_idle_time" do it "raises error if frequency is not :on_idle" do - [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency| + %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency| expect { resource.send(:validate_idle_time, 5, frequency) }.to raise_error(ArgumentError, "idle_time property is only valid for tasks that run on_idle") end end @@ -370,7 +370,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end it "does not raises error if idle_time is not set for other frequencies" do - [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency| + %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency| expect { resource.send(:validate_idle_time, nil, frequency) }.not_to raise_error end end diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb index 0b79a447a3..d0383a8cec 100644 --- a/spec/unit/resource/yum_package_spec.rb +++ b/spec/unit/resource/yum_package_spec.rb @@ -95,7 +95,7 @@ describe Chef::Resource::YumPackage, "flush_cache" do end it "should allow you to set the flush timing with an array" do - flush_array = [ :before, :after ] + flush_array = %i{before after} flush_hash = { before: true, after: true } @resource.flush_cache(flush_array) expect(@resource.flush_cache).to eq(flush_hash) diff --git a/spec/unit/resource_collection/resource_list_spec.rb b/spec/unit/resource_collection/resource_list_spec.rb index dabb8f037d..05363c20b1 100644 --- a/spec/unit/resource_collection/resource_list_spec.rb +++ b/spec/unit/resource_collection/resource_list_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Chef::ResourceCollection::ResourceList do - let(:resource_list) { Chef::ResourceCollection::ResourceList.new() } + let(:resource_list) { Chef::ResourceCollection::ResourceList.new } let(:resource) { Chef::Resource::ZenMaster.new("makoto") } let(:second_resource) { Chef::Resource::ZenMaster.new("hattori") } diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb index 403be4c566..30a55cd3e1 100644 --- a/spec/unit/resource_collection/resource_set_spec.rb +++ b/spec/unit/resource_collection/resource_set_spec.rb @@ -92,7 +92,7 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master) collection.insert_as(zen_follower) check_by_names(collection.find(zen_master: [zen_master_name], zen_follower: [zen_follower_name]), - zen_master_name, zen_follower_name) + zen_master_name, zen_follower_name) end it "should find resources of multiple kinds (:zen_master => a, :zen_follower => b with custom names)" do @@ -100,7 +100,7 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master2, :zzz, "name2") collection.insert_as(zen_follower, :yyy, "name3") check_by_names(collection.find(zzz: %w{name1 name2}, yyy: ["name3"]), - zen_master_name, zen_follower_name, zen_master2_name) + zen_master_name, zen_follower_name, zen_master2_name) end it "should find a resource by string zen_master[a]" do @@ -118,7 +118,7 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master) collection.insert_as(zen_master2) check_by_names(collection.find("zen_master[#{zen_master_name},#{zen_master2_name}]"), - zen_master_name, zen_master2_name) + zen_master_name, zen_master2_name) end it "should find array names" do @@ -138,14 +138,14 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master, :zzz, "name1") collection.insert_as(zen_master2, :zzz, "name2") check_by_names(collection.find("zzz[name1,name2]"), - zen_master_name, zen_master2_name) + zen_master_name, zen_master2_name) end it "should find resources of multiple types by strings of zen_master[a]" do collection.insert_as(zen_master) collection.insert_as(zen_follower) check_by_names(collection.find("zen_master[#{zen_master_name}]", "zen_follower[#{zen_follower_name}]"), - zen_master_name, zen_follower_name) + zen_master_name, zen_follower_name) end it "should find resources of multiple types by strings of zen_master[a] with custom names" do @@ -154,7 +154,7 @@ describe Chef::ResourceCollection::ResourceSet do collection.insert_as(zen_master2, :zzz, "name2") collection.insert_as(zen_follower, :yyy, "name3") check_by_names(collection.find("zzz[name1,name2]", "yyy[name3]"), - zen_master_name, zen_follower_name, zen_master2_name) + zen_master_name, zen_follower_name, zen_master2_name) end it "should only keep the last copy when multiple instances of a Resource are inserted" do @@ -172,7 +172,7 @@ describe Chef::ResourceCollection::ResourceSet do end it "should raise an exception if you pass something other than a string or hash to resource" do - expect { collection.find([Array.new]) }.to raise_error(ArgumentError) + expect { collection.find([[]]) }.to raise_error(ArgumentError) end it "raises an error when attempting to find a resource that does not exist" do diff --git a/spec/unit/resource_collection/stepable_iterator_spec.rb b/spec/unit/resource_collection/stepable_iterator_spec.rb index 6354b1b7fb..ec831c9afe 100644 --- a/spec/unit/resource_collection/stepable_iterator_spec.rb +++ b/spec/unit/resource_collection/stepable_iterator_spec.rb @@ -72,7 +72,7 @@ describe Chef::ResourceCollection::StepableIterator do @collection << lambda { @snitch_var = 42 } @iterator = CRSI.for_collection(@collection) - @iterator.each { |proc| proc.call } + @iterator.each(&:call) end it "allows the iteration to be paused" do @@ -124,7 +124,7 @@ describe Chef::ResourceCollection::StepableIterator do it "allows the iteration to start by being stepped" do @snitch_var = nil @iterator = CRSI.for_collection(@collection) - @iterator.iterate_on(:element) { |proc| proc.call } + @iterator.iterate_on(:element, &:call) @iterator.step expect(@iterator.position).to eq(1) expect(@snitch_var).to eq(23) diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb index 7f59246a88..60f17b6934 100644 --- a/spec/unit/resource_collection_spec.rb +++ b/spec/unit/resource_collection_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::ResourceCollection do - let(:rc) { Chef::ResourceCollection.new() } + let(:rc) { Chef::ResourceCollection.new } let(:resource) { Chef::Resource::ZenMaster.new("makoto") } it "should throw an error when calling a non-delegated method" do @@ -97,7 +97,7 @@ describe Chef::ResourceCollection do describe "each" do it "should allow you to iterate over every resource in the collection" do load_up_resources - results = Array.new + results = [] expect do rc.each do |r| results << r.name @@ -119,7 +119,7 @@ describe Chef::ResourceCollection do describe "each_index" do it "should allow you to iterate over every resource by index" do load_up_resources - results = Array.new + results = [] expect do rc.each_index do |i| results << rc[i].name @@ -246,7 +246,7 @@ describe Chef::ResourceCollection do end it "should raise an exception if you pass something other than a string or hash to resource" do - expect { rc.resources([Array.new]) }.to raise_error(ArgumentError) + expect { rc.resources([[]]) }.to raise_error(ArgumentError) end it "raises an error when attempting to find a resource that does not exist" do diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb index 5be3e59009..a1c59eaaca 100644 --- a/spec/unit/resource_definition_spec.rb +++ b/spec/unit/resource_definition_spec.rb @@ -19,7 +19,7 @@ require "spec_helper" describe Chef::ResourceDefinition do - let(:defn) { Chef::ResourceDefinition.new() } + let(:defn) { Chef::ResourceDefinition.new } describe "initialize" do it "should be a Chef::ResourceDefinition" do @@ -92,7 +92,7 @@ describe Chef::ResourceDefinition do it "should raise an exception if prototype_params is not a hash" do expect do - defn.define :monkey, Array.new do + defn.define :monkey, [] do end end.to raise_error(ArgumentError) end diff --git a/spec/unit/resource_inspector_spec.rb b/spec/unit/resource_inspector_spec.rb index aef92732b3..c0852be3b2 100644 --- a/spec/unit/resource_inspector_spec.rb +++ b/spec/unit/resource_inspector_spec.rb @@ -39,7 +39,7 @@ describe ResourceInspector do it "returns a hash with required data" do expect(subject[:description]).to eq "A dummy resource" - expect(subject[:actions]).to match_array [:nothing, :dummy] + expect(subject[:actions]).to match_array %i{nothing dummy} end context "excluding built in properties" do diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb index cec931dd70..a2d814fca0 100644 --- a/spec/unit/resource_reporter_spec.rb +++ b/spec/unit/resource_reporter_spec.rb @@ -619,7 +619,7 @@ describe Chef::ResourceReporter do expect(@rest_client).to receive(:post) .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, - { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) + { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) .and_raise(@error) end @@ -648,7 +648,7 @@ describe Chef::ResourceReporter do @error = Net::HTTPClientException.new("500 message", @response) expect(@rest_client).to receive(:post) .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, - { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) + { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) .and_raise(@error) end @@ -678,7 +678,7 @@ describe Chef::ResourceReporter do @error = Net::HTTPClientException.new("500 message", @response) expect(@rest_client).to receive(:post) .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, - { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) + { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) .and_raise(@error) end @@ -699,7 +699,7 @@ describe Chef::ResourceReporter do response = { "uri" => "https://example.com/reports/nodes/spitfire/runs/@run_id" } expect(@rest_client).to receive(:post) .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s }, - { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) + { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }) .and_return(response) @resource_reporter.run_started(@run_status) end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index b1b639d823..ae481108d8 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -115,14 +115,14 @@ describe Chef::Resource do it "sets a list of state attributes" do resource_class = Class.new(Chef::Resource) resource_class.state_attrs(:checksum, :owner, :group, :mode) - expect(resource_class.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_class.state_attrs).to match_array(%i{checksum owner group mode}) end it "inherits state attributes from the superclass" do resource_class = Class.new(Chef::Resource) resource_subclass = Class.new(resource_class) resource_class.state_attrs(:checksum, :owner, :group, :mode) - expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode}) end it "combines inherited state attributes with non-inherited state attributes" do @@ -130,7 +130,7 @@ describe Chef::Resource do resource_subclass = Class.new(resource_class) resource_class.state_attrs(:checksum, :owner) resource_subclass.state_attrs(:group, :mode) - expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode}) end end @@ -157,7 +157,7 @@ describe Chef::Resource do it "describes its state" do resource_state = file_resource.state_for_resource_reporter - expect(resource_state.keys).to match_array([:checksum, :owner, :group, :mode]) + expect(resource_state.keys).to match_array(%i{checksum owner group mode}) expect(resource_state[:checksum]).to eq("abc123") expect(resource_state[:owner]).to eq("root") expect(resource_state[:group]).to eq("wheel") @@ -410,7 +410,7 @@ describe Chef::Resource do resource "foo" do foo foo end - EOH + EOH end end @@ -510,11 +510,11 @@ describe Chef::Resource do context "when the resource has a property with a default" do let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } } it "should include the default in the hash" do - expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, - :name, :source_line, - :action, :elapsed_time, - :default_guard_interpreter, :guard_interpreter].sort) + expect(resource.to_hash.keys.sort).to eq(%i{a allowed_actions params provider updated + updated_by_last_action before + name source_line + action elapsed_time + default_guard_interpreter guard_interpreter}.sort) expect(resource.to_hash[:name]).to eq "funk" expect(resource.to_hash[:a]).to eq 1 end @@ -522,11 +522,11 @@ describe Chef::Resource do it "should convert to a hash" do hash = resource.to_hash - expected_keys = [ :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, - :name, :source_line, - :action, :elapsed_time, - :default_guard_interpreter, :guard_interpreter ] + expected_keys = %i{allowed_actions params provider updated + updated_by_last_action before + name source_line + action elapsed_time + default_guard_interpreter guard_interpreter} expect(hash.keys - expected_keys).to eq([]) expect(expected_keys - hash.keys).to eq([]) expect(hash[:name]).to eql("funk") @@ -838,7 +838,7 @@ describe Chef::Resource do it "should print \"skipped due to action :nothing\" message for doc formatter when action is :nothing" do fdoc = Chef::Formatters.new(:doc, STDOUT, STDERR) allow(run_context).to receive(:events).and_return(fdoc) - expect(fdoc).to receive(:puts).with(" (skipped due to action :nothing)", anything()) + expect(fdoc).to receive(:puts).with(" (skipped due to action :nothing)", anything) resource.should_skip?(:nothing) end @@ -1118,8 +1118,8 @@ describe Chef::Resource do end context "with an array action" do - before { resource.action([:two, :one]) } - it { is_expected.to eq [:two, :one] } + before { resource.action(%i{two one}) } + it { is_expected.to eq %i{two one} } end context "with an assignment" do @@ -1128,8 +1128,8 @@ describe Chef::Resource do end context "with an array assignment" do - before { resource.action = [:two, :one] } - it { is_expected.to eq [:two, :one] } + before { resource.action = %i{two one} } + it { is_expected.to eq %i{two one} } end context "with an invalid action" do @@ -1166,8 +1166,8 @@ describe Chef::Resource do end context "with an array default action" do - let(:default_action) { [:two, :one] } - it { is_expected.to eq [:two, :one] } + let(:default_action) { %i{two one} } + it { is_expected.to eq %i{two one} } end end diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 57f1d5c6ba..153e7791ee 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -113,7 +113,7 @@ describe Chef::Role do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @role.default_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @role.default_attributes([]) }.to raise_error(ArgumentError) end end @@ -128,7 +128,7 @@ describe Chef::Role do end it "should throw an ArgumentError if we aren't a kind of hash" do - expect { @role.override_attributes(Array.new) }.to raise_error(ArgumentError) + expect { @role.override_attributes([]) }.to raise_error(ArgumentError) end end @@ -248,7 +248,7 @@ describe Chef::Role do ROLE_DSL = <<~EOR.freeze name "ceiling_cat" description "like Aliens, but furry" -EOR + EOR describe "when loading from disk" do before do diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb index e93088cd5f..75e91d0072 100644 --- a/spec/unit/run_context/cookbook_compiler_spec.rb +++ b/spec/unit/run_context/cookbook_compiler_spec.rb @@ -107,7 +107,7 @@ describe Chef::RunContext::CookbookCompiler do node.run_list("test-with-deps::default", "test-with-circular-deps::default") compiler.compile_libraries - expect(LibraryLoadOrder.load_order).to eq(["dependency1", "dependency2", "test-with-deps", "circular-dep2", "circular-dep1", "test-with-circular-deps"]) + expect(LibraryLoadOrder.load_order).to eq(%w{dependency1 dependency2 test-with-deps circular-dep2 circular-dep1 test-with-circular-deps}) end end @@ -121,18 +121,18 @@ describe Chef::RunContext::CookbookCompiler do node.run_list("test-with-deps::default", "test-with-circular-deps::default") compiler.compile_lwrps - expect(LibraryLoadOrder.load_order).to eq(["dependency1-provider", - "dependency1-resource", - "dependency2-provider", - "dependency2-resource", - "test-with-deps-provider", - "test-with-deps-resource", - "circular-dep2-provider", - "circular-dep2-resource", - "circular-dep1-provider", - "circular-dep1-resource", - "test-with-circular-deps-provider", - "test-with-circular-deps-resource"]) + expect(LibraryLoadOrder.load_order).to eq(%w{dependency1-provider + dependency1-resource + dependency2-provider + dependency2-resource + test-with-deps-provider + test-with-deps-resource + circular-dep2-provider + circular-dep2-resource + circular-dep1-provider + circular-dep1-resource + test-with-circular-deps-provider + test-with-circular-deps-resource}) end end @@ -147,12 +147,12 @@ describe Chef::RunContext::CookbookCompiler do node.run_list("test-with-deps::default", "test-with-circular-deps::default") compiler.compile_resource_definitions - expect(LibraryLoadOrder.load_order).to eq(["dependency1-definition", - "dependency2-definition", - "test-with-deps-definition", - "circular-dep2-definition", - "circular-dep1-definition", - "test-with-circular-deps-definition"]) + expect(LibraryLoadOrder.load_order).to eq(%w{dependency1-definition + dependency2-definition + test-with-deps-definition + circular-dep2-definition + circular-dep1-definition + test-with-circular-deps-definition}) end end @@ -205,14 +205,14 @@ describe Chef::RunContext::CookbookCompiler do it "should return an array of cookbook names as symbols without duplicates" do node.run_list("test-with-circular-deps::default", "circular-dep1::default", "circular-dep2::default") - expect(compiler.cookbook_order).to eq([:"circular-dep2", - :"circular-dep1", - :"test-with-circular-deps"]) + expect(compiler.cookbook_order).to eq(%i{circular-dep2 + circular-dep1 + test-with-circular-deps}) end it "determines if a cookbook is in the list of cookbooks reachable by dependency" do node.run_list("test-with-deps::default", "test-with-deps::server") - expect(compiler.cookbook_order).to eq([:dependency1, :dependency2, :"test-with-deps"]) + expect(compiler.cookbook_order).to eq(%i{dependency1 dependency2 test-with-deps}) expect(compiler.unreachable_cookbook?(:dependency1)).to be_falsey expect(compiler.unreachable_cookbook?(:dependency2)).to be_falsey expect(compiler.unreachable_cookbook?(:'test-with-deps')).to be_falsey diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb index 3a39bc79cc..4ddc75f002 100644 --- a/spec/unit/run_list/run_list_expansion_spec.rb +++ b/spec/unit/run_list/run_list_expansion_spec.rb @@ -94,12 +94,15 @@ describe Chef::RunList::RunListExpansion do allow(@expansion).to receive(:fetch_role).and_return(@first_role, @second_role) @expansion.expand @json = '{"id":"_default","run_list":[{"type":"recipe","name":"lobster::mastercookbook","version":"0.1.0",' - .concat( -'"skipped":false},{"type":"role","name":"rage","children":[{"type":"role","name":"mollusk","children":[],"missing":null,' - .concat( -'"error":null,"skipped":null},{"type":"recipe","name":"crabrevenge","version":null,"skipped":false}],"missing":null,' - .concat( -'"error":null,"skipped":null},{"type":"recipe","name":"fist","version":"0.1","skipped":false}]}'))) + .concat( + '"skipped":false},{"type":"role","name":"rage","children":[{"type":"role","name":"mollusk","children":[],"missing":null,' + .concat( + '"error":null,"skipped":null},{"type":"recipe","name":"crabrevenge","version":null,"skipped":false}],"missing":null,' + .concat( + '"error":null,"skipped":null},{"type":"recipe","name":"fist","version":"0.1","skipped":false}]}' + ) + ) + ) end diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index ac062c665d..5dc877ad9a 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -133,7 +133,7 @@ describe Chef::RunList do it "should yield each member to your block" do @run_list << "foo" @run_list << "bar" - seen = Array.new + seen = [] @run_list.each { |r| seen << r } expect(seen).to be_include("recipe[foo]") expect(seen).to be_include("recipe[bar]") diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index 1effe3157c..ffb0cd523f 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -295,7 +295,7 @@ describe Chef::Runner do # execution, and schedule delayed actions :second and :third on the first # resource. The duplicate actions should "collapse" to a single notification # and order should be preserved. - expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third}) end it "executes delayed notifications in the order they were declared" do @@ -321,7 +321,7 @@ describe Chef::Runner do third_resource.notifies(:third_action, first_resource, :delayed) runner.converge - expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third}) end it "does not fire notifications if the resource was not updated by the last action executed" do @@ -347,7 +347,7 @@ describe Chef::Runner do runner.converge # All of the resources should only fire once: - expect(SnitchyProvider.all_actions_called).to eq([:first, :second, :third]) + expect(SnitchyProvider.all_actions_called).to eq(%i{first second third}) # all of the resources should be marked as updated for reporting purposes expect(first_resource).to be_updated diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index 151fcb51b3..83f988911c 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -149,7 +149,8 @@ describe Chef::Search::Query do ], "start" => 0, "total" => 4, - } end + } + end let(:big_response_empty) do { @@ -169,7 +170,7 @@ describe Chef::Search::Query do it "accepts a type as the first argument" do expect { query.search("node") }.not_to raise_error expect { query.search(:node) }.not_to raise_error - expect { query.search(Hash.new) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/) + expect { query.search({}) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/) end it "queries for every object of a type by default" do diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb index bcce7c1a08..7ca5f74bef 100644 --- a/spec/unit/shell/model_wrapper_spec.rb +++ b/spec/unit/shell/model_wrapper_spec.rb @@ -57,7 +57,7 @@ describe Shell::ModelWrapper do end it "maps the listed nodes when given a block" do - expect(@wrapper.all { |n| n.name }.sort.reverse).to eq(%w{yummy sammich}) + expect(@wrapper.all(&:name).sort.reverse).to eq(%w{yummy sammich}) end end diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb index 2e32e6547d..c98989491d 100644 --- a/spec/unit/shell/shell_session_spec.rb +++ b/spec/unit/shell/shell_session_spec.rb @@ -57,8 +57,7 @@ describe Shell::ClientSession do load_node: true, build_node: true, register: true, - sync_cookbooks: {} - ) + sync_cookbooks: {}) end before do @@ -94,8 +93,7 @@ describe Shell::SoloSession do load_node: true, build_node: true, register: true, - sync_cookbooks: {} - ) + sync_cookbooks: {}) end before do @@ -132,8 +130,7 @@ describe Shell::StandAloneSession do load_node: true, build_node: true, register: true, - sync_cookbooks: {} - ) + sync_cookbooks: {}) end let(:recipe) { Chef::Recipe.new(nil, nil, run_context) } let(:run_context) { Chef::RunContext.new(node, {}, events) } @@ -238,11 +235,11 @@ describe Shell::SoloLegacySession do it "passes the shell CLI args to the client" do @client = double("Chef::Client.new", - run_ohai: true, - load_node: true, - build_node: true, - register: true, - sync_cookbooks: {}) + run_ohai: true, + load_node: true, + build_node: true, + register: true, + sync_cookbooks: {}) expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(@client) @session.json_configuration = json_attribs @session.send(:rebuild_node) diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb index 8ba1afa72a..aa573706b1 100644 --- a/spec/unit/shell_spec.rb +++ b/spec/unit/shell_spec.rb @@ -30,8 +30,7 @@ ObjectTestHarness = Proc.new do end desc "rspecin'" - def rspec_method - end + def rspec_method; end end class TestJobManager diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 48dbf010e9..492dc147d9 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -65,7 +65,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @user.name Hash.new }.to raise_error(ArgumentError) + expect { @user.name({}) }.to raise_error(ArgumentError) end end @@ -84,7 +84,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it anything but true or false" do - expect { @user.name Hash.new }.to raise_error(ArgumentError) + expect { @user.name({}) }.to raise_error(ArgumentError) end end @@ -99,7 +99,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.public_key Hash.new }.to raise_error(ArgumentError) + expect { @user.public_key({}) }.to raise_error(ArgumentError) end end @@ -114,7 +114,7 @@ describe Chef::User do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.private_key Hash.new }.to raise_error(ArgumentError) + expect { @user.private_key({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb index 37b2252492..4bde7278fe 100644 --- a/spec/unit/user_v1_spec.rb +++ b/spec/unit/user_v1_spec.rb @@ -37,7 +37,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it something lame" do - expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError) + expect { @user.send(method, {}) }.to raise_error(ArgumentError) end end @@ -57,7 +57,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it anything but true or false" do - expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError) + expect { @user.send(method, {}) }.to raise_error(ArgumentError) end end @@ -95,7 +95,7 @@ describe Chef::UserV1 do end it "should throw an ArgumentError if you feed it anything but a string" do - expect { @user.username Hash.new }.to raise_error(ArgumentError) + expect { @user.username({}) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index 8bc68ec160..3a9a45b841 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -110,7 +110,7 @@ describe Chef::Util::Backup do end it "should strip the drive letter off for windows" do expect(@backup).to receive(:path).and_return('c:\a\b\c.txt') - expect(@backup.send(:backup_filename)).to match(%r|^\\a\\b\\c.txt.chef-\d{14}.\d{6}$|) + expect(@backup.send(:backup_filename)).to match(/^\\a\\b\\c.txt.chef-\d{14}.\d{6}$/) end it "should strip the drive letter off for windows (with forwardslashes)" do expect(@backup).to receive(:path).and_return("c:/a/b/c.txt") diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb index 32e5c0e07f..6ced178bf1 100644 --- a/spec/unit/util/dsc/lcm_output_parser_spec.rb +++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb @@ -52,7 +52,7 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser do logtype: [machinename]: LCM: [ Start Resource ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources.length).to eq(1) expect(resources[0].name).to eq("[name]") @@ -66,7 +66,7 @@ EOF logtype: [machinename]: LCM: [ End Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].changes_state?).to be_truthy end @@ -80,7 +80,7 @@ EOF logtype: [machinename]: LCM: [ End Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"]) end @@ -92,7 +92,7 @@ EOF logtype: [machinename]: LCM: [ Skip Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].changes_state?).to be_falsey end @@ -104,7 +104,7 @@ EOF logtype: [machinename]: LCM: [ Skip Set ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].change_log).to be_empty end @@ -118,7 +118,7 @@ EOF ResourcesNotInDesiredState: [name] ReturnValue : 0 PSComputerName : . -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) expect(resources.length).to eq(1) expect(resources[0].name).to eq("[name]") @@ -131,7 +131,7 @@ EOF ResourcesNotInDesiredState: [name] ReturnValue : 0 PSComputerName : . -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) expect(resources[0].changes_state?).to be_truthy end @@ -143,7 +143,7 @@ EOF ResourcesNotInDesiredState: ReturnValue : 0 PSComputerName : . -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) expect(resources[0].changes_state?).to be_falsey end @@ -155,7 +155,7 @@ EOF ResourcesNotInDesiredState: ReturnValue : 0 PSComputerName : . -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) expect(resources[0].change_log).to be_empty end @@ -176,7 +176,7 @@ EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ End Set ] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].changes_state?).to be_falsey @@ -197,7 +197,7 @@ EOF logtype: [machinename]: LCM: [ End Set ] logtype: [machinename]: LCM: [ End Resource ] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].changes_state?).to be_falsey @@ -217,7 +217,7 @@ EOF logtype: [machinename]: LCM: [ End Set ] logtype: [machinename]: LCM: [ End Resource ] logtype: [machinename]: LCM: [ End Set ] -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false) expect(resources[0].changes_state?).to be_truthy expect(resources[0].name).to eql("[name]") @@ -239,7 +239,7 @@ EOF ResourcesNotInDesiredState: [name2] ReturnValue : 0 PSComputerName : . -EOF + EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true) expect(resources[0].changes_state?).to be_falsey diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb index cce5a39537..4ef6abdd59 100644 --- a/spec/unit/util/dsc/local_configuration_manager_spec.rb +++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb @@ -29,7 +29,7 @@ describe Chef::Util::DSC::LocalConfigurationManager do logtype: [machinename]: LCM: [ Start Resource ] [name] logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] -EOH + EOH end let(:no_whatif_lcm_output) do @@ -40,13 +40,13 @@ EOH + ~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand -EOH + EOH end let(:dsc_resource_import_failure_output) do <<~EOH PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : . -EOH + EOH end let(:lcm_status) do diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb index e53bc9662a..ac851a835e 100644 --- a/spec/unit/util/editor_spec.rb +++ b/spec/unit/util/editor_spec.rb @@ -9,7 +9,7 @@ describe Chef::Util::Editor do end it "makes a copy of an Array" do - array = Array.new + array = [] editor = described_class.new(array) expect(editor.lines).to_not be(array) end diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb index 6f65174d15..65207d5dfb 100644 --- a/spec/unit/util/powershell/ps_credential_spec.rb +++ b/spec/unit/util/powershell/ps_credential_spec.rb @@ -29,8 +29,9 @@ describe Chef::Util::Powershell::PSCredential do it "should create the script to create a PSCredential when calling" do allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted") expect(ps_credential.to_psobject).to eq( - "New-Object System.Management.Automation.PSCredential("\ - "'#{username}',('encrypted' | ConvertTo-SecureString))") + "New-Object System.Management.Automation.PSCredential("\ + "'#{username}',('encrypted' | ConvertTo-SecureString))" + ) end end diff --git a/spec/unit/util/threaded_job_queue_spec.rb b/spec/unit/util/threaded_job_queue_spec.rb index 8a89943a8a..48a34bce31 100644 --- a/spec/unit/util/threaded_job_queue_spec.rb +++ b/spec/unit/util/threaded_job_queue_spec.rb @@ -22,7 +22,7 @@ describe Chef::Util::ThreadedJobQueue do let(:queue) { Chef::Util::ThreadedJobQueue.new } it "should pass mutex to jobs with an arity of 1" do - job = double() + job = double expect(job).to receive(:arity).at_least(:once).and_return(1) expect(job).to receive(:call).exactly(5).times.with(an_instance_of(Mutex)) @@ -31,7 +31,7 @@ describe Chef::Util::ThreadedJobQueue do end it "should pass nothing to jobs with an arity of 0" do - job = double() + job = double expect(job).to receive(:arity).at_least(:once).and_return(0) expect(job).to receive(:call).exactly(5).times.with(no_args) diff --git a/spec/unit/version_class_spec.rb b/spec/unit/version_class_spec.rb index 5543fbe3c7..c6848491ee 100644 --- a/spec/unit/version_class_spec.rb +++ b/spec/unit/version_class_spec.rb @@ -105,7 +105,7 @@ describe Chef::Version do a = %w{0.0.0 0.0.1 0.1.0 0.1.1 1.0.0 1.1.0 1.1.1}.map do |s| Chef::Version.new(s) end - got = a.sort.map { |v| v.to_s } + got = a.sort.map(&:to_s) expect(got).to eq(%w{0.0.0 0.0.1 0.1.0 0.1.1 1.0.0 1.1.0 1.1.1}) end @@ -113,7 +113,7 @@ describe Chef::Version do a = %w{9.8.7 1.0.0 1.2.3 4.4.6 4.5.6 0.8.6 4.5.5 5.9.8 3.5.7}.map do |s| Chef::Version.new(s) end - got = a.sort.map { |v| v.to_s } + got = a.sort.map(&:to_s) expect(got).to eq(%w{0.8.6 1.0.0 1.2.3 3.5.7 4.4.6 4.5.5 4.5.6 5.9.8 9.8.7}) end @@ -160,9 +160,9 @@ describe Chef::Version do [ "1.2.2", :<=, "1.2.1", false ], [ "1.2.2", :<, "1.2.1", false ], ].each do |spec| - it "(#{spec.first(3).join(' ')}) should be #{spec[3]}" do + it "(#{spec.first(3).join(" ")}) should be #{spec[3]}" do got = Chef::Version.new(spec[0]).send(spec[1], - Chef::Version.new(spec[2])) + Chef::Version.new(spec[2])) expect(got).to eq(spec[3]) end end diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb index 574f38d8e2..2485d9ee47 100644 --- a/spec/unit/win32/registry_spec.rb +++ b/spec/unit/win32/registry_spec.rb @@ -29,7 +29,7 @@ describe Chef::Win32::Registry do let(:key_to_delete) { "OpscodeNumbers" } let(:sub_key) { "OpscodePrimes" } let(:missing_key_path) { 'HKCU\Software' } - let(:registry) { Chef::Win32::Registry.new() } + let(:registry) { Chef::Win32::Registry.new } let(:hive_mock) { double("::Win32::Registry::KHKEY_CURRENT_USER") } let(:reg_mock) { double("reg") } @@ -252,7 +252,7 @@ describe Chef::Win32::Registry do expect(registry).to receive(:key_exists!).with(key_path).and_return(true) expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key]) expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock) - expect(reg_mock).to receive(:each_key).and_return(no_args()) + expect(reg_mock).to receive(:each_key).and_return(no_args) expect(registry.has_subkeys?(key_path)).to eq(false) end @@ -290,7 +290,7 @@ describe Chef::Win32::Registry do expect(registry).to receive(:key_exists!).with(key_path).and_return(true) expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key]) expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock) - expect(reg_mock).to receive(:any?).and_yield(no_args()) + expect(reg_mock).to receive(:any?).and_yield(no_args) registry.value_exists?(key_path, value1) == false end end @@ -305,7 +305,7 @@ describe Chef::Win32::Registry do expect(registry).to receive(:key_exists!).with(key_path).and_return(true) expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key]) expect(registry).to receive(:get_type_from_name).with(:string).and_return(1) - expect(reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "1") + expect(reg_mock).to receive(:each).with(no_args).and_yield("one", 1, "1") expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock) expect(registry.data_exists?(key_path, value1)).to eq(true) end @@ -315,7 +315,7 @@ describe Chef::Win32::Registry do expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key]) expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock) expect(registry).to receive(:get_type_from_name).with(:string).and_return(1) - expect(reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "2") + expect(reg_mock).to receive(:each).with(no_args).and_yield("one", 1, "2") expect(registry.data_exists?(key_path, value1)).to eq(false) end end diff --git a/spec/unit/win32/security_spec.rb b/spec/unit/win32/security_spec.rb index 3c612aef10..efbb290adf 100644 --- a/spec/unit/win32/security_spec.rb +++ b/spec/unit/win32/security_spec.rb @@ -98,7 +98,8 @@ describe "Chef::Win32::Security", :windows_only do let(:token) do Chef::ReservedNames::Win32::Security.open_process_token( Chef::ReservedNames::Win32::Process.get_current_process, - token_rights) + token_rights + ) end it "raises error if GetTokenInformation fails" do diff --git a/tasks/announce.rb b/tasks/announce.rb index b6b701f04b..c898e80ed8 100644 --- a/tasks/announce.rb +++ b/tasks/announce.rb @@ -41,18 +41,11 @@ class ReleaseAnnouncement end def release_notes_from_file - File.read("RELEASE_NOTES.md").match(/^# Chef Client Release Notes #{@maj_minor}:\n\n(.*)/m)[1] + File.read("RELEASE_NOTES.md").match(/^# Chef Infra Client Release Notes #{@maj_minor}:\n\n(.*)/m)[1] end end -namespace :announce do - desc "Generate the Prerelease Announcement (version: X.Y.Z, release_date: YYYY-MM-DD)" - task :prerelease, :version, :release_date do |t, args| - ReleaseAnnouncement.new(args[:version], args[:release_date], "prerelease").render - end - - desc "Generate the Release Announcement (version: X.Y.Z)" - task :release, :version do |t, args| - ReleaseAnnouncement.new(args[:version], nil, "release").render - end +desc "Generate the Release Announcement (version: X.Y.Z)" +task :announce_release, :version do |t, args| + ReleaseAnnouncement.new(args[:version], nil, "release").render end diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb deleted file mode 100644 index 7465f7ba9e..0000000000 --- a/tasks/maintainers.rb +++ /dev/null @@ -1,211 +0,0 @@ -# -# Copyright:: Copyright 2015-2018, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "rake" - -SOURCE = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.toml") -TARGET = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.md") - -# The list of repositories that teams should own -REPOSITORIES = ["chef/chef", "chef/chef-dk", "chef/chef-census", "chef/chef-repo", - "chef/client-docs", "chef/ffi-yajl", "chef/libyajl2-gem", - "chef/mixlib-authentication", "chef/mixlib-cli", - "chef/mixlib-config", "chef/mixlib-install", "chef/mixlib-log", - "chef/mixlib-shellout", "chef/ohai", "chef/omnibus-chef"].freeze - -begin - require "tomlrb" - require "octokit" - require "pp" - - namespace :maintainers do - task default: :generate - - desc "Generate MarkDown version of MAINTAINERS file" - task :generate do - out = "<!-- This is a generated file. Please do not edit directly -->\n\n" - out << "# " + source["Preamble"]["title"] + "\n\n" - out << source["Preamble"]["text"] + "\n" - - # The project lead is a special case - out << "# " + source["Org"]["Lead"]["title"] + "\n\n" - out << format_person(source["Org"]["Lead"]["person"]) + "\n\n" - - out << format_components(source["Org"]["Components"]) - File.open(TARGET, "w") do |fn| - fn.write out - end - end - - desc "Synchronize GitHub teams" - # there's a special @chef/client-maintainers team that's everyone - # and then there's a team per component - task :synchronize do - Octokit.auto_paginate = true - get_github_teams - prepare_teams(source["Org"]["Components"].dup) - sync_teams! - end - end - - def github - @github ||= Octokit::Client.new(netrc: true) - end - - def source - @source ||= Tomlrb.load_file SOURCE - end - - def teams - @teams ||= { "client-maintainers" => { "title" => "Client Maintainers" } } - end - - def add_members(team, name) - teams["client-maintainers"]["members"] ||= [] - teams["client-maintainers"]["members"] << name - teams[team] ||= {} - teams[team]["members"] ||= [] - teams[team]["members"] << name - end - - def set_team_title(team, title) - teams[team] ||= {} - teams[team]["title"] = title - end - - def gh_teams - @gh_teams ||= {} - end - - # we have to resolve team names to ids. While we're at it, we can get the privacy - # setting, so we know whether we need to update it - def get_github_teams - github.org_teams("chef").each do |team| - gh_teams[team[:slug]] = { "id" => team[:id], "privacy" => team[:privacy] } - end - end - - def get_github_team(team) - github.team_members(gh_teams[team]["id"]).map do |member| - member[:login] - end.sort.uniq.map(&:downcase) - rescue - [] - end - - def create_team(team) - puts "creating new github team: #{team} with title: #{teams[team]["title"]} " - t = github.create_team("chef", name: team, description: teams[team]["title"], - privacy: "closed", repo_names: REPOSITORIES, - accept: "application/vnd.github.ironman-preview+json") - gh_teams[team] = { "id" => t[:id], "privacy" => t[:privacy] } - end - - def compare_teams(current, desired) - # additions are the subtraction of the current state from the desired state - # deletions are the subtraction of the desired state from the current state - [desired - current, current - desired] - end - - def prepare_teams(cmp) - %w{text paths}.each { |k| cmp.delete(k) } - if cmp.key?("team") - team = cmp.delete("team") - add_members(team, cmp.delete("lieutenant")) if cmp.key?("lieutenant") - add_members(team, cmp.delete("maintainers")) if cmp.key?("maintainers") - set_team_title(team, cmp.delete("title")) - else - %w{maintainers lieutenant title}.each { |k| cmp.delete(k) } - end - cmp.each_value { |v| prepare_teams(v) } - end - - def update_team(team, additions, deletions) - create_team(team) unless gh_teams.key?(team) - update_team_privacy(team) - add_team_members(team, additions) - remove_team_members(team, deletions) - rescue => e - puts "failed for #{team}: #{e.message}" - end - - def update_team_privacy(team) - return if gh_teams[team]["privacy"] == "closed" - puts "Setting #{team} privacy to closed from #{gh_teams[team]["privacy"]}" - github.update_team(gh_teams[team]["id"], privacy: "closed", - accept: "application/vnd.github.ironman-preview+json") - end - - def add_team_members(team, additions) - additions.each do |member| - puts "Adding #{member} to #{team}" - github.add_team_membership(gh_teams[team]["id"], member, role: "member", - accept: "application/vnd.github.ironman-preview+json") - end - end - - def remove_team_members(team, deletions) - deletions.each do |member| - puts "Removing #{member} from #{team}" - github.remove_team_membership(gh_teams[team]["id"], member, - accept: "application/vnd.github.ironman-preview+json") - end - end - - def sync_teams! - teams.each do |name, details| - current = get_github_team(name) - desired = details["members"].flatten.sort.uniq.map(&:downcase) - additions, deletions = compare_teams(current, desired) - update_team(name, additions, deletions) - end - end - - def get_person(person) - source["people"][person] - end - - def format_components(cmp) - out = "## " + cmp.delete("title") + "\n\n" - out << cmp.delete("text") + "\n" if cmp.key?("text") - out << "To mention the team, use @chef/#{cmp.delete("team")}\n\n" if cmp.key?("team") - if cmp.key?("lieutenant") - out << "### Lieutenant\n\n" - out << format_person(cmp.delete("lieutenant")) + "\n\n" - end - out << format_maintainers(cmp.delete("maintainers")) + "\n" if cmp.key?("maintainers") - cmp.delete("paths") - cmp.each_value { |v| out << format_components(v) } - out - end - - def format_maintainers(people) - o = "### Maintainers\n\n" - people.each do |p| - o << format_person(p) + "\n" - end - o - end - - def format_person(person) - mnt = get_person(person) - "* [#{mnt["Name"]}](https://github.com/#{mnt["GitHub"]})" - end - -rescue LoadError - STDERR.puts "\n*** TomlRb not available.\n\n" -end diff --git a/tasks/templates/prerelease.md.erb b/tasks/templates/prerelease.md.erb deleted file mode 100644 index cab7f11fff..0000000000 --- a/tasks/templates/prerelease.md.erb +++ /dev/null @@ -1,35 +0,0 @@ -Ohai Chefs! - -We have selected <%= @version %> as our Chef v<%= @maj_minor %> release candidate which is scheduled for release on <%= @date.strftime('%A %B %-d, %Y') %>. - -# Release Highlights - -<%= @release_notes %> - -Please see the [CHANGELOG](https://github.com/chef/chef/blob/master/CHANGELOG.md) for the complete list of changes. - -# Get the Build -As always, you can download binaries directly from [downloads.chef.io](https://downloads.chef.io/chef/current/<%= @version %>) or by using the `mixlib-install` command line utility: - -```shell -$ mixlib-install download chef -v <%= @version %> -c current -``` - -Alternatively, you can install Chef using one of the following command options: - -```shell -# In Shell -$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chef -v <%= @version %> -c current - -# In Windows PowerShell -. { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project chef -version <%= @version %> -channel current -``` - -If you want to give this version a spin in Test Kitchen, create or add the following to your `kitchen.yml` file: - -```yaml -provisioner: - product_name: chef - channel: current - product_version: <%= @version %> -``` |