Merge branch 'unify-match_ids.rb' into 'master'

Unify spec/support/matchers/match_ids.rb

See merge request gitlab-org/gitlab-ce!20108
This commit is contained in:
Robert Speicher 2018-06-22 16:35:19 +00:00
commit 643466f6b9
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,13 @@ RSpec::Matchers.define :match_ids do |*expected|
'matches elements by ids'
end
failure_message do
actual_ids = map_ids(actual)
expected_ids = map_ids(expected)
"expected IDs #{actual_ids} in:\n\n #{actual.inspect}\n\nto match IDs #{expected_ids} in:\n\n #{expected.inspect}"
end
def map_ids(elements)
elements = elements.flatten if elements.respond_to?(:flatten)