Skip to content

Instantly share code, notes, and snippets.

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 capitalist/313503 to your computer and use it in GitHub Desktop.
Save capitalist/313503 to your computer and use it in GitHub Desktop.
require 'spec/runner/formatter/progress_bar_formatter'
# Put this in spec/support and run with:
# spec spec --require spec/support/no_shoulds_punk_formatter.rb --format NoShouldsPunkFormatter
class NoShouldsPunkFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def initialize(options, output)
super
@examples_with_should = []
end
def example_group_started(example_group_proxy)
@example_group = example_group_proxy
end
def example_started(example)
if example.description && example.description.starts_with?("should")
@examples_with_should << ["#{@example_group.description} #{example.description}", example.location]
end
end
def dump_summary(duration, example_count, failure_count, pending_count)
super
print_list_of_examples_with_should if @examples_with_should.any?
end
private
def print_list_of_examples_with_should
@output.puts
@output.puts "You think you got off easy punk? Well what about:"
@examples_with_should.each do |example|
@output.puts "\n#{example[0]}"
@output.puts "#{example[1]}\n"
end
@output.puts
@output.puts "You big pansy."
@output.flush
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment