Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save capitalist/313503 to your computer and use it in GitHub Desktop.

Select an option

Save capitalist/313503 to your computer and use it in GitHub Desktop.

Revisions

  1. @thechrisoshow thechrisoshow created this gist Feb 24, 2010.
    44 changes: 44 additions & 0 deletions no_shoulds_punk_formatter.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    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