blob: 7250f7bf1645f86aa2557c4c76d1e00083b4f85d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# frozen_string_literal: true
require 'active_support/hash_with_indifferent_access'
require 'delegate'
require_relative 'flaky_example'
module Gitlab
module RspecFlaky
class FlakyExamplesCollection < SimpleDelegator
def initialize(collection = {})
raise ArgumentError, "`collection` must be a Hash, #{collection.class} given!" unless collection.is_a?(Hash)
collection_of_flaky_examples =
collection.map do |uid, example|
[
uid,
FlakyExample.new(example.to_h.symbolize_keys)
]
end
super(Hash[collection_of_flaky_examples])
end
def to_h
transform_values(&:to_h).deep_symbolize_keys
end
def -(other)
raise ArgumentError, "`other` must respond to `#key?`, #{other.class} does not!" unless other.respond_to?(:key)
self.class.new(reject { |uid, _| other.key?(uid) })
end
end
end
end
|