summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-01-14 14:08:03 +0000
committerThom May <thom@chef.io>2016-01-14 14:08:03 +0000
commit51cfbdc4d16739caac4d946fadbe678444aafe34 (patch)
tree56dfd8f1cd9fd933de27268b32402e955a43ac2b /spec/support
parent05064423057d4cf46f4713b81b08829cf6d20af6 (diff)
downloadchef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go along with chef/chefstyle#5 . We should pick something and use it consistently, and my opinion is that double quotes are the appropriate thing.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/chef_helpers.rb6
-rw-r--r--spec/support/key_helpers.rb2
-rw-r--r--spec/support/lib/chef/resource/with_state.rb4
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb4
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb4
-rw-r--r--spec/support/matchers/leak.rb4
-rw-r--r--spec/support/mock/constant.rb4
-rw-r--r--spec/support/mock/platform.rb4
-rw-r--r--spec/support/platform_helpers.rb40
-rw-r--r--spec/support/platforms/prof/win32.rb2
-rw-r--r--spec/support/platforms/win32/spec_service.rb4
-rw-r--r--spec/support/shared/context/client.rb4
-rw-r--r--spec/support/shared/context/config.rb6
-rw-r--r--spec/support/shared/context/win32.rb8
-rw-r--r--spec/support/shared/examples/client.rb4
-rw-r--r--spec/support/shared/functional/directory_resource.rb6
-rw-r--r--spec/support/shared/functional/file_resource.rb10
-rw-r--r--spec/support/shared/functional/http.rb60
-rw-r--r--spec/support/shared/functional/securable_resource.rb74
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb12
-rw-r--r--spec/support/shared/functional/win32_service.rb4
-rw-r--r--spec/support/shared/functional/windows_script.rb18
-rw-r--r--spec/support/shared/integration/app_server_support.rb4
-rw-r--r--spec/support/shared/integration/integration_helper.rb28
-rw-r--r--spec/support/shared/integration/knife_support.rb20
-rw-r--r--spec/support/shared/matchers/exit_with_code.rb2
-rw-r--r--spec/support/shared/matchers/match_environment_variable.rb4
-rw-r--r--spec/support/shared/unit/api_versioning.rb6
-rw-r--r--spec/support/shared/unit/execute_resource.rb2
-rw-r--r--spec/support/shared/unit/file_system_support.rb10
-rw-r--r--spec/support/shared/unit/platform_introspector.rb54
-rw-r--r--spec/support/shared/unit/provider/file.rb18
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb48
-rw-r--r--spec/support/shared/unit/script_resource.rb12
-rw-r--r--spec/support/shared/unit/windows_script_resource.rb8
35 files changed, 250 insertions, 250 deletions
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index 851b1dce0a..a792cd3c5f 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -15,7 +15,7 @@
#
CHEF_SPEC_DATA = File.expand_path(File.dirname(__FILE__) + "/../data/")
CHEF_SPEC_ASSETS = File.expand_path(File.dirname(__FILE__) + "/../functional/assets/")
-CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, 'test-backup-path')
+CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, "test-backup-path")
Chef::Config[:log_level] = :fatal
Chef::Config[:persistent_queue] = false
@@ -82,12 +82,12 @@ end
# This is a helper to canonicalize paths that we're using in the file
# tests.
def canonicalize_path(path)
- windows? ? path.gsub('/', '\\') : path
+ windows? ? path.gsub("/", '\\') : path
end
# Check if a cmd exists on the PATH
def which(cmd)
- paths = ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ]
+ paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
paths.each do |path|
filename = File.join(path, cmd)
return filename if File.executable?(filename)
diff --git a/spec/support/key_helpers.rb b/spec/support/key_helpers.rb
index 076f709380..cec0e26cb4 100644
--- a/spec/support/key_helpers.rb
+++ b/spec/support/key_helpers.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
shared_examples_for "a knife key command" do
let(:stderr) { StringIO.new }
diff --git a/spec/support/lib/chef/resource/with_state.rb b/spec/support/lib/chef/resource/with_state.rb
index 773ae7ddb8..60269632b0 100644
--- a/spec/support/lib/chef/resource/with_state.rb
+++ b/spec/support/lib/chef/resource/with_state.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'chef/knife'
-require 'chef/json_compat'
+require "chef/knife"
+require "chef/json_compat"
class Chef
class Resource
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 155e6ae729..83ae078f1d 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -15,8 +15,8 @@
# limitations under the License.
#
-require 'chef/knife'
-require 'chef/json_compat'
+require "chef/knife"
+require "chef/json_compat"
class Chef
class Resource
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 4106549d79..6f6f4fcabb 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'chef/knife'
-require 'chef/json_compat'
+require "chef/knife"
+require "chef/json_compat"
class Chef
class Resource
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index 01d1e53f92..80f0ae44c7 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -60,10 +60,10 @@ module Matchers
def profiler
@profiler ||= begin
if Chef::Platform.windows?
- require File.join(File.dirname(__FILE__), '..', 'platforms', 'prof', 'win32')
+ require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32")
RSpec::Prof::Win32::Profiler.new
else
- require File.join(File.dirname(__FILE__), '..', 'prof', 'gc')
+ require File.join(File.dirname(__FILE__), "..", "prof", "gc")
RSpec::Prof::GC::Profiler.new
end
end
diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb
index c706ad29dd..98756d715f 100644
--- a/spec/support/mock/constant.rb
+++ b/spec/support/mock/constant.rb
@@ -23,7 +23,7 @@ def mock_constants(constants, &block)
end
def parse_constant(constant)
- source, _, constant_name = constant.to_s.rpartition('::')
+ source, _, constant_name = constant.to_s.rpartition("::")
[constantize(source), constant_name]
end
@@ -41,7 +41,7 @@ end
# File activesupport/lib/active_support/inflector/methods.rb, line 209
def constantize(camel_cased_word)
- names = camel_cased_word.split('::')
+ names = camel_cased_word.split("::")
names.shift if names.empty? || names.first.empty?
constant = Object
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index 7eae82fe7d..a8bbf13589 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -7,7 +7,7 @@
# or +Chef::FileAccessControl+
def platform_mock(platform = :unix, &block)
allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false)
- ENV['SYSTEMDRIVE'] = (platform == :windows ? 'C:' : nil)
+ ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil)
if platform == :windows
Chef::Config.set_defaults_for_windows
@@ -16,7 +16,7 @@ def platform_mock(platform = :unix, &block)
end
if block_given?
- mock_constants({"RUBY_PLATFORM" => (platform == :windows ? 'i386-mingw32' : 'x86_64-darwin11.2.0'),
+ 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
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index e80df90499..0259dc6dfb 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -1,6 +1,6 @@
-require 'fcntl'
-require 'chef/mixin/shell_out'
-require 'ohai/mixin/gce_metadata'
+require "fcntl"
+require "chef/mixin/shell_out"
+require "ohai/mixin/gce_metadata"
class ShellHelpers
extend Chef::Mixin::ShellOut
@@ -11,11 +11,11 @@ def ruby_lt_20?
end
def chef_gte_13?
- Chef::VERSION.split('.').first.to_i >= 13
+ Chef::VERSION.split(".").first.to_i >= 13
end
def chef_lt_13?
- Chef::VERSION.split('.').first.to_i < 13
+ Chef::VERSION.split(".").first.to_i < 13
end
def ruby_gte_19?
@@ -27,11 +27,11 @@ def ruby_20?
end
def ruby_64bit?
- !!(RbConfig::CONFIG['host_cpu'] =~ /x86_64/)
+ !!(RbConfig::CONFIG["host_cpu"] =~ /x86_64/)
end
def ruby_32bit?
- !!(RbConfig::CONFIG['host_cpu'] =~ /i686/)
+ !!(RbConfig::CONFIG["host_cpu"] =~ /i686/)
end
def windows?
@@ -43,29 +43,29 @@ def ohai
OHAI_SYSTEM
end
-require 'wmi-lite/wmi' if windows?
+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']
+ computer_system = wmi.first_of("Win32_ComputerSystem")
+ computer_system["partofdomain"]
end
def windows_win2k3?
return false unless windows?
wmi = WmiLite::Wmi.new
- host = wmi.first_of('Win32_OperatingSystem')
- (host['version'] && host['version'].start_with?("5.2"))
+ host = wmi.first_of("Win32_OperatingSystem")
+ (host["version"] && host["version"].start_with?("5.2"))
end
def windows_2008r2_or_later?
return false unless windows?
wmi = WmiLite::Wmi.new
- host = wmi.first_of('Win32_OperatingSystem')
- version = host['version']
+ host = wmi.first_of("Win32_OperatingSystem")
+ version = host["version"]
return false unless version
- components = version.split('.').map do | component |
+ components = version.split(".").map do | component |
component.to_i
end
components.length >=2 && components[0] >= 6 && components[1] >= 1
@@ -75,7 +75,7 @@ def windows_powershell_dsc?
return false unless windows?
supports_dsc = false
begin
- wmi = WmiLite::Wmi.new('root/microsoft/windows/desiredstateconfiguration')
+ wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration")
lcm = wmi.query("SELECT * FROM meta_class WHERE __this ISA 'MSFT_DSCLocalConfigurationManager'")
supports_dsc = !! lcm
rescue WmiLite::WmiException
@@ -84,7 +84,7 @@ def windows_powershell_dsc?
end
def windows_nano_server?
- require 'chef/platform/query_helpers'
+ require "chef/platform/query_helpers"
Chef::Platform.windows_nano_server?
end
@@ -117,7 +117,7 @@ end
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
def windows64?
- windows? && ( ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' || ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' )
+ windows? && ( ENV["PROCESSOR_ARCHITECTURE"] == "AMD64" || ENV["PROCESSOR_ARCHITEW6432"] == "AMD64" )
end
# detects if the hardware is 32-bit
@@ -156,10 +156,10 @@ def wpar?
end
def supports_cloexec?
- Fcntl.const_defined?('F_SETFD') && Fcntl.const_defined?('FD_CLOEXEC')
+ Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
end
-DEV_NULL = windows? ? 'NUL' : '/dev/null'
+DEV_NULL = windows? ? "NUL" : "/dev/null"
def selinux_enabled?
# This code is currently copied from lib/chef/util/selinux to make
diff --git a/spec/support/platforms/prof/win32.rb b/spec/support/platforms/prof/win32.rb
index ab256ff0fc..379f75a594 100644
--- a/spec/support/platforms/prof/win32.rb
+++ b/spec/support/platforms/prof/win32.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'chef/win32/process'
+require "chef/win32/process"
module RSpec
module Prof
diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb
index 3e1f6c3638..037ccc93de 100644
--- a/spec/support/platforms/win32/spec_service.rb
+++ b/spec/support/platforms/win32/spec_service.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'win32/daemon'
+require "win32/daemon"
class SpecService < ::Win32::Daemon
def service_init
@@ -26,7 +26,7 @@ class SpecService < ::Win32::Daemon
def service_main(*startup_parameters)
while running? do
if !File.exists?(@test_service_file)
- File.open(@test_service_file, 'wb') do |f|
+ File.open(@test_service_file, "wb") do |f|
f.write("This file is created by SpecService")
end
end
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index eec66dcb26..2089928618 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
+require "spec_helper"
# Stubs a basic client object
shared_context "client" do
@@ -140,7 +140,7 @@ shared_context "a client run" do
before do
Chef::Config[:client_fork] = enable_fork
- Chef::Config[:cache_path] = windows? ? 'C:\chef' : '/var/chef'
+ Chef::Config[:cache_path] = windows? ? 'C:\chef' : "/var/chef"
Chef::Config[:why_run] = false
Chef::Config[:audit_mode] = :enabled
diff --git a/spec/support/shared/context/config.rb b/spec/support/shared/context/config.rb
index 1412356f3a..bb4ff7e0d1 100644
--- a/spec/support/shared/context/config.rb
+++ b/spec/support/shared/context/config.rb
@@ -5,15 +5,15 @@
#
# Required chef files here:
-require 'chef/config'
+require "chef/config"
# Required spec files here:
-require 'spec_helper'
+require "spec_helper"
# Basic config. Nothing fancy.
shared_context "default config options" do
before do
- Chef::Config[:cache_path] = windows? ? 'C:\chef' : '/var/chef'
+ Chef::Config[:cache_path] = windows? ? 'C:\chef' : "/var/chef"
end
# Don't need to have an after block to reset the config...
diff --git a/spec/support/shared/context/win32.rb b/spec/support/shared/context/win32.rb
index 60ed92ca1d..9e0099d8af 100644
--- a/spec/support/shared/context/win32.rb
+++ b/spec/support/shared/context/win32.rb
@@ -18,8 +18,8 @@
RSpec.shared_context "Win32" do
before(:all) do
@original_win32 = if defined?(Win32)
- win32 = Object.send(:const_get, 'Win32')
- Object.send(:remove_const, 'Win32')
+ win32 = Object.send(:const_get, "Win32")
+ Object.send(:remove_const, "Win32")
win32
else
nil
@@ -28,7 +28,7 @@ RSpec.shared_context "Win32" do
end
after(:all) do
- Object.send(:remove_const, 'Win32') if defined?(Win32)
- Object.send(:const_set, 'Win32', @original_win32) if @original_win32
+ Object.send(:remove_const, "Win32") if defined?(Win32)
+ Object.send(:const_set, "Win32", @original_win32) if @original_win32
end
end
diff --git a/spec/support/shared/examples/client.rb b/spec/support/shared/examples/client.rb
index 330cb40ac6..5af63dc307 100644
--- a/spec/support/shared/examples/client.rb
+++ b/spec/support/shared/examples/client.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require 'spec/support/shared/context/client'
+require "spec_helper"
+require "spec/support/shared/context/client"
# requires platform and platform_version be defined
shared_examples "a completed run" do
diff --git a/spec/support/shared/functional/directory_resource.rb b/spec/support/shared/functional/directory_resource.rb
index 51c7550a78..6aeef139b3 100644
--- a/spec/support/shared/functional/directory_resource.rb
+++ b/spec/support/shared/functional/directory_resource.rb
@@ -48,7 +48,7 @@ shared_examples_for "a directory resource" do
expect(File).not_to exist(path)
resource.recursive(true)
- @recursive_path = File.join(path, 'red-headed-stepchild')
+ @recursive_path = File.join(path, "red-headed-stepchild")
resource.path(@recursive_path)
resource.run_action(:create)
end
@@ -133,7 +133,7 @@ shared_examples_for "a directory resource" do
context "with the recursive option" do
before do
- FileUtils.mkdir(File.join(path, 'red-headed-stepchild'))
+ FileUtils.mkdir(File.join(path, "red-headed-stepchild"))
resource.recursive(true)
resource.run_action(:delete)
end
@@ -152,7 +152,7 @@ shared_context Chef::Resource::Directory do
# deployment strategies more completely.
let(:test_file_dir) do
if windows?
- File.join(ENV['systemdrive'], "test-dir")
+ File.join(ENV["systemdrive"], "test-dir")
else
File.join(CHEF_SPEC_DATA, "test-dir")
end
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index 3ce3c9c94e..4f517b2041 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -144,7 +144,7 @@ shared_examples_for "a file with the wrong content" do
end
context "when diff is enabled" do
- describe 'sensitive attribute' do
+ describe "sensitive attribute" do
context "should be insensitive by default" do
it { expect(resource.sensitive).to(be_falsey) }
end
@@ -165,7 +165,7 @@ shared_examples_for "a file with the wrong content" do
end
it "should suppress the diff" do
- expect(resource.diff).to(include('suppressed sensitive resource'))
+ expect(resource.diff).to(include("suppressed sensitive resource"))
expect(reporter_messages[1]).to eq("suppressed sensitive resource")
end
@@ -776,7 +776,7 @@ shared_examples_for "a configured file resource" do
end
context "when the target file is a socket",:unix_only do
- require 'socket'
+ require "socket"
# It turns out that the path to a socket can have at most ~104
# bytes. Therefore we are creating our sockets in tmpdir so that
@@ -1020,14 +1020,14 @@ end
shared_context Chef::Resource::File do
if windows?
- require 'chef/win32/file'
+ require "chef/win32/file"
end
# We create the files in a different directory than tmp to exercise
# different file deployment strategies more completely.
let(:test_file_dir) do
if windows?
- File.join(ENV['systemdrive'], "test-dir")
+ File.join(ENV["systemdrive"], "test-dir")
else
File.join(CHEF_SPEC_DATA, "test-dir")
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index cfbb8e3689..7b7c17106d 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -22,11 +22,11 @@
module ChefHTTPShared
def nyan_uncompressed_filename
- File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png')
+ File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png")
end
def nyan_compressed_filename
- File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz')
+ File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png.gz")
end
def binread(file)
@@ -60,7 +60,7 @@ module ChefHTTPShared
# 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' } ) {
+ @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
@@ -68,7 +68,7 @@ module ChefHTTPShared
# 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' } ) {
+ @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
@@ -81,7 +81,7 @@ module ChefHTTPShared
# (expected_content should be uncompressed)
@api.get("/nyan_cat_content_length.png", 200, nil,
{
- 'Content-Length' => nyan_uncompressed_size.to_s
+ "Content-Length" => nyan_uncompressed_size.to_s
}
) {
File.open(nyan_uncompressed_filename, "rb") do |f|
@@ -92,9 +92,9 @@ module ChefHTTPShared
# (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-Encoding' => 'gzip',
+ "Content-Length" => nyan_compressed_size.to_s,
+ "Content-Type" => "application/gzip",
+ "Content-Encoding" => "gzip",
}
) {
File.open(nyan_compressed_filename, "rb") do |f|
@@ -109,7 +109,7 @@ module ChefHTTPShared
# (expected_content should be uncompressed)
@api.get("/nyan_cat_truncated.png", 200, nil,
{
- 'Content-Length' => (nyan_uncompressed_size + 1).to_s
+ "Content-Length" => (nyan_uncompressed_size + 1).to_s
}
) {
File.open(nyan_uncompressed_filename, "rb") do |f|
@@ -120,9 +120,9 @@ module ChefHTTPShared
# (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-Encoding' => 'gzip',
+ "Content-Length" => (nyan_compressed_size + 1).to_s,
+ "Content-Type" => "application/gzip",
+ "Content-Encoding" => "gzip",
}
) {
File.open(nyan_compressed_filename, "rb") do |f|
@@ -137,8 +137,8 @@ module ChefHTTPShared
# (expected_content should be uncompressed)
@api.get("/nyan_cat_transfer_encoding.png", 200, nil,
{
- 'Content-Length' => (nyan_uncompressed_size + 1).to_s,
- 'Transfer-Encoding' => 'anything',
+ "Content-Length" => (nyan_uncompressed_size + 1).to_s,
+ "Transfer-Encoding" => "anything",
}
) {
File.open(nyan_uncompressed_filename, "rb") do |f|
@@ -149,19 +149,19 @@ module ChefHTTPShared
#
# 403 with a Content-Length
#
- @api.get('/forbidden', 403, 'Forbidden',
+ @api.get("/forbidden", 403, "Forbidden",
{
- 'Content-Length' => 'Forbidden'.bytesize.to_s
+ "Content-Length" => "Forbidden".bytesize.to_s
}
)
- @api.post('/posty', 200, 'Hi!')
+ @api.post("/posty", 200, "Hi!")
#
# 400 with an error
#
- @api.get('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }')
- @api.post('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }')
+ @api.get("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
+ @api.post("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
end
@@ -175,14 +175,14 @@ end
shared_examples_for "downloading all the things" do
describe "when downloading a simple uncompressed file" do
- let(:source) { 'http://localhost:9000/nyan_cat.png' }
+ let(:source) { "http://localhost:9000/nyan_cat.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "downloads requests correctly"
end
describe "when downloading a compressed file that should be left compressed" do
- let(:source) { 'http://localhost:9000/nyan_cat.png.gz' }
+ let(:source) { "http://localhost:9000/nyan_cat.png.gz" }
let(:expected_content) { binread(nyan_compressed_filename) }
# its the callers responsibility to disable_gzip when downloading a .gz url
@@ -192,57 +192,57 @@ shared_examples_for "downloading all the things" do
end
describe "when downloading a file that has been compressed by the webserver" do
- let(:source) { 'http://localhost:9000/nyan_cat_compressed.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_compressed.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "downloads requests correctly"
end
describe "when downloading an uncompressed file with a correct content_length" do
- let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_content_length.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "downloads requests correctly"
end
describe "when downloading a file that has been compressed by the webserver with a correct content_length" do
- let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "downloads requests correctly"
end
describe "when downloading an uncompressed file that is truncated" do
- let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_truncated.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "validates content length and throws an exception"
end
describe "when downloading a file that has been compressed by the webserver that is truncated" do
- let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_truncated_compressed.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "validates content length and throws an exception"
end
describe "when downloading a file that has transfer encoding set with a bad content length that should be ignored" do
- let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_transfer_encoding.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
it_behaves_like "downloads requests correctly"
end
describe "when downloading an endpoint that 403s" do
- let(:source) { 'http://localhost:9000/forbidden' }
+ let(:source) { "http://localhost:9000/forbidden" }
it_behaves_like "an endpoint that 403s"
end
describe "when downloading an endpoint that 403s" do
- let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
+ let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" }
let(:expected_content) { binread(nyan_uncompressed_filename) }
- let(:source2) { 'http://localhost:9000/forbidden' }
+ let(:source2) { "http://localhost:9000/forbidden" }
it_behaves_like "a 403 after a successful request when reusing the request object"
end
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 1e8edec9ae..453f7e2f45 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'etc'
-require 'functional/resource/base'
+require "etc"
+require "functional/resource/base"
shared_context "setup correct permissions" do
if windows?
@@ -38,9 +38,9 @@ shared_context "setup correct permissions" do
# Root only context.
before :each, :unix_only, :requires_root do
if ohai[:platform] == "aix"
- File.chown(Etc.getpwnam('guest').uid, 1337, path)
+ File.chown(Etc.getpwnam("guest").uid, 1337, path)
else
- File.chown(Etc.getpwnam('nobody').uid, 1337, path)
+ File.chown(Etc.getpwnam("nobody").uid, 1337, path)
end
end
@@ -155,9 +155,9 @@ shared_examples_for "a securable resource with existing target" do
context "on Unix", :unix_only do
if ohai[:platform] == "aix"
- let(:expected_user_name) { 'guest' }
+ let(:expected_user_name) { "guest" }
else
- let(:expected_user_name) { 'nobody' }
+ let(:expected_user_name) { "nobody" }
end
let(:expected_uid) { Etc.getpwnam(expected_user_name).uid }
let(:desired_gid) { 1337 }
@@ -197,7 +197,7 @@ shared_examples_for "a securable resource with existing target" do
describe "when setting the permissions from octal given as a String" do
before do
- @mode_string = '776'
+ @mode_string = "776"
resource.mode @mode_string
resource.run_action(:create)
end
@@ -258,7 +258,7 @@ shared_examples_for "a securable resource with existing target" do
describe "when setting group" do
before do
- resource.group('Administrators')
+ resource.group("Administrators")
resource.run_action(:create)
end
@@ -273,8 +273,8 @@ shared_examples_for "a securable resource with existing target" do
describe "when setting rights and deny_rights" do
before do
- resource.deny_rights(:modify, 'Guest')
- resource.rights(:read, 'Guest')
+ resource.deny_rights(:modify, "Guest")
+ resource.rights(:read, "Guest")
resource.run_action(:create)
end
@@ -303,7 +303,7 @@ shared_examples_for "a securable resource without existing target" do
end
it "sets owner when owner is specified" do
- resource.owner 'Guest'
+ resource.owner "Guest"
resource.run_action(:create)
expect(descriptor.owner).to eq(SID.Guest)
end
@@ -322,7 +322,7 @@ shared_examples_for "a securable resource without existing target" do
arbitrary_non_default_owner = SID.Guest
expect(arbitrary_non_default_owner).not_to eq(SID.default_security_object_owner)
- resource.owner 'Guest' # Change to arbitrary_non_default_owner once issue #1508 is fixed
+ resource.owner "Guest" # Change to arbitrary_non_default_owner once issue #1508 is fixed
resource.run_action(:create)
expect(descriptor.owner).to eq(arbitrary_non_default_owner)
@@ -340,7 +340,7 @@ shared_examples_for "a securable resource without existing target" do
end
it "sets group when group is specified" do
- resource.group 'Everyone'
+ resource.group "Everyone"
resource.run_action(:create)
expect(descriptor.group).to eq(SID.Everyone)
end
@@ -353,7 +353,7 @@ shared_examples_for "a securable resource without existing target" do
arbitrary_non_default_group = SID.Everyone
expect(arbitrary_non_default_group).not_to eq(SID.default_security_object_group)
- resource.group 'Everyone' # Change to arbitrary_non_default_group once issue #1508 is fixed
+ resource.group "Everyone" # Change to arbitrary_non_default_group once issue #1508 is fixed
resource.run_action(:create)
expect(descriptor.group).to eq(arbitrary_non_default_group)
@@ -366,45 +366,45 @@ shared_examples_for "a securable resource without existing target" do
describe "with rights and deny_rights attributes" do
it "correctly sets :read rights" do
- resource.rights(:read, 'Guest')
+ resource.rights(:read, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_read_perms))
end
it "correctly sets :read_execute rights" do
- resource.rights(:read_execute, 'Guest')
+ resource.rights(:read_execute, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_read_execute_perms))
end
it "correctly sets :write rights" do
- resource.rights(:write, 'Guest')
+ resource.rights(:write, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_write_perms))
end
it "correctly sets :modify rights" do
- resource.rights(:modify, 'Guest')
+ resource.rights(:modify, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_modify_perms))
end
it "correctly sets :full_control rights" do
- resource.rights(:full_control, 'Guest')
+ resource.rights(:full_control, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_full_control_perms))
end
it "correctly sets deny_rights" do
# deny is an ACE with full rights, but is a deny type ace, not an allow type
- resource.deny_rights(:full_control, 'Guest')
+ resource.deny_rights(:full_control, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(denied_acl(SID.Guest, expected_full_control_perms))
end
it "Sets multiple rights" do
- resource.rights(:read, 'Everyone')
- resource.rights(:modify, 'Guest')
+ resource.rights(:read, "Everyone")
+ resource.rights(:modify, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(
@@ -414,8 +414,8 @@ shared_examples_for "a securable resource without existing target" do
end
it "Sets deny_rights ahead of rights" do
- resource.rights(:read, 'Everyone')
- resource.deny_rights(:modify, 'Guest')
+ resource.rights(:read, "Everyone")
+ resource.deny_rights(:modify, "Guest")
resource.run_action(:create)
expect(explicit_aces).to eq(
@@ -425,8 +425,8 @@ shared_examples_for "a securable resource without existing target" do
end
it "Sets deny_rights ahead of rights when specified in reverse order" do
- resource.deny_rights(:modify, 'Guest')
- resource.rights(:read, 'Everyone')
+ resource.deny_rights(:modify, "Guest")
+ resource.rights(:read, "Everyone")
resource.run_action(:create)
expect(explicit_aces).to eq(
@@ -445,9 +445,9 @@ shared_examples_for "a securable resource without existing target" do
it "respects mode in string form as an octal number" do
#on windows, mode cannot modify owner and/or group permissons
#unless the owner and/or group as appropriate is specified
- resource.mode '400'
- resource.owner 'Guest'
- resource.group 'Everyone'
+ resource.mode "400"
+ resource.owner "Guest"
+ resource.group "Everyone"
resource.run_action(:create)
expect(explicit_aces).to eq([ ACE.access_allowed(SID.Guest, Security::FILE_GENERIC_READ) ])
@@ -455,7 +455,7 @@ shared_examples_for "a securable resource without existing target" do
it "respects mode in numeric form as a ruby-interpreted octal" do
resource.mode 0700
- resource.owner 'Guest'
+ resource.owner "Guest"
resource.run_action(:create)
expect(explicit_aces).to eq([ ACE.access_allowed(SID.Guest, Security::FILE_GENERIC_READ | Security::FILE_GENERIC_WRITE | Security::FILE_GENERIC_EXECUTE | Security::DELETE) ])
@@ -463,8 +463,8 @@ shared_examples_for "a securable resource without existing target" do
it "respects the owner, group and everyone bits of mode" do
resource.mode 0754
- resource.owner 'Guest'
- resource.group 'Administrators'
+ resource.owner "Guest"
+ resource.group "Administrators"
resource.run_action(:create)
expect(explicit_aces).to eq([
@@ -476,8 +476,8 @@ shared_examples_for "a securable resource without existing target" do
it "respects the individual read, write and execute bits of mode" do
resource.mode 0421
- resource.owner 'Guest'
- resource.group 'Administrators'
+ resource.owner "Guest"
+ resource.group "Administrators"
resource.run_action(:create)
expect(explicit_aces).to eq([
@@ -487,7 +487,7 @@ shared_examples_for "a securable resource without existing target" do
])
end
- it 'warns when mode tries to set owner bits but owner is not specified' do
+ it "warns when mode tries to set owner bits but owner is not specified" do
@warn = []
allow(Chef::Log).to receive(:warn) { |msg| @warn << msg }
@@ -497,7 +497,7 @@ shared_examples_for "a securable resource without existing target" do
expect(@warn.include?("Mode 400 includes bits for the owner, but owner is not specified")).to be_truthy
end
- it 'warns when mode tries to set group bits but group is not specified' do
+ it "warns when mode tries to set group bits but group is not specified" do
@warn = []
allow(Chef::Log).to receive(:warn) { |msg| @warn << msg }
@@ -511,7 +511,7 @@ shared_examples_for "a securable resource without existing target" do
it "does not inherit aces if inherits is set to false" do
# We need at least one ACE if we're creating a securable without
# inheritance
- resource.rights(:full_control, 'Administrators')
+ resource.rights(:full_control, "Administrators")
resource.inherits(false)
resource.run_action(:create)
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index 3176ebba0d..c9b5bae465 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -1,5 +1,5 @@
-require 'functional/resource/base'
+require "functional/resource/base"
ALL_EXPANDED_PERMISSIONS = ["generic read",
"generic write",
@@ -76,9 +76,9 @@ shared_examples_for "a securable resource with reporting" do
# TODO/bug: duplicated from the "securable resource" tests
if ohai[:platform] == "aix"
- let(:expected_user_name) { 'guest' }
+ let(:expected_user_name) { "guest" }
else
- let(:expected_user_name) { 'nobody' }
+ let(:expected_user_name) { "nobody" }
end
before do
@@ -96,9 +96,9 @@ shared_examples_for "a securable resource with reporting" do
# TODO: duplicated from "securable resource"
if ohai[:platform] == "aix"
- let(:expected_user_name) { 'guest' }
+ let(:expected_user_name) { "guest" }
else
- let(:expected_user_name) { 'nobody' }
+ let(:expected_user_name) { "nobody" }
end
let(:expected_uid) { Etc.getpwnam(expected_user_name).uid }
let(:desired_gid) { 1337 }
@@ -303,7 +303,7 @@ shared_examples_for "a securable resource with reporting" do
context "and owner is specified with a string (username) in new_resource" do
# TODO/bug: duplicated from the "securable resource" tests
- let(:expected_user_name) { 'Guest' }
+ let(:expected_user_name) { "Guest" }
before do
resource.owner(expected_user_name)
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 8eca7a47fa..5bd2d772cb 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -1,5 +1,5 @@
-require 'chef/application/windows_service_manager'
+require "chef/application/windows_service_manager"
shared_context "using Win32::Service" do
# Some helper methods.
@@ -46,7 +46,7 @@ shared_context "using Win32::Service" do
:service_name => "spec-service",
:service_display_name => "Spec Test Service",
:service_description => "Service for testing Chef::Application::WindowsServiceManager.",
- :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), '../../platforms/win32/spec_service.rb')),
+ :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
:delayed_start => true,
}
}
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index d84c06c86b..423d968ea5 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -19,7 +19,7 @@
# Shared context used by both Powershell and Batch script provider
# tests.
-require 'chef/platform/query_helpers'
+require "chef/platform/query_helpers"
shared_context Chef::Resource::WindowsScript do
before(:all) do
@@ -56,11 +56,11 @@ shared_context Chef::Resource::WindowsScript do
if resource_architecture
expected_architecture = resource_architecture
else
- expected_architecture = @ohai_reader.data['kernel']['machine'].to_sym
+ expected_architecture = @ohai_reader.data["kernel"]["machine"].to_sym
end
end
let(:expected_architecture_output) do
- expected_architecture == :i386 ? 'X86' : 'AMD64'
+ expected_architecture == :i386 ? "X86" : "AMD64"
end
let(:guard_script_suffix) do
"guard"
@@ -99,7 +99,7 @@ shared_context Chef::Resource::WindowsScript do
it "executes a 64-bit guard", :windows64_only do
resource.only_if resource_guard_command, :architecture => guard_architecture
resource.run_action(:run)
- expect(get_guard_process_architecture).to eq('amd64')
+ expect(get_guard_process_architecture).to eq("amd64")
end
end
@@ -108,7 +108,7 @@ shared_context Chef::Resource::WindowsScript do
it "executes a 32-bit guard" do
resource.only_if resource_guard_command, :architecture => guard_architecture
resource.run_action(:run)
- expect(get_guard_process_architecture).to eq('x86')
+ expect(get_guard_process_architecture).to eq("x86")
end
end
@@ -138,8 +138,8 @@ shared_context Chef::Resource::WindowsScript do
before(:each) do
@dir = Dir.mktmpdir("Jerry Smith")
@original_env = ENV.to_hash.dup
- ENV.delete('TMP')
- ENV['TMP'] = @dir
+ ENV.delete("TMP")
+ ENV["TMP"] = @dir
end
after(:each) do
@@ -183,7 +183,7 @@ shared_context Chef::Resource::WindowsScript do
end
end
- def get_windows_script_output(suffix = '')
+ def get_windows_script_output(suffix = "")
File.read("#{script_output_path}#{suffix}")
end
@@ -195,7 +195,7 @@ shared_context Chef::Resource::WindowsScript do
get_process_architecture(guard_script_suffix)
end
- def get_process_architecture(suffix = '')
+ def get_process_architecture(suffix = "")
get_windows_script_output(suffix).strip.downcase
end
diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb
index a133833d3e..da32a477fd 100644
--- a/spec/support/shared/integration/app_server_support.rb
+++ b/spec/support/shared/integration/app_server_support.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'rack'
-require 'stringio'
+require "rack"
+require "stringio"
module AppServerSupport
def start_app_server(app, port)
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 7d62a698d8..a19c9b35e7 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -17,15 +17,15 @@
# limitations under the License.
#
-require 'tmpdir'
-require 'fileutils'
-require 'chef/config'
-require 'chef/json_compat'
-require 'chef/server_api'
-require 'support/shared/integration/knife_support'
-require 'support/shared/integration/app_server_support'
-require 'cheffish/rspec/chef_run_support'
-require 'spec_helper'
+require "tmpdir"
+require "fileutils"
+require "chef/config"
+require "chef/json_compat"
+require "chef/server_api"
+require "support/shared/integration/knife_support"
+require "support/shared/integration/app_server_support"
+require "cheffish/rspec/chef_run_support"
+require "spec_helper"
module Cheffish
class BasicChefClient
@@ -75,8 +75,8 @@ module IntegrationSupport
def file(relative_path, contents)
filename = path_to(relative_path)
dir = File.dirname(filename)
- FileUtils.mkdir_p(dir) unless dir == '.'
- File.open(filename, 'w') do |file|
+ FileUtils.mkdir_p(dir) unless dir == "."
+ File.open(filename, "w") do |file|
raw = case contents
when Hash, Array
Chef::JSONCompat.to_json_pretty(contents)
@@ -90,7 +90,7 @@ module IntegrationSupport
def symlink(relative_path, relative_dest)
filename = path_to(relative_path)
dir = File.dirname(filename)
- FileUtils.mkdir_p(dir) unless dir == '.'
+ FileUtils.mkdir_p(dir) unless dir == "."
dest_filename = path_to(relative_dest)
File.symlink(dest_filename, filename)
end
@@ -111,7 +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')
+ @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|
Chef::Config.delete("#{object_name}_path".to_sym)
@@ -140,7 +140,7 @@ module IntegrationSupport
# Versioned cookbooks
- RSpec.shared_context 'with versioned cookbooks', :versioned_cookbooks => true do
+ RSpec.shared_context "with versioned cookbooks", :versioned_cookbooks => true do
before(:each) { Chef::Config[:versioned_cookbooks] = true }
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
end
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index fb624bca8b..0a8b855222 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -15,14 +15,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'chef/config'
-require 'chef/knife'
-require 'chef/application/knife'
-require 'logger'
-require 'chef/log'
+require "chef/config"
+require "chef/knife"
+require "chef/application/knife"
+require "logger"
+require "chef/log"
module KnifeSupport
- DEBUG = ENV['DEBUG']
+ DEBUG = ENV["DEBUG"]
def knife(*args, &block)
# Allow knife('role from file roles/blah.json') rather than requiring the
# arguments to be split like knife('role', 'from', 'file', 'roles/blah.json')
@@ -37,7 +37,7 @@ module KnifeSupport
Chef::Config[:concurrency] = 1
# Work on machines where we can't access /var
- checksums_cache_dir = Dir.mktmpdir('checksums') do |checksums_cache_dir|
+ checksums_cache_dir = Dir.mktmpdir("checksums") do |checksums_cache_dir|
Chef::Config[:cache_options] = {
:path => checksums_cache_dir,
:skip_expires => true,
@@ -146,11 +146,11 @@ module KnifeSupport
private
def should_result_in(expected)
- expected[:stdout] = '' if !expected[:stdout]
- expected[:stderr] = '' if !expected[:stderr]
+ expected[:stdout] = "" if !expected[:stdout]
+ expected[:stderr] = "" if !expected[:stderr]
expected[:exit_code] = 0 if !expected[:exit_code]
# TODO make this go away
- stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, '')
+ stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, "")
if expected[:stderr].is_a?(Regexp)
expect(stderr_actual).to match(expected[:stderr])
diff --git a/spec/support/shared/matchers/exit_with_code.rb b/spec/support/shared/matchers/exit_with_code.rb
index 32ebf8db15..cf1825f2ed 100644
--- a/spec/support/shared/matchers/exit_with_code.rb
+++ b/spec/support/shared/matchers/exit_with_code.rb
@@ -1,4 +1,4 @@
-require 'rspec/expectations'
+require "rspec/expectations"
# Lifted from http://stackoverflow.com/questions/1480537/how-can-i-validate-exits-and-aborts-in-rspec
RSpec::Matchers.define :exit_with_code do |exp_code|
diff --git a/spec/support/shared/matchers/match_environment_variable.rb b/spec/support/shared/matchers/match_environment_variable.rb
index c8c905f44a..393775ea29 100644
--- a/spec/support/shared/matchers/match_environment_variable.rb
+++ b/spec/support/shared/matchers/match_environment_variable.rb
@@ -1,6 +1,6 @@
-require 'rspec/expectations'
-require 'spec/support/platform_helpers'
+require "rspec/expectations"
+require "spec/support/platform_helpers"
RSpec::Matchers.define :match_environment_variable do |varname|
match do |actual|
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index ccbe95d029..261efc6f52 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -19,7 +19,7 @@
require "chef/exceptions"
shared_examples_for "version handling" do
- let(:response_406) { OpenStruct.new(:code => '406') }
+ let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
before do
@@ -38,7 +38,7 @@ shared_examples_for "version handling" do
end # version handling
shared_examples_for "user and client reregister" do
- let(:response_406) { OpenStruct.new(:code => '406') }
+ let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
@@ -55,7 +55,7 @@ shared_examples_for "user and client reregister" do
context "when the exception is 406 and returns x-ops-server-api-version header" do
before do
allow(rest_v0).to receive(:put).and_raise(exception_406)
- allow(response_406).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash_406))
+ allow(response_406).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash_406))
end
it "raises an error about only V0 being supported" do
diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb
index 3a88ff8890..e5bcbd5e91 100644
--- a/spec/support/shared/unit/execute_resource.rb
+++ b/spec/support/shared/unit/execute_resource.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
shared_examples_for "an execute resource" do
diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb
index 3aee46fc7f..f071cffee3 100644
--- a/spec/support/shared/unit/file_system_support.rb
+++ b/spec/support/shared/unit/file_system_support.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'chef/chef_fs/file_system'
-require 'chef/chef_fs/file_system/memory/memory_root'
-require 'chef/chef_fs/file_system/memory/memory_dir'
-require 'chef/chef_fs/file_system/memory/memory_file'
+require "chef/chef_fs/file_system"
+require "chef/chef_fs/file_system/memory/memory_root"
+require "chef/chef_fs/file_system/memory/memory_dir"
+require "chef/chef_fs/file_system/memory/memory_file"
module FileSystemSupport
def memory_fs(pretty_name, value, cannot_be_in_regex = nil)
@@ -33,7 +33,7 @@ module FileSystemSupport
dir
end
- def memory_fs_value(value, name = '', parent = nil)
+ def memory_fs_value(value, name = "", parent = nil)
if value.is_a?(Hash)
dir = Chef::ChefFS::FileSystem::Memory::MemoryDir.new(name, parent)
value.each do |key, child|
diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb
index 52a780eb10..51a2befdbb 100644
--- a/spec/support/shared/unit/platform_introspector.rb
+++ b/spec/support/shared/unit/platform_introspector.rb
@@ -30,10 +30,10 @@ shared_examples_for "a platform introspector" do
@platform_hash["debian"] = {["5", "6"] => "debian-5/6", "default" => "debian"}
@platform_hash["default"] = "default"
# The following @platform_hash keys are used for testing version constraints
- @platform_hash['exact_match'] = { '1.2.3' => 'exact', '>= 1.0' => 'not exact'}
- @platform_hash['multiple_matches'] = { '~> 2.3.4' => 'matched ~> 2.3.4', '>= 2.3' => 'matched >=2.3' }
- @platform_hash['invalid_cookbook_version'] = {'>= 21' => 'Matches a single number'}
- @platform_hash['successful_matches'] = { '< 3.0' => 'matched < 3.0', '>= 3.0' => 'matched >= 3.0' }
+ @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact"}
+ @platform_hash["multiple_matches"] = { "~> 2.3.4" => "matched ~> 2.3.4", ">= 2.3" => "matched >=2.3" }
+ @platform_hash["invalid_cookbook_version"] = {">= 21" => "Matches a single number"}
+ @platform_hash["successful_matches"] = { "< 3.0" => "matched < 3.0", ">= 3.0" => "matched >= 3.0" }
@platform_family_hash = {
"debian" => "debian value",
@@ -84,28 +84,28 @@ shared_examples_for "a platform introspector" do
expect(platform_introspector.value_for_platform(@platform_hash)).to eq("openbsd")
end
- it 'returns the exact match' do
- node.automatic_attrs[:platform] = 'exact_match'
- node.automatic_attrs[:platform_version] = '1.2.3'
- expect(platform_introspector.value_for_platform(@platform_hash)).to eq('exact')
+ it "returns the exact match" do
+ node.automatic_attrs[:platform] = "exact_match"
+ node.automatic_attrs[:platform_version] = "1.2.3"
+ expect(platform_introspector.value_for_platform(@platform_hash)).to eq("exact")
end
- it 'raises RuntimeError' do
- node.automatic_attrs[:platform] = 'multiple_matches'
- node.automatic_attrs[:platform_version] = '2.3.4'
+ it "raises RuntimeError" do
+ node.automatic_attrs[:platform] = "multiple_matches"
+ node.automatic_attrs[:platform_version] = "2.3.4"
expect {platform_introspector.value_for_platform(@platform_hash)}.to raise_error(RuntimeError)
end
- it 'should not require .0 to match >= 21.0' do
- node.automatic_attrs[:platform] = 'invalid_cookbook_version'
- node.automatic_attrs[:platform_version] = '21'
- expect(platform_introspector.value_for_platform(@platform_hash)).to eq('Matches a single number')
+ it "should not require .0 to match >= 21.0" do
+ node.automatic_attrs[:platform] = "invalid_cookbook_version"
+ node.automatic_attrs[:platform_version] = "21"
+ expect(platform_introspector.value_for_platform(@platform_hash)).to eq("Matches a single number")
end
- it 'should return the value for that match' do
- node.automatic_attrs[:platform] = 'successful_matches'
- node.automatic_attrs[:platform_version] = '2.9'
- expect(platform_introspector.value_for_platform(@platform_hash)).to eq('matched < 3.0')
+ it "should return the value for that match" do
+ node.automatic_attrs[:platform] = "successful_matches"
+ node.automatic_attrs[:platform_version] = "2.9"
+ expect(platform_introspector.value_for_platform(@platform_hash)).to eq("matched < 3.0")
end
describe "when platform versions is an array" do
@@ -125,17 +125,17 @@ shared_examples_for "a platform introspector" do
describe "when checking platform?" do
it "returns true if the node is a provided platform and platforms are provided as symbols" do
- node.automatic_attrs[:platform] = 'ubuntu'
+ node.automatic_attrs[:platform] = "ubuntu"
expect(platform_introspector.platform?([:redhat, :ubuntu])).to eq(true)
end
it "returns true if the node is a provided platform and platforms are provided as strings" do
- node.automatic_attrs[:platform] = 'ubuntu'
+ node.automatic_attrs[:platform] = "ubuntu"
expect(platform_introspector.platform?(["redhat", "ubuntu"])).to eq(true)
end
it "returns false if the node is not of the provided platforms" do
- node.automatic_attrs[:platform] = 'ubuntu'
+ node.automatic_attrs[:platform] = "ubuntu"
expect(platform_introspector.platform?(:splatlinux)).to eq(false)
end
end
@@ -143,17 +143,17 @@ shared_examples_for "a platform introspector" do
describe "when checking platform_family?" 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'
+ node.automatic_attrs[:platform_family] = "debian"
expect(platform_introspector.platform_family?([:rhel, :debian])).to eq(true)
end
it "returns true if the node is a provided platform and platforms are provided as strings" do
- node.automatic_attrs[:platform_family] = 'rhel'
+ node.automatic_attrs[:platform_family] = "rhel"
expect(platform_introspector.platform_family?(["rhel", "debian"])).to eq(true)
end
it "returns false if the node is not of the provided platforms" do
- node.automatic_attrs[:platform_family] = 'suse'
+ node.automatic_attrs[:platform_family] = "suse"
expect(platform_introspector.platform_family?(:splatlinux)).to eq(false)
end
@@ -176,13 +176,13 @@ shared_examples_for "a platform introspector" do
it "returns the correct default for a given platform" do
node.automatic_attrs[:platform] = "debian"
- node.automatic_attrs[:platform_version] = '9000'
+ node.automatic_attrs[:platform_version] = "9000"
expect(platform_introspector.value_for_platform(@platform_hash)).to eq([ :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'
+ node.automatic_attrs[:platform_version] = "4.0"
expect(platform_introspector.value_for_platform(@platform_hash)).to eq([:restart, :reload])
end
end
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 973cb047f7..82260b07df 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tmpdir'
+require "spec_helper"
+require "tmpdir"
if windows?
- require 'chef/win32/file'
+ require "chef/win32/file"
end
# Filesystem stubs
@@ -37,7 +37,7 @@ end
# forwards-vs-reverse slashes on windows sucks
def windows_path
- windows? ? normalized_path.gsub(/\\/, '/') : normalized_path
+ windows? ? normalized_path.gsub(/\\/, "/") : normalized_path
end
# this is all getting a bit stupid, CHEF-4802 cut to remove all this
@@ -460,7 +460,7 @@ shared_examples_for Chef::Provider::File do
before { setup_normal_file }
let(:tempfile) {
- t = double('Tempfile', :path => "/tmp/foo-bar-baz", :closed? => true)
+ t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true)
allow(content).to receive(:tempfile).and_return(t)
t
}
@@ -507,7 +507,7 @@ shared_examples_for Chef::Provider::File do
before do
setup_normal_file
provider.load_current_resource
- tempfile = double('Tempfile', :path => "/tmp/foo-bar-baz")
+ tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
allow(content).to receive(:tempfile).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true)
expect(tempfile).to receive(:close).once
@@ -520,7 +520,7 @@ shared_examples_for Chef::Provider::File do
let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" }
before do
allow(provider).to receive(:contents_changed?).and_return(true)
- diff = double('Diff', :for_output => ['+++','---','+foo','-bar'],
+ diff = double("Diff", :for_output => ["+++","---","+foo","-bar"],
:for_reporting => diff_for_reporting )
allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true)
expect(provider).to receive(:diff).at_least(:once).and_return(diff)
@@ -584,13 +584,13 @@ shared_examples_for Chef::Provider::File do
end
it "raises an exception when the content object returns a tempfile with a nil path" do
- tempfile = double('Tempfile', :path => nil)
+ tempfile = double("Tempfile", :path => nil)
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect{ provider.send(:do_contents_changes) }.to raise_error
end
it "raises an exception when the content object returns a tempfile that does not exist" do
- tempfile = double('Tempfile', :path => "/tmp/foo-bar-baz")
+ tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false)
expect{ provider.send(:do_contents_changes) }.to raise_error
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index 60b048975a..07fe1f772b 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -60,14 +60,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should set the option for #{attribute} if the new resources #{attribute} is not nil" do
allow(@new_resource).to receive(attribute).and_return("hola")
- expect(provider.universal_options).to eql([option, 'hola'])
+ expect(provider.universal_options).to eql([option, "hola"])
end
it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do
allow(@new_resource).to receive(:supports).and_return({:manage_home => false,
:non_unique => false})
allow(@new_resource).to receive(attribute).and_return("hola")
- expect(provider.universal_options).to eql([option, 'hola'])
+ expect(provider.universal_options).to eql([option, "hola"])
end
it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management (using real attributes)" do
@@ -75,7 +75,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
allow(@new_resource).to receive(:non_unique).and_return(false)
allow(@new_resource).to receive(:non_unique).and_return(false)
allow(@new_resource).to receive(attribute).and_return("hola")
- expect(provider.universal_options).to eql([option, 'hola'])
+ expect(provider.universal_options).to eql([option, "hola"])
end
end
@@ -83,7 +83,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
combined_opts = []
supported_useradd_options.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
allow(@new_resource).to receive(attribute).and_return("hola")
- combined_opts << option << 'hola'
+ combined_opts << option << "hola"
end
expect(provider.universal_options).to eql(combined_opts)
end
@@ -156,17 +156,17 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
provider.current_resource = @current_resource
provider.new_resource.manage_home true
provider.new_resource.home "/Users/mud"
- provider.new_resource.gid '23'
+ provider.new_resource.gid "23"
end
it "runs useradd with the computed command options" do
command = ["useradd",
- "-c", 'Adam Jacob',
- "-g", '23' ]
- command.concat(["-p", 'abracadabra']) if supported_useradd_options.key?("password")
- command.concat([ "-s", '/usr/bin/zsh',
- "-u", '1000',
- "-d", '/Users/mud',
+ "-c", "Adam Jacob",
+ "-g", "23" ]
+ command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password")
+ command.concat([ "-s", "/usr/bin/zsh",
+ "-u", "1000",
+ "-d", "/Users/mud",
"-m",
"adam" ])
expect(provider).to receive(:shell_out!).with(*command).and_return(true)
@@ -183,11 +183,11 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should not include -m or -d in the command options" do
command = ["useradd",
- "-c", 'Adam Jacob',
- "-g", '23']
- command.concat(["-p", 'abracadabra']) if supported_useradd_options.key?("password")
- command.concat([ "-s", '/usr/bin/zsh',
- "-u", '1000',
+ "-c", "Adam Jacob",
+ "-g", "23"]
+ command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password")
+ command.concat([ "-s", "/usr/bin/zsh",
+ "-u", "1000",
"-r",
"adam" ])
expect(provider).to receive(:shell_out!).with(*command).and_return(true)
@@ -202,15 +202,15 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
before(:each) do
provider.new_resource.manage_home true
provider.new_resource.home "/Users/mud"
- provider.new_resource.gid '23'
+ provider.new_resource.gid "23"
end
# CHEF-3423, -m must come before the username
# CHEF-4305, -d must come before -m to support CentOS/RHEL 5
it "runs usermod with the computed command options" do
command = ["usermod",
- "-g", '23',
- "-d", '/Users/mud',
+ "-g", "23",
+ "-d", "/Users/mud",
"-m",
"adam" ]
expect(provider).to receive(:shell_out!).with(*command).and_return(true)
@@ -220,8 +220,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "does not set the -r option to usermod" do
@new_resource.system(true)
command = ["usermod",
- "-g", '23',
- "-d", '/Users/mud',
+ "-g", "23",
+ "-d", "/Users/mud",
"-m",
"adam" ]
expect(provider).to receive(:shell_out!).with(*command).and_return(true)
@@ -231,7 +231,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "CHEF-3429: does not set -m if we aren't changing the home directory" do
expect(provider).to receive(:updating_home?).and_return(false)
command = ["usermod",
- "-g", '23',
+ "-g", "23",
"adam" ]
expect(provider).to receive(:shell_out!).with(*command).and_return(true)
provider.manage_user
@@ -307,7 +307,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
it "should raise a Chef::Exceptions::User if passwd -S fails on anything other than redhat/centos" do
- @node.automatic_attrs[:platform] = 'ubuntu'
+ @node.automatic_attrs[:platform] = "ubuntu"
expect(provider).to receive(:shell_out!).
with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
and_return(passwd_s_status)
@@ -315,7 +315,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
expect { provider.check_lock }.to raise_error(Chef::Exceptions::User)
end
- ['redhat', 'centos'].each do |os|
+ ["redhat", "centos"].each do |os|
it "should not raise a Chef::Exceptions::User if passwd -S exits with 1 on #{os} and the passwd package is version 0.73-1" do
@node.automatic_attrs[:platform] = os
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index 18ee94606e..60967f30a3 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
shared_examples_for "a script resource" do
@@ -49,18 +49,18 @@ shared_examples_for "a script resource" do
end
it "should raise an exception if users set command on the resource", :chef_gte_13_only do
- expect { script_resource.command('foo') }.to raise_error(Chef::Exceptions::Script)
+ expect { script_resource.command("foo") }.to raise_error(Chef::Exceptions::Script)
end
it "should not raise an exception if users set command on the resource", :chef_lt_13_only do
- expect { script_resource.command('foo') }.not_to raise_error
+ expect { script_resource.command("foo") }.not_to raise_error
end
describe "when executing guards" do
let(:resource) {
resource = script_resource
resource.run_context = run_context
- resource.code 'echo hi'
+ resource.code "echo hi"
resource
}
let(:node) {
@@ -83,7 +83,7 @@ shared_examples_for "a script resource" do
expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block)
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).not_to receive(:evaluate_action)
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:evaluate).and_return(true)
- resource.only_if 'echo hi'
+ resource.only_if "echo hi"
expect(resource.should_skip?(:run)).to eq(nil)
end
@@ -91,7 +91,7 @@ shared_examples_for "a script resource" do
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
resource.guard_interpreter :script
- resource.only_if 'echo hi'
+ resource.only_if "echo hi"
expect(resource.should_skip?(:run)).to eq(nil)
end
end
diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb
index a2fc884ff2..f32cdc6e50 100644
--- a/spec/support/shared/unit/windows_script_resource.rb
+++ b/spec/support/shared/unit/windows_script_resource.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'support/shared/unit/execute_resource'
-require 'support/shared/unit/script_resource'
+require "support/shared/unit/execute_resource"
+require "support/shared/unit/script_resource"
shared_examples_for "a Windows script resource" do
before(:each) do
@@ -51,7 +51,7 @@ shared_examples_for "a Windows script resource" do
it "should use a resource to evaluate the guard when guard_interpreter is not specified" do
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate)
- @resource.only_if 'echo hi'
+ @resource.only_if "echo hi"
expect(@resource.should_skip?(:run)).to eq(nil)
end