summaryrefslogtreecommitdiff
path: root/spec/unit/provider/remote_directory_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/remote_directory_spec.rb')
-rw-r--r--spec/unit/provider/remote_directory_spec.rb82
1 files changed, 41 insertions, 41 deletions
diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb
index 6426dafd79..0103169e84 100644
--- a/spec/unit/provider/remote_directory_spec.rb
+++ b/spec/unit/provider/remote_directory_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'digest/md5'
-require 'tmpdir'
-require 'chef/mixin/file_class'
+require "spec_helper"
+require "digest/md5"
+require "tmpdir"
+require "chef/mixin/file_class"
class Chef::CFCCheck
include Chef::Mixin::FileClass
@@ -32,7 +32,7 @@ describe Chef::Provider::RemoteDirectory do
@resource = Chef::Resource::RemoteDirectory.new(File.join(Dir.tmpdir, "tafty"))
# in CHEF_SPEC_DATA/cookbooks/openldap/files/default/remotedir
@resource.source "remotedir"
- @resource.cookbook('openldap')
+ @resource.cookbook("openldap")
@cookbook_repo = ::File.expand_path(::File.join(CHEF_SPEC_DATA, "cookbooks"))
Chef::Cookbook::FileVendor.fetch_from_disk(@cookbook_repo)
@@ -121,12 +121,12 @@ describe Chef::Provider::RemoteDirectory do
it "transfers the directory with all contents" do
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/.a_dotfile')).to be_truthy
- expect(::File.exist?(@destination_dir + '/.a_dotdir/.a_dotfile_in_a_dotdir')).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/.a_dotfile")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/.a_dotdir/.a_dotfile_in_a_dotdir")).to be_truthy
end
describe "only if it is missing" do
@@ -134,15 +134,15 @@ describe Chef::Provider::RemoteDirectory do
@resource.overwrite(true)
@provider.run_action(:create)
- File.open(@destination_dir + '/remote_dir_file1.txt', 'a') {|f| f.puts "blah blah blah" }
- File.open(@destination_dir + '/remotesubdir/remote_subdir_file1.txt', 'a') {|f| f.puts "blah blah blah" }
- file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + '/remote_dir_file1.txt'))
- subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt'))
+ File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt"))
+ subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt"))
@provider.run_action(:create_if_missing)
- expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy
- expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy
+ expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy
+ expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy
end
end
@@ -151,35 +151,35 @@ describe Chef::Provider::RemoteDirectory do
it "removes existing files if purge is true" do
@provider.run_action(:create)
- FileUtils.touch(@destination_dir + '/marked_for_death.txt')
- FileUtils.touch(@destination_dir + '/remotesubdir/marked_for_death_again.txt')
+ FileUtils.touch(@destination_dir + "/marked_for_death.txt")
+ FileUtils.touch(@destination_dir + "/remotesubdir/marked_for_death_again.txt")
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy
- expect(::File.exist?(@destination_dir + '/marked_for_death.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/remotesubdir/marked_for_death_again.txt')).to be_falsey
+ expect(::File.exist?(@destination_dir + "/marked_for_death.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/remotesubdir/marked_for_death_again.txt")).to be_falsey
end
it "removes files in subdirectories before files above" do
@provider.run_action(:create)
- FileUtils.mkdir_p(@destination_dir + '/a/multiply/nested/directory/')
- FileUtils.touch(@destination_dir + '/a/foo.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/bar.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/nested/baz.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/nested/directory/qux.txt')
+ FileUtils.mkdir_p(@destination_dir + "/a/multiply/nested/directory/")
+ FileUtils.touch(@destination_dir + "/a/foo.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/bar.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/nested/baz.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/nested/directory/qux.txt")
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/a/foo.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/bar.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/nested/baz.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/nested/directory/qux.txt')).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/foo.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/bar.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/nested/baz.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/nested/directory/qux.txt")).to be_falsey
end
it "removes directory symlinks properly", :not_supported_on_win2k3 do
- symlinked_dir_path = @destination_dir + '/symlinked_dir'
+ symlinked_dir_path = @destination_dir + "/symlinked_dir"
@provider.action = :create
@provider.run_action
@@ -207,13 +207,13 @@ describe Chef::Provider::RemoteDirectory do
it "leaves modifications alone" do
@provider.run_action(:create)
- ::File.open(@destination_dir + '/remote_dir_file1.txt', 'a') {|f| f.puts "blah blah blah" }
- ::File.open(@destination_dir + '/remotesubdir/remote_subdir_file1.txt', 'a') {|f| f.puts "blah blah blah" }
- file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt'))
- subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt'))
+ ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt"))
+ subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt"))
@provider.run_action(:create)
- expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy
- expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy
+ expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy
+ expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy
end
end