rspecguard

How to silence RSpec's "Failed Examples..." and "Finished in..." output


I'm using RSpec within Guard, which runs it automatically when I edit a file. For me, the list of failed examples is just noise. I'd like to trim down the output. But I can't figure out which part of RSpec is responsible for it (formatter? core?) and then, how to silence it.

I marked up the output:

enter image description here

I'd like to silence the green altogether. And either silence or reduce down the blue area to just a few words. (In case you're wondering why: I'd like to run Guard in just a tiny window, maybe at the bottom of my IDE. But these extra lines cause the failure details to scroll up out of view. And they're unnecessary when running in this way.)

I looked through all the Guard and RSpec docs and can't find options that deal with these. I get this same output from several RSpec output formatters. So I'm not sure if it's core RSpec outputting this, or the formatter.


Solution

  • Put this file into your spec folder:

    # spec/my_formatter.rb
    
    class MyFormatter < RSpec::Core::Formatters::ProgressFormatter
      RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
      def dump_summary *args; end
    end
    

    Then rspec -f MyFormatter ftw.