c8755543f0
Enables frozen string for the following files: * lib/generators/**/*.rb * lib/gitaly/**/*.rb * lib/google_api/**/*.rb * lib/haml_lint/**/*.rb * lib/json_web_token/**/*.rb * lib/mattermost/**/*.rb * lib/microsoft_teams/**/*.rb * lib/object_storage/**/*.rb * lib/omni_auth/**/*.rb * lib/peek/**/*.rb * lib/rouge/**/*.rb * lib/rspec_flaky/**/*.rb * lib/system_check/**/*.rb Partially addresses #47424.
37 lines
976 B
Ruby
37 lines
976 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'active_support/hash_with_indifferent_access'
|
|
|
|
require_relative 'flaky_example'
|
|
|
|
module RspecFlaky
|
|
class FlakyExamplesCollection < SimpleDelegator
|
|
def initialize(collection = {})
|
|
unless collection.is_a?(Hash)
|
|
raise ArgumentError, "`collection` must be a Hash, #{collection.class} given!"
|
|
end
|
|
|
|
collection_of_flaky_examples =
|
|
collection.map do |uid, example|
|
|
[
|
|
uid,
|
|
example.is_a?(RspecFlaky::FlakyExample) ? example : RspecFlaky::FlakyExample.new(example)
|
|
]
|
|
end
|
|
|
|
super(Hash[collection_of_flaky_examples])
|
|
end
|
|
|
|
def to_h
|
|
Hash[map { |uid, example| [uid, example.to_h] }].deep_symbolize_keys
|
|
end
|
|
|
|
def -(other)
|
|
unless other.respond_to?(:key)
|
|
raise ArgumentError, "`other` must respond to `#key?`, #{other.class} does not!"
|
|
end
|
|
|
|
self.class.new(reject { |uid, _| other.key?(uid) })
|
|
end
|
|
end
|
|
end
|