File: dynamic_matchers.rb

package info (click to toggle)
ruby-rspec-puppet 4.0.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,444 kB
  • sloc: ruby: 6,377; makefile: 6
file content (35 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

module RSpec::Puppet
  module ManifestMatchers
    def method_missing(method, *args, &block)
      if /^(create|contain)_/.match?(method.to_s)
        return RSpec::Puppet::ManifestMatchers::CreateGeneric.new(method, *args,
                                                                  &block)
      end
      if /^have_.+_count$/.match?(method.to_s)
        return RSpec::Puppet::ManifestMatchers::CountGeneric.new(nil, args[0],
                                                                 method)
      end
      return RSpec::Puppet::ManifestMatchers::Compile.new if method == :compile

      super
    end
  end

  module FunctionMatchers
    def method_missing(method, *args, &block)
      return RSpec::Puppet::FunctionMatchers::Run.new if method == :run

      super
    end
  end

  module TypeMatchers
    def method_missing(method, *args, &block)
      return RSpec::Puppet::TypeMatchers::CreateGeneric.new(method, *args, &block) if method == :be_valid_type

      super
    end
  end
end