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
# specs/falkiness_spec.rb | |
describe 'Flakiness' do | |
it 'fails randomly' do | |
expect(random_true).to be true | |
end | |
it 'might also fail randomly' do | |
expect(random_true).to be true | |
end | |
private | |
def random_true |
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
# Gemfile | |
source 'https://rubygems.org' | |
ruby '2.5.1' | |
gem 'rspec' | |
gem 'rspec-retry' |
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
# spec_helper.rb | |
require 'rspec/retry' | |
RSpec.configure do |config| | |
config.default_retry_count = 2 | |
config.verbose_retry = true | |
... |
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
# spec_helper.rb | |
RSpec.configure do |config| | |
... | |
# callback to be run between retries | |
config.retry_callback = proc do |example| | |
# marks this test as flaky so we can identify it even if it | |
# passed at later retries | |
example.metadata[:flaky] = true | |
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
# lib/formatters/flakiness.rb | |
require 'rspec/core/formatters/console_codes' | |
require 'rspec/core/formatters/documentation_formatter' | |
class Flakiness < RSpec::Core::Formatters::DocumentationFormatter | |
RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished,:example_passed, :example_pending, :example_failed | |
def example_passed(notification) | |
return super unless notification.example.metadata[:flaky] | |
output.puts flaky_output(notification.example) |
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
class FlattenableArray | |
def initialize(array) | |
@array = array | |
end | |
def flatten | |
flat = [] | |
@array.each do |element| | |
if element.is_a? Array |
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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'digest/md5' | |
# TODO option to install git hook on pull | |
# TODO option to uninstall git hook on pull | |
# TODO option to install files in a .git/info/exclude |