From 8c149e9b888b23870adaa98b9ab99be732d5a5bc Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Wed, 20 Jul 2022 15:08:31 -0700 Subject: [PATCH] Add the ability to use `kind_of` matchers This allows you to check the return type of functions, like this example: ``` is_expected.to run.with_params('mymod/template.epp', { 'foo' => 'bar' }).and_return(kind_of String) ``` --- lib/rspec-puppet/matchers/run.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rspec-puppet/matchers/run.rb b/lib/rspec-puppet/matchers/run.rb index 53dbd9952..97c763991 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -35,6 +35,8 @@ def matches?(func_obj) case @expected_return when Regexp return !!(@actual_return =~ @expected_return) + when RSpec::Mocks::ArgumentMatchers::KindOf, RSpec::Matchers::AliasedMatcher + return @expected_return === @actual_return else return @actual_return == @expected_return end