Skip to content

Instantly share code, notes, and snippets.

@mcoms
Created June 12, 2017 20:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mcoms/77954d191bde31d4677872d2ab3d0cd5 to your computer and use it in GitHub Desktop.
Save mcoms/77954d191bde31d4677872d2ab3d0cd5 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
# 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
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