-
-
Save duncanjbrown/3bc25ef6b0a851062d16254050199397 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 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] | |
regex = /^(\s*)(it|scenario) / | |
line.gsub!(regex, '\1x\2 ') | |
@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 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
Use
x
s instead ofskip
, and use a regex to put in thex
s, otherwise a spec called "doesn't submit" became "doesn't submxit"