briandunn / flatware

A parallel test runner for RSpec and Cucumber with pretty output
MIT License
255 stars 35 forks source link

Using other rspec formatters #87

Open louim opened 2 months ago

louim commented 2 months ago

Hey @briandunn!

First, a big thanks for putting this gem together. I'd like to know how much work would be required to allow using other rspec formatters? I'm mostly interested about using a formatter that will immediately print failure in the while the specs are still running. Eg: https://github.com/thekompanee/fuubar or https://github.com/grosser/rspec-instafail.

Would it be something possible at all?

briandunn commented 1 month ago

Yes, this should totally be possible. There is already an API for implementing Flatware formatters. These are the methods that will be called on your formatter: https://github.com/briandunn/flatware/blob/master/lib/flatware/broadcaster.rb#L6-L13 Here is where the built in RSpec console formatter is instantiated: https://github.com/briandunn/flatware/blob/master/lib/flatware/rspec/cli.rb#L20-L23

Roughly the steps to implement one of those:

1) restore the formatter CLI option. 1) write an adapter from the Flatware events to the RSpec events, similar to https://github.com/briandunn/flatware/blob/master/lib/flatware/rspec/formatters/console.rb.

It may be possible to write a general adapter that make most rspec formatters work. that would be cool.