summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/application/base_spec.rb2
-rw-r--r--spec/unit/application_spec.rb6
-rw-r--r--spec/unit/compliance/input_spec.rb2
-rw-r--r--spec/unit/compliance/profile_spec.rb2
-rw-r--r--spec/unit/compliance/waiver_spec.rb4
-rw-r--r--spec/unit/data_collector_spec.rb2
-rw-r--r--spec/unit/file_content_management/deploy/mv_unix_spec.rb4
-rw-r--r--spec/unit/file_content_management/tempfile_spec.rb2
-rw-r--r--spec/unit/mixin/openssl_helper_spec.rb8
-rw-r--r--spec/unit/mixin/template_spec.rb4
-rw-r--r--spec/unit/monologger_spec.rb2
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb10
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb2
-rw-r--r--spec/unit/provider/user/solaris_spec.rb4
-rw-r--r--spec/unit/resource/inspec_input_spec.rb16
-rw-r--r--spec/unit/resource/inspec_waiver_spec.rb16
-rw-r--r--spec/unit/util/backup_spec.rb2
-rw-r--r--spec/unit/util/diff_spec.rb8
18 files changed, 48 insertions, 48 deletions
diff --git a/spec/unit/application/base_spec.rb b/spec/unit/application/base_spec.rb
index ce90464603..6f15064180 100644
--- a/spec/unit/application/base_spec.rb
+++ b/spec/unit/application/base_spec.rb
@@ -6,7 +6,7 @@ describe Chef::Application::Base, "setup_application" do
context "when validation key is supplied" do
before do
@app = Chef::Application::Base.new
- tempfile = Tempfile.new(validation_path)
+ tempfile = Tempfile.create(validation_path)
tempfile.write "string"
tempfile.close
@path = tempfile.path
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index b84f0c99f2..6014f16b8a 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -415,7 +415,7 @@ describe Chef::Application do
end
context "when cli arguments contain valid recipe file path" do
- let(:tempfile) { Tempfile.new("default.rb").path }
+ let(:tempfile) { Tempfile.create("default.rb").path }
before do
allow(app).to receive(:cli_arguments).and_return([tempfile])
end
@@ -478,7 +478,7 @@ describe Chef::Application do
context "when cli arguments contain valid recipe file path and invalid string" do
let(:fatal) { false }
before do
- tempfile = Tempfile.new("default.rb").path
+ tempfile = Tempfile.create("default.rb").path
allow(app).to receive(:cli_arguments).and_return([tempfile, "test"])
allow(Chef::Application).to receive(:fatal!).and_return(fatal)
end
@@ -504,7 +504,7 @@ describe Chef::Application do
describe "when config file exists but contains errors" do
def create_config_file(text)
- @config_file = Tempfile.new("rspec-chef-config")
+ @config_file = Tempfile.create("rspec-chef-config")
@config_file.write(text)
@config_file.close
@app.config[:config_file] = @config_file.path
diff --git a/spec/unit/compliance/input_spec.rb b/spec/unit/compliance/input_spec.rb
index a65adfb284..61b8f53fb7 100644
--- a/spec/unit/compliance/input_spec.rb
+++ b/spec/unit/compliance/input_spec.rb
@@ -90,7 +90,7 @@ ssh-01:
run: false
justification: "waived, yo"
EOH
- tempfile = Tempfile.new("chef-compliance-test")
+ tempfile = Tempfile.create("chef-compliance-test")
tempfile.write string
tempfile.close
newinput = Chef::Compliance::Input.from_file(events, tempfile.path, cookbook_name)
diff --git a/spec/unit/compliance/profile_spec.rb b/spec/unit/compliance/profile_spec.rb
index 8487b26691..c8ed5c7b40 100644
--- a/spec/unit/compliance/profile_spec.rb
+++ b/spec/unit/compliance/profile_spec.rb
@@ -106,7 +106,7 @@ version: 2.6.4#{" "}
supports:#{" "}
- os-family: unix
EOH
- tempfile = Tempfile.new("chef-compliance-test")
+ tempfile = Tempfile.create("chef-compliance-test")
tempfile.write string
tempfile.close
newprofile = Chef::Compliance::Profile.from_file(events, tempfile.path, cookbook_name)
diff --git a/spec/unit/compliance/waiver_spec.rb b/spec/unit/compliance/waiver_spec.rb
index e001e3a97d..27fdfbd95e 100644
--- a/spec/unit/compliance/waiver_spec.rb
+++ b/spec/unit/compliance/waiver_spec.rb
@@ -20,7 +20,7 @@ require "tempfile"
describe Chef::Compliance::Waiver do
let(:events) { Chef::EventDispatch::Dispatcher.new }
- let(:data) { { "ssh-01" => { "expiration_date" => Date.jd(2463810), "justification" => "waived, yo", "run" => false } } }
+ let(:data) { { "ssh-01" => { "expiration_date" => Date.jd(2463810), "run" => false, "justification" => "waived, yo" } } }
let(:path) { "/var/chef/cache/cookbooks/acme_compliance/compliance/waivers/default.yml" }
let(:cookbook_name) { "acme_compliance" }
let(:waiver) { Chef::Compliance::Waiver.new(events, data, path, cookbook_name) }
@@ -90,7 +90,7 @@ ssh-01:
run: false
justification: "waived, yo"
EOH
- tempfile = Tempfile.new("chef-compliance-test")
+ tempfile = Tempfile.create("chef-compliance-test")
tempfile.write string
tempfile.close
newwaiver = Chef::Compliance::Waiver.from_file(events, tempfile.path, cookbook_name)
diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb
index eb698d6661..2ca2fd3eb6 100644
--- a/spec/unit/data_collector_spec.rb
+++ b/spec/unit/data_collector_spec.rb
@@ -881,7 +881,7 @@ describe Chef::DataCollector do
end
describe "#send_to_file_location(file_name, message)" do
- let(:tempfile) { Tempfile.new("rspec-chef-datacollector-out") }
+ let(:tempfile) { Tempfile.create("rspec-chef-datacollector-out") }
let(:shift_jis) { "I have no idea what this character is:\n #{0x83.chr}#{0x80.chr}.\n" }
it "handles invalid UTF-8 properly" do
data_collector.send(:send_to_file_location, tempfile, { invalid: shift_jis })
diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
index a514667c71..2f90d03a55 100644
--- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
@@ -101,8 +101,8 @@ describe Chef::FileContentManagement::Deploy::MvUnix do
describe "when testing against real files", unix_only: true do
it "preserves sticky bits" do
- staging_file = Tempfile.new("staging_file")
- target_file = Tempfile.new("target_file")
+ staging_file = Tempfile.create("staging_file")
+ target_file = Tempfile.create("target_file")
File.chmod(04755, target_file.path)
content_deployer.deploy(staging_file.path, target_file.path)
expect(::File.stat(target_file.path).mode & 07777).to eql(04755)
diff --git a/spec/unit/file_content_management/tempfile_spec.rb b/spec/unit/file_content_management/tempfile_spec.rb
index 82d156eb3b..2e79442f84 100644
--- a/spec/unit/file_content_management/tempfile_spec.rb
+++ b/spec/unit/file_content_management/tempfile_spec.rb
@@ -23,7 +23,7 @@ describe Chef::FileContentManagement::Tempfile do
def tempfile_object_for_path(path)
r = Chef::Resource::File.new("decorative name that should not matter")
r.path path
- Chef::FileContentManagement::Tempfile.new(r)
+ Chef::FileContentManagement::Tempfile.create(r)
end
describe "#tempfile_basename" do
diff --git a/spec/unit/mixin/openssl_helper_spec.rb b/spec/unit/mixin/openssl_helper_spec.rb
index 7766e8f9b2..a534a18f6a 100644
--- a/spec/unit/mixin/openssl_helper_spec.rb
+++ b/spec/unit/mixin/openssl_helper_spec.rb
@@ -71,7 +71,7 @@ describe Chef::Mixin::OpenSSLHelper do
require "tempfile"
before(:each) do
- @dhparam_file = Tempfile.new("dhparam")
+ @dhparam_file = Tempfile.create("dhparam")
end
context "When the dhparam.pem file does not exist" do
@@ -110,7 +110,7 @@ describe Chef::Mixin::OpenSSLHelper do
cipher = ::OpenSSL::Cipher.new("des3")
before(:each) do
- @keyfile = Tempfile.new("keyfile")
+ @keyfile = Tempfile.create("keyfile")
end
context "When the key file does not exist" do
@@ -184,7 +184,7 @@ describe Chef::Mixin::OpenSSLHelper do
require "tempfile"
before(:each) do
- @crlfile = Tempfile.new("crlfile")
+ @crlfile = Tempfile.create("crlfile")
end
context "When the crl file doesnt not exist" do
@@ -852,7 +852,7 @@ describe Chef::Mixin::OpenSSLHelper do
require "tempfile"
before(:each) do
- @certfile = Tempfile.new("certfile")
+ @certfile = Tempfile.create("certfile")
end
context "When the cert file doesn't exist" do
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 63522839e9..938dd68928 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -105,7 +105,7 @@ describe Chef::Mixin::Template, "render_template" do
it "should render local files" do
- tf = Tempfile.new("partial")
+ tf = Tempfile.create("partial")
tf.write "test"
tf.rewind
@@ -125,7 +125,7 @@ describe Chef::Mixin::Template, "render_template" do
it "should render using the source argument if provided" do
- tf = Tempfile.new("partial")
+ tf = Tempfile.create("partial")
tf.write "test"
tf.rewind
diff --git a/spec/unit/monologger_spec.rb b/spec/unit/monologger_spec.rb
index 5448de32b2..7d9f10290c 100644
--- a/spec/unit/monologger_spec.rb
+++ b/spec/unit/monologger_spec.rb
@@ -36,7 +36,7 @@ describe MonoLogger do
describe "when given an object that is stringable (to_str)" do
it "should open a File object with the given path" do
- temp_file = Tempfile.new("rspec-monologger-log")
+ temp_file = Tempfile.create("rspec-monologger-log")
temp_file.close
MonoLogger.new(temp_file.path).fatal("Do, or do not. There is no try.")
expect(File.read(temp_file.path)).to match(/Do, or do not. There is no try./)
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index 7cf951498d..1afb9c4a7d 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -56,7 +56,7 @@ describe Chef::Provider::Ifconfig::Debian do
describe "generate_config" do
context "when writing a file" do
- let(:tempfile) { Tempfile.new("rspec-chef-ifconfig-debian") }
+ let(:tempfile) { Tempfile.create("rspec-chef-ifconfig-debian") }
let(:tempdir_path) { Dir.mktmpdir("rspec-chef-ifconfig-debian-dir") }
@@ -105,7 +105,7 @@ describe Chef::Provider::Ifconfig::Debian do
end
context "when the file is up-to-date" do
- let(:tempfile) { Tempfile.new("rspec-chef-ifconfig-debian") }
+ let(:tempfile) { Tempfile.create("rspec-chef-ifconfig-debian") }
let(:tempdir_path) { Dir.mktmpdir("rspec-chef-ifconfig-debian-dir") }
@@ -182,7 +182,7 @@ describe Chef::Provider::Ifconfig::Debian do
context "when writing a file" do
let(:config_file_ifcfg) { StringIO.new }
- let(:tempfile) { Tempfile.new("rspec-chef-ifconfig-debian") }
+ let(:tempfile) { Tempfile.create("rspec-chef-ifconfig-debian") }
let(:tempdir_path) { Dir.mktmpdir("rspec-chef-ifconfig-debian-dir") }
@@ -231,7 +231,7 @@ describe Chef::Provider::Ifconfig::Debian do
end
context "when the file is up-to-date" do
- let(:tempfile) { Tempfile.new("rspec-chef-ifconfig-debian") }
+ let(:tempfile) { Tempfile.create("rspec-chef-ifconfig-debian") }
let(:tempdir_path) { Dir.mktmpdir("rspec-chef-ifconfig-debian-dir") }
@@ -295,7 +295,7 @@ describe Chef::Provider::Ifconfig::Debian do
describe "delete_config for action_delete" do
- let(:tempfile) { Tempfile.new("rspec-chef-ifconfig-debian") }
+ let(:tempfile) { Tempfile.create("rspec-chef-ifconfig-debian") }
let(:tempdir_path) { Dir.mktmpdir("rspec-chef-ifconfig-debian-dir") }
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 4ca22b4b78..fc2919ee6a 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -77,7 +77,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
let(:vfstab_file) do
- t = Tempfile.new("rspec-vfstab")
+ t = Tempfile.create("rspec-vfstab")
t.write(vfstab_file_contents)
t.close
t
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index 58c3c0bd68..4ff3a8e48e 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -64,13 +64,13 @@ describe Chef::Provider::User::Solaris do
it "should write out a modified version of the password file" do
# Let this test run #write_shadow_file
allow(provider).to receive(:write_shadow_file).and_call_original
- password_file = Tempfile.new("shadow")
+ password_file = Tempfile.create("shadow")
password_file.puts "adam:existingpassword:15441::::::"
password_file.close
stub_const("Chef::Provider::User::Solaris::PASSWORD_FILE", password_file.path)
allow(provider).to receive(:shell_out_compacted!).and_return(true)
# may not be able to write to /etc for tests...
- temp_file = Tempfile.new("shadow")
+ temp_file = Tempfile.create("shadow")
allow(Tempfile).to receive(:new).with("shadow", "/etc").and_return(temp_file)
new_resource.password "verysecurepassword"
provider.manage_user
diff --git a/spec/unit/resource/inspec_input_spec.rb b/spec/unit/resource/inspec_input_spec.rb
index 4acdfd60a9..033147a729 100644
--- a/spec/unit/resource/inspec_input_spec.rb
+++ b/spec/unit/resource/inspec_input_spec.rb
@@ -153,7 +153,7 @@ ssh_custom_path = "/whatever2"
context "with a input in a file" do
it "loads a YAML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yaml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yaml"])
tempfile.write input_yaml
tempfile.close
resource.name tempfile.path
@@ -169,7 +169,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a YAML file in a source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yaml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yaml"])
tempfile.write input_yaml
tempfile.close
resource.name "my-resource-name"
@@ -186,7 +186,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a YML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yml"])
tempfile.write input_yaml
tempfile.close
resource.name tempfile.path
@@ -202,7 +202,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a YML file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yml"])
tempfile.write input_yaml
tempfile.close
resource.name "my-resource-name"
@@ -219,7 +219,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a JSON file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".json"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".json"])
tempfile.write input_json
tempfile.close
resource.name tempfile.path
@@ -235,7 +235,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a JSON file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".json"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".json"])
tempfile.write input_json
tempfile.close
resource.name "my-resource-name"
@@ -252,7 +252,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a TOML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".toml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".toml"])
tempfile.write input_toml
tempfile.close
resource.name tempfile.path
@@ -268,7 +268,7 @@ ssh_custom_path = "/whatever2"
end
it "loads a TOML file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".toml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".toml"])
tempfile.write input_toml
tempfile.close
resource.name "my-resource-name"
diff --git a/spec/unit/resource/inspec_waiver_spec.rb b/spec/unit/resource/inspec_waiver_spec.rb
index 3154bcc9fa..4b6119724d 100644
--- a/spec/unit/resource/inspec_waiver_spec.rb
+++ b/spec/unit/resource/inspec_waiver_spec.rb
@@ -165,7 +165,7 @@ justification = "waived, yo"
context "with a waiver in a file" do
it "loads a YAML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yaml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yaml"])
tempfile.write waiver_yaml
tempfile.close
resource.name tempfile.path
@@ -181,7 +181,7 @@ justification = "waived, yo"
end
it "loads a YAML file in a source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yaml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yaml"])
tempfile.write waiver_yaml
tempfile.close
resource.name "my-resource-name"
@@ -198,7 +198,7 @@ justification = "waived, yo"
end
it "loads a YML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yml"])
tempfile.write waiver_yaml
tempfile.close
resource.name tempfile.path
@@ -214,7 +214,7 @@ justification = "waived, yo"
end
it "loads a YML file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".yml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".yml"])
tempfile.write waiver_yaml
tempfile.close
resource.name "my-resource-name"
@@ -231,7 +231,7 @@ justification = "waived, yo"
end
it "loads a JSON file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".json"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".json"])
tempfile.write waiver_json
tempfile.close
resource.name tempfile.path
@@ -247,7 +247,7 @@ justification = "waived, yo"
end
it "loads a JSON file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".json"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".json"])
tempfile.write waiver_json
tempfile.close
resource.name "my-resource-name"
@@ -264,7 +264,7 @@ justification = "waived, yo"
end
it "loads a TOML file" do
- tempfile = Tempfile.new(["spec-compliance-test", ".toml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".toml"])
tempfile.write waiver_toml
tempfile.close
resource.name tempfile.path
@@ -280,7 +280,7 @@ justification = "waived, yo"
end
it "loads a TOML file using the source attribute" do
- tempfile = Tempfile.new(["spec-compliance-test", ".toml"])
+ tempfile = Tempfile.create(["spec-compliance-test", ".toml"])
tempfile.write waiver_toml
tempfile.close
resource.name "my-resource-name"
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index d7a57dce1a..37b584fa7b 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -22,7 +22,7 @@ require "tmpdir"
describe Chef::Util::Backup do
let(:tempfile) do
- Tempfile.new("chef-util-backup-spec-test")
+ Tempfile.create("chef-util-backup-spec-test")
end
before(:each) do
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index d1440dbaaa..da7867a4f1 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -20,13 +20,13 @@ require "spec_helper"
require "tmpdir"
shared_context "using file paths with spaces" do
- let!(:old_tempfile) { Tempfile.new("chef-util diff-spec") }
- let!(:new_tempfile) { Tempfile.new("chef-util diff-spec") }
+ let!(:old_tempfile) { Tempfile.create("chef-util diff-spec") }
+ let!(:new_tempfile) { Tempfile.create("chef-util diff-spec") }
end
shared_context "using file paths without spaces" do
- let!(:old_tempfile) { Tempfile.new("chef-util-diff-spec") }
- let!(:new_tempfile) { Tempfile.new("chef-util-diff-spec") }
+ let!(:old_tempfile) { Tempfile.create("chef-util-diff-spec") }
+ let!(:new_tempfile) { Tempfile.create("chef-util-diff-spec") }
end
shared_examples_for "a diff util" do