features/support/test_server_files.rb in ftpd-0.2.1 vs features/support/test_server_files.rb in ftpd-0.2.2

- old
+ new

@@ -2,11 +2,11 @@ def add_file(path) full_path = temp_path(path) mkdir_p File.dirname(full_path) File.open(full_path, 'wb') do |file| - file.puts @templates[File.basename(full_path)] + file.write @templates[File.basename(full_path)] end end def add_directory(path) full_path = temp_path(path) @@ -16,10 +16,23 @@ def has_file?(path) full_path = temp_path(path) File.exists?(full_path) end + def has_file_with_contents_of?(path) + expected_contents = @templates[File.basename(path)] + all_paths.any? do |path| + File.open(path, 'rb', &:read) == expected_contents + end + end + + def files_named_like(name) + all_paths.select do |path| + path.include?(name) + end + end + def has_directory?(path) full_path = temp_path(path) File.directory?(full_path) end @@ -28,8 +41,12 @@ File.open(full_path, 'rb', &:read) end def temp_path(path) File.expand_path(path, temp_dir) + end + + def all_paths + Dir[temp_path('**/*')] end end