From 43ce0555d5df2c2c9bbdadbc6c27a2ebfbe3e093 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 | 13 +++++++++++++ 1 file changed, 13 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..66907f5 --- /dev/null +++ b/spec/support/acceptance/matchers/match_without_whitespace.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# 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(%r{\s*}, '').match?(Regexp.new(expected.source, Regexp::EXTENDED)) + end + + failure_message do |actual| + "Actual:\n\n\s\s#{actual.gsub(%r{\s*}, '')}\n\nExpected:\n\n\s\s#{expected.source}" + end +end