summaryrefslogtreecommitdiff
path: root/spec/support/shared/functional
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared/functional')
-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
7 files changed, 92 insertions, 92 deletions
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