Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rspec 2 formatter to output files in the order they are tested
#
# Rspec 2.x custom formatter that will run all your tests and output a list of spec files that have been run
#
# Can be usefull for extracting all of the files that nmake up the test run
#
# TZ=Pacific/Auckland bundle exec rspec spec --tag ~integration --tag ~fragile --require ./custom_formatter.rb --format CustomFormatter --out specs.txt --seed 34104
#
require "rspec/core/formatters/base_text_formatter"
require 'JSON'
class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
def initialize(output)
super(output)
@files = []
end
def example_started(proxy)
@files << proxy.file_path unless @files.include? proxy.file_path
end
def dump_summary(duration, example_count, failure_count, pending_count)
@files.each do |f|
output << f
output << "\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment