Skip to content

Instantly share code, notes, and snippets.

@davidoram
Created August 19, 2015 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidoram/b938e800271f31119e44 to your computer and use it in GitHub Desktop.
Save davidoram/b938e800271f31119e44 to your computer and use it in GitHub Desktop.
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