mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 19:58:34 +08:00
22 lines
640 B
Ruby
22 lines
640 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
RSpec::Matchers.define :eq_ts_vector do |expected_vector|
|
||
|
match do |actual_vector|
|
||
|
actual = actual_vector.split(" ").sort
|
||
|
expected = expected_vector.split(" ").sort
|
||
|
|
||
|
(expected - actual == []) && (actual - expected == [])
|
||
|
end
|
||
|
failure_message do |actual_vector|
|
||
|
actual = actual_vector.split(" ").sort
|
||
|
expected = expected_vector.split(" ").sort
|
||
|
|
||
|
message = +"ts_vector does not match!\n\n"
|
||
|
message << "Additional elements:\n"
|
||
|
message << (expected - actual).join("\n")
|
||
|
message << "\nMissing elements:\n"
|
||
|
message << (actual - expected).join("\n")
|
||
|
message
|
||
|
end
|
||
|
end
|