-
-
Save chumpy/2fa4713e8d53e7043149d5c35db80556 to your computer and use it in GitHub Desktop.
When you're having a bad day and just want to skip every failing RSpec test
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
# frozen_string_literal: true | |
class CustomFormatter | |
RSpec::Core::Formatters.register self, :example_failed | |
def initialize(output) | |
@output = output | |
end | |
def example_failed(notification) | |
tf = Tempfile.new | |
File.open(notification.example.metadata[:file_path]) do |f| | |
counter = 1 | |
while (line = f.gets) | |
if counter == notification.example.metadata[:line_number] | |
line.sub!('it', 'skip') | |
line.sub!('scenario', 'skip') | |
@output << line | |
end | |
tf.write line | |
counter += 1 | |
end | |
end | |
tf.close | |
FileUtils.mv tf.path, notification.example.metadata[:file_path] | |
end | |
end |
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
rspec --require ./custom_formatter.rb --format CustomFormatter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/chumpy/2fa4713e8d53e7043149d5c35db80556#file-custom_formatter-rb-L16
Also replaced
"with"
in the spec descriptions.