dcadenas-filetesthelper 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/file_test_helper.rb +3 -3
- data/spec/file_test_helper_spec.rb +4 -2
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/file_test_helper.rb
CHANGED
@@ -52,9 +52,9 @@ module FileTestHelper
|
|
52
52
|
return unless files_with_contents
|
53
53
|
files_with_contents.each do |path, file_contents|
|
54
54
|
raise ArguemntError, 'A path is not allowed to start with /' if path =~ /^\//
|
55
|
-
|
55
|
+
raise ArgumentError, 'A path is not allowed to contain ..' if path =~ /\.\./
|
56
56
|
|
57
|
-
|
57
|
+
dir, file = path.scan(/(.*[\/])?([^\/]*$)/)[0]
|
58
58
|
mkpath dir unless(dir.nil? or dir.empty?)
|
59
59
|
|
60
60
|
unless(file.nil? or file.empty?)
|
@@ -72,7 +72,7 @@ module FileTestHelper
|
|
72
72
|
cd base_dir
|
73
73
|
begin
|
74
74
|
files_with_contents.each do |path, file_contents|
|
75
|
-
remove_dir(path)
|
75
|
+
remove_dir(path.split(File::SEPARATOR).first)
|
76
76
|
end
|
77
77
|
ensure
|
78
78
|
cd initial_dir
|
@@ -103,9 +103,11 @@ describe FileTestHelper do
|
|
103
103
|
test_file = 'should_persist_after_test.txt'
|
104
104
|
begin
|
105
105
|
`touch #{test_file}`
|
106
|
-
with_files_in_directory(Dir.pwd, 'somefile.txt' => '') {}
|
106
|
+
with_files_in_directory(Dir.pwd, 'dir/somefile.txt' => '', 'anotherfile.txt' => '') {}
|
107
107
|
|
108
|
-
File.exist?('somefile.txt').should be_false
|
108
|
+
File.exist?('dir/somefile.txt').should be_false
|
109
|
+
File.exist?('anotherfile.txt').should be_false
|
110
|
+
File.exist?('dir').should be_false
|
109
111
|
File.exist?(test_file).should be_true
|
110
112
|
ensure
|
111
113
|
File.delete(test_file)
|