Last active
August 29, 2015 14:02
-
-
Save vargonaut/2ba19873177e3b7fedf2 to your computer and use it in GitHub Desktop.
A simple RSpec formatter to give you the example file and line, along with a description and status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rspec/core/formatters/base_text_formatter' | |
| # RSpec 2 | |
| # rspec --require <path_to>/line_formatter.rb --format LineFormatter spec/ | |
| # ./spec/lib/a_spec.rb:39 | |
| # Success Thing#with_thing does thing | |
| # | |
| # ./spec/lib/a_spec.rb:45 | |
| # pending Thing#does_other_thing is pending | |
| # | |
| # ./spec/lib/a_spec.rb:67 | |
| # FAILURE Thing#should_never_happen fails | |
| # | |
| # < summary, blah blah> | |
| class LineFormatter < RSpec::Core::Formatters::BaseTextFormatter | |
| def example_started(example) | |
| super(example) | |
| output.puts example.location | |
| end | |
| def example_passed(example) | |
| super(example) | |
| output.print success_color('Success ') | |
| output.puts example.full_description | |
| output.puts | |
| end | |
| def example_pending(example) | |
| super(example) | |
| output.print pending_color('pending ') | |
| output.puts example.full_description | |
| output.puts | |
| end | |
| def example_failed(example) | |
| super(example) | |
| output.print failure_color('FAILURE ') | |
| output.puts example.full_description | |
| output.puts | |
| end | |
| def start_dump | |
| super() | |
| output.puts | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment