summaryrefslogtreecommitdiff
path: root/spec/unit/chef_fs/diff_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/chef_fs/diff_spec.rb')
-rw-r--r--spec/unit/chef_fs/diff_spec.rb108
1 files changed, 54 insertions, 54 deletions
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index d946fcb9e7..726adf8e50 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,70 +20,70 @@ require "spec_helper"
require "chef/chef_fs/file_pattern"
require "chef/chef_fs/command_line"
-# Removes the date stamp from the diff and replaces it with ' DATE'
-# example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000"
-# windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012"
-def remove_os_differences(diff)
- diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE')
- diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS")
-end
-
-describe "diff", :uses_diff => true do
+describe "diff", uses_diff: true do
include FileSystemSupport
+ # Removes the date stamp from the diff and replaces it with ' DATE'
+ # example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000"
+ # windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012"
+ def remove_os_differences(diff)
+ diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE')
+ diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS")
+ end
+
context "with two filesystems with all types of difference" do
let(:a) do
memory_fs("a", {
- :both_dirs => {
- :sub_both_dirs => { :subsub => nil },
- :sub_both_files => nil,
- :sub_both_files_different => "a\n",
- :sub_both_dirs_empty => {},
- :sub_dirs_empty_in_a_filled_in_b => {},
- :sub_dirs_empty_in_b_filled_in_a => { :subsub => nil },
- :sub_a_only_dir => { :subsub => nil },
- :sub_a_only_file => nil,
- :sub_dir_in_a_file_in_b => {},
- :sub_file_in_a_dir_in_b => nil,
+ both_dirs: {
+ sub_both_dirs: { subsub: nil },
+ sub_both_files: nil,
+ sub_both_files_different: "a\n",
+ sub_both_dirs_empty: {},
+ sub_dirs_empty_in_a_filled_in_b: {},
+ sub_dirs_empty_in_b_filled_in_a: { subsub: nil },
+ sub_a_only_dir: { subsub: nil },
+ sub_a_only_file: nil,
+ sub_dir_in_a_file_in_b: {},
+ sub_file_in_a_dir_in_b: nil,
},
- :both_files => nil,
- :both_files_different => "a\n",
- :both_dirs_empty => {},
- :dirs_empty_in_a_filled_in_b => {},
- :dirs_empty_in_b_filled_in_a => { :subsub => nil },
- :dirs_in_a_cannot_be_in_b => {},
- :file_in_a_cannot_be_in_b => nil,
- :a_only_dir => { :subsub => nil },
- :a_only_file => nil,
- :dir_in_a_file_in_b => {},
- :file_in_a_dir_in_b => nil,
+ both_files: nil,
+ both_files_different: "a\n",
+ both_dirs_empty: {},
+ dirs_empty_in_a_filled_in_b: {},
+ dirs_empty_in_b_filled_in_a: { subsub: nil },
+ dirs_in_a_cannot_be_in_b: {},
+ file_in_a_cannot_be_in_b: nil,
+ a_only_dir: { subsub: nil },
+ a_only_file: nil,
+ dir_in_a_file_in_b: {},
+ file_in_a_dir_in_b: nil,
}, /cannot_be_in_a/)
end
let(:b) do
memory_fs("b", {
- :both_dirs => {
- :sub_both_dirs => { :subsub => nil },
- :sub_both_files => nil,
- :sub_both_files_different => "b\n",
- :sub_both_dirs_empty => {},
- :sub_dirs_empty_in_a_filled_in_b => { :subsub => nil },
- :sub_dirs_empty_in_b_filled_in_a => {},
- :sub_b_only_dir => { :subsub => nil },
- :sub_b_only_file => nil,
- :sub_dir_in_a_file_in_b => nil,
- :sub_file_in_a_dir_in_b => {},
+ both_dirs: {
+ sub_both_dirs: { subsub: nil },
+ sub_both_files: nil,
+ sub_both_files_different: "b\n",
+ sub_both_dirs_empty: {},
+ sub_dirs_empty_in_a_filled_in_b: { subsub: nil },
+ sub_dirs_empty_in_b_filled_in_a: {},
+ sub_b_only_dir: { subsub: nil },
+ sub_b_only_file: nil,
+ sub_dir_in_a_file_in_b: nil,
+ sub_file_in_a_dir_in_b: {},
},
- :both_files => nil,
- :both_files_different => "b\n",
- :both_dirs_empty => {},
- :dirs_empty_in_a_filled_in_b => { :subsub => nil },
- :dirs_empty_in_b_filled_in_a => {},
- :dirs_in_b_cannot_be_in_a => {},
- :file_in_b_cannot_be_in_a => nil,
- :b_only_dir => { :subsub => nil },
- :b_only_file => nil,
- :dir_in_a_file_in_b => nil,
- :file_in_a_dir_in_b => {},
+ both_files: nil,
+ both_files_different: "b\n",
+ both_dirs_empty: {},
+ dirs_empty_in_a_filled_in_b: { subsub: nil },
+ dirs_empty_in_b_filled_in_a: {},
+ dirs_in_b_cannot_be_in_a: {},
+ file_in_b_cannot_be_in_a: nil,
+ b_only_dir: { subsub: nil },
+ b_only_file: nil,
+ dir_in_a_file_in_b: nil,
+ file_in_a_dir_in_b: {},
}, /cannot_be_in_b/)
end
it "Chef::ChefFS::CommandLine.diff_print(/)" do