From bf79046f52d87113de1fb8e91269a6348a8a4db5 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 18 Jul 2024 13:00:21 +0200 Subject: [PATCH] Add custom cert matcher --- .../acceptance/matchers/match_without_whitespace.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/support/acceptance/matchers/match_without_whitespace.rb diff --git a/spec/support/acceptance/matchers/match_without_whitespace.rb b/spec/support/acceptance/matchers/match_without_whitespace.rb new file mode 100644 index 0000000..d363385 --- /dev/null +++ b/spec/support/acceptance/matchers/match_without_whitespace.rb @@ -0,0 +1,11 @@ +# based on https://github.com/theforeman/puppet-certs/blob/master/spec/support/acceptance/matchers/match_without_whitespace.rb +# https://github.com/theforeman/puppet-certs/commit/6b82334a5661a4e95b8c0604535ec39c991c9787 +RSpec::Matchers.define :match_without_whitespace do |expected| + match do |actual| + actual.gsub(/\s*/, '').match?(Regexp.new(expected.source, Regexp::EXTENDED)) + end + + failure_message do |actual| + "Actual:\n\n\s\s#{actual.gsub(/\s*/, '')}\n\nExpected:\n\n\s\s#{expected.source}" + end +end