class RspecN::Formatters::FileFormatter
Constants
- BASE_FILE_NAME
Public Class Methods
new(runner:)
click to toggle source
# File lib/rspec_n/formatters/file_formatter.rb, line 8 def initialize(runner:) @runner = runner @format = "%m/%d %l:%M:%S %p" delete_all_files end
Public Instance Methods
delete_all_files()
click to toggle source
# File lib/rspec_n/formatters/file_formatter.rb, line 14 def delete_all_files log_directory = Pathname.new(@runner.input.log_path) Dir.glob(log_directory.join("#{BASE_FILE_NAME}.**")).each { |file| File.delete(file) } end
write(run, command)
click to toggle source
# File lib/rspec_n/formatters/file_formatter.rb, line 19 def write(run, command) return if run.skipped? return unless @runner.input.write_files? log_directory = Pathname.new(@runner.input.log_path) FileUtils.mkdir_p(log_directory) file_path = log_directory.join("#{BASE_FILE_NAME}.#{run.iteration}") File.open(file_path, "w") do |f| f.write("Iteration: #{run.iteration}\n") f.write("Start Time: #{run.formatted_start_time(@format)}\n") f.write("Finish Time: #{run.formatted_finish_time(@format)}\n") f.write("Duration: #{convert_seconds_to_hms(run.duration_seconds)}\n") f.write("Command: #{command}\n\n") f.write(run.rspec_stdout) f.write(run.rspec_stderr) end end