lib/watirsplash/html_formatter.rb in watirsplash-0.2.2 vs lib/watirsplash/html_formatter.rb in watirsplash-0.2.3

- old
+ new

@@ -17,17 +17,14 @@ attr_writer :browser def initialize(options, output) # :nodoc: raise "output has to be a file path!" unless output.is_a?(String) @output_dir = File.expand_path(File.dirname(output)) + archive_results + puts "Results will be saved into the directory #{@output_dir}" @files_dir = File.join(@output_dir, "files") - if File.exists?(@output_dir) - archive_dir = File.join(@output_dir, "../archive") - FileUtils.mkdir_p(archive_dir) unless File.exists?(archive_dir) - FileUtils.mv @output_dir, File.join(archive_dir, "#{File.basename(@output_dir)}_#{File.mtime(@output_dir).strftime("%y%m%d_%H%M%S")}") - end FileUtils.mkdir_p(@files_dir) @files_saved_during_example = [] super end @@ -112,9 +109,19 @@ extension = File.extname(file_name) basename = File.basename(file_name, extension) file_path = File.join(@files_dir, "#{basename}_#{Time.now.strftime("%H%M%S")}_#{example_group_number}_#{example_number}#{extension}") @files_saved_during_example.unshift(:desc => description, :path => file_path) file_path + end + + private + + def archive_results + if File.exists?(@output_dir) + archive_dir = File.join(@output_dir, "../archive") + FileUtils.mkdir_p(archive_dir) unless File.exists?(archive_dir) + FileUtils.mv @output_dir, File.join(archive_dir, "#{File.basename(@output_dir)}_#{File.mtime(@output_dir).strftime("%y%m%d_%H%M%S")}") + end end end end \ No newline at end of file