# require 'rspec/core/formatters/base_formatter'
#
# # NOT A FINISHED PRODUCT.
# # Ceasing development due to concerns of how this will handle when we run in Parallel
# # Running in Parallel will call this multiple times and delete the other failures. Not good
#
#
# module RSpec
#   module Failures
#     class Formatter < RSpec::Core::Formatters::BaseFormatter
#       RSpec::Core::Formatters.register self, :dump_failures
#
#       def dump_failures(notification)
#         output = ''
#         failures = notification.failed_examples
#
#         if failures.length > 0 # If there are failures
#           failures.each do |example| # Loop through each failure
#             output << example.full_description << "\n" # Append the description of the failure to an output string
#           end
#
#           delete_file # Destroy any previous failure file
#           write_file(output) # Write the above output to a file
#         else # No failures, safe to delete
#           delete_file
#         end
#       end
#
#       def write_file(output)
#         open('output/output.failures', 'w') { |f|
#           f.print output.strip
#         }
#
#         puts 'Wrote file'
#         puts 'Entries For output folder'
#         puts Dir.entries('output')
#         puts "\n\n"
#       end
#
#       def delete_file()
#         if File.exists?('output/output.failures')
#           File.delete('output/output.failures')
#           puts 'Deleted File'
#         end
#       end
#     end
#   end
# end
