summaryrefslogtreecommitdiff
path: root/spec/support/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared')
-rw-r--r--spec/support/shared/context/client.rb5
-rw-r--r--spec/support/shared/functional/file_resource.rb8
-rw-r--r--spec/support/shared/functional/http.rb32
-rw-r--r--spec/support/shared/functional/win32_service.rb8
-rw-r--r--spec/support/shared/shared_examples.rb4
-rw-r--r--spec/support/shared/unit/api_versioning.rb4
-rw-r--r--spec/support/shared/unit/application_dot_d.rb15
-rw-r--r--spec/support/shared/unit/provider/file.rb4
-rw-r--r--spec/support/shared/unit/resource/static_provider_resolution.rb4
-rw-r--r--spec/support/shared/unit/script_resource.rb8
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb8
11 files changed, 52 insertions, 48 deletions
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index d8676ef168..b0530ab497 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -230,8 +230,9 @@ shared_context "audit phase failed with error" do
end
shared_context "audit phase completed with failed controls" do
- let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) }
+ let(:audit_runner) do
+ instance_double("Chef::Audit::Runner", :failed? => true,
+ :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/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index ec515e2e91..eb7a378db9 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -400,9 +400,9 @@ shared_examples_for "a configured file resource" do
end
context "when the target file is a symlink", :not_supported_on_win2k3 do
- let(:symlink_target) {
+ let(:symlink_target) do
File.join(CHEF_SPEC_DATA, "file-test-target")
- }
+ end
describe "when configured not to manage symlink's target" do
before(:each) do
@@ -820,9 +820,9 @@ shared_examples_for "a configured file resource" do
end
describe "when path is specified with windows separator", :windows_only do
- let(:path) {
+ let(:path) do
File.join(test_file_dir, make_tmpname(file_base)).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)
- }
+ end
before do
@notified_resource = Chef::Resource.new("punk", resource.run_context)
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 7e9e3f34c5..76faaaed47 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -52,27 +52,27 @@ module ChefHTTPShared
# just a normal file
# (expected_content should be uncompressed)
- @api.get("/nyan_cat.png", 200) {
+ @api.get("/nyan_cat.png", 200) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ 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" } ) {
+ @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
- }
+ 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" } ) {
+ @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
- }
+ end
#
# endpoints that set Content-Length correctly
@@ -83,11 +83,11 @@ module ChefHTTPShared
{
"Content-Length" => nyan_uncompressed_size.to_s,
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_content_length_compressed.png", 200, nil,
@@ -96,11 +96,11 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}
- ) {
+ ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# endpoints that simulate truncated downloads (bad content-length header)
@@ -111,11 +111,11 @@ module ChefHTTPShared
{
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_truncated_compressed.png", 200, nil,
@@ -124,11 +124,11 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}
- ) {
+ ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
@@ -140,11 +140,11 @@ module ChefHTTPShared
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
"Transfer-Encoding" => "anything",
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# 403 with a Content-Length
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index f9cc43d3f9..3199caa34f 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -37,7 +37,7 @@ shared_context "using Win32::Service" do
# Definition for the test-service
- let(:test_service) {
+ let(:test_service) do
{
:service_name => "spec-service",
:service_display_name => "Spec Test Service",
@@ -45,13 +45,13 @@ shared_context "using Win32::Service" do
:service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
:delayed_start => true,
}
- }
+ end
# Test service creates a file for us to verify that it is running.
# Since our test service is running as Local System we should look
# for the file it creates under SYSTEM temp directory
- let(:test_service_file) {
+ let(:test_service_file) do
"#{ENV['SystemDrive']}\\windows\\temp\\spec_service_file"
- }
+ end
end
diff --git a/spec/support/shared/shared_examples.rb b/spec/support/shared/shared_examples.rb
index 550fa2eb68..0c031bbafd 100644
--- a/spec/support/shared/shared_examples.rb
+++ b/spec/support/shared/shared_examples.rb
@@ -3,9 +3,9 @@
# Any object which defines a .to_json should import this test
shared_examples "to_json equivalent to Chef::JSONCompat.to_json" do
- let(:jsonable) {
+ let(:jsonable) do
raise "You must define the subject when including this test"
- }
+ end
it "should allow consumers to call #to_json or Chef::JSONCompat.to_json" do
expect(jsonable.to_json).to eq(Chef::JSONCompat.to_json(jsonable))
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index b61469a2d0..28141b73b1 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -43,13 +43,13 @@ shared_examples_for "user and client reregister" do
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
let(:max_version) { "5" }
- let(:return_hash_406) {
+ let(:return_hash_406) do
{
"min_version" => min_version,
"max_version" => max_version,
"request_version" => "30",
}
- }
+ end
context "when V0 is not supported by the server" do
context "when the exception is 406 and returns x-ops-server-api-version header" do
diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb
index a8769d6d03..da4eb88edd 100644
--- a/spec/support/shared/unit/application_dot_d.rb
+++ b/spec/support/shared/unit/application_dot_d.rb
@@ -31,8 +31,9 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory with configuration" do
# We're not going to mock out globbing the directory. We want to
# make sure that we are correctly globbing.
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../../data/client.d_00")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ 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")
@@ -45,8 +46,9 @@ shared_examples_for "an application that loads a dot d" do
end
context "when client_d_dir is set to a directory without configuration" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ 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,
@@ -60,8 +62,9 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory containing a directory named foo.rb" do
# foo.rb as a directory should be ignored
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_02")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ 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/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index cb539ffbc3..394fdaa02f 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -459,11 +459,11 @@ shared_examples_for Chef::Provider::File do
context "do_validate_content" do
before { setup_normal_file }
- let(:tempfile) {
+ let(:tempfile) do
t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true)
allow(content).to receive(:tempfile).and_return(t)
t
- }
+ end
context "with user-supplied verifications" do
it "calls #verify on each verification with tempfile path" do
diff --git a/spec/support/shared/unit/resource/static_provider_resolution.rb b/spec/support/shared/unit/resource/static_provider_resolution.rb
index 4ae5d4576f..e68b805d7d 100644
--- a/spec/support/shared/unit/resource/static_provider_resolution.rb
+++ b/spec/support/shared/unit/resource/static_provider_resolution.rb
@@ -33,13 +33,13 @@ def static_provider_resolution(opts = {})
platform_version = opts[:platform_version]
describe resource_class, "static provider initialization" do
- let(:node) {
+ let(:node) do
node = Chef::Node.new
node.automatic_attrs[:os] = os
node.automatic_attrs[:platform_family] = platform_family
node.automatic_attrs[:platform_version] = platform_version
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:resource) { resource_class.new("foo", run_context) }
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index 732b07d4ef..27864e1625 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -57,18 +57,18 @@ shared_examples_for "a script resource" do
end
describe "when executing guards" do
- let(:resource) {
+ let(:resource) do
resource = script_resource
resource.run_context = run_context
resource.code "echo hi"
resource
- }
- let(:node) {
+ end
+ let(:node) do
node = Chef::Node.new
node.automatic[:platform] = "debian"
node.automatic[:platform_version] = "6.0"
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index e3481dfeca..6c31ca22d1 100644
--- a/spec/support/shared/unit/user_and_client_shared.rb
+++ b/spec/support/shared/unit/user_and_client_shared.rb
@@ -55,13 +55,13 @@ shared_examples_for "user or client create" do
end
context "when chef_key is returned by the server" do
- let(:chef_key) {
+ let(:chef_key) do
{
"chef_key" => {
"public_key" => "some_public_key",
},
}
- }
+ end
it "puts the public key into the objectr returned by create" do
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))
@@ -70,14 +70,14 @@ shared_examples_for "user or client create" do
end
context "when private_key is returned in chef_key" do
- let(:chef_key) {
+ let(:chef_key) do
{
"chef_key" => {
"public_key" => "some_public_key",
"private_key" => "some_private_key",
},
}
- }
+ end
it "puts the private key into the object returned by create" do
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))