title: puppet-rspec table driven testing
body: <p>I am trying to to test a type and I have a question: is table driven testing at all possible? I have a class which gets a hash passed to it and I would like to check it with different hash contents, so I would like my test to look like</p>
  
  <pre><code>require_relative '../../../spec_helper'
  require_relative '../../isamjunction_mocks'
  
  describe 'addon::isam::junctionmember::config', :type =&gt; :class do
      let(:pre_condition) {[$mock_isam_junction_member.render]}
      $junctionmember_hashes.each do |member|
          let(:params) {{:data_isamjunctionmember =&gt; member}}
          describe member[:name] do
              it {
                  compare = member.dup
                  compare.delete(:isam_servername)
                  is_expected.to contain_class('isam_junction_member').with(
                      compare
                  )
              }
          end
      end
  end
  </code></pre>
  
  <p>When I run this it looks to me like the puppet catalog was compiled with the last of my array of test hashes because I see that when the first of my test hashes is compared against the catalog I get failures (looks like the catalog was compiled with my second and last hash (whose test succeeds).</p>
  
  <p>In rspec-puppet when does the catalog get compiled? Can I force a re-compile and would this be performant? Is there a better, more idiomatic way of doing this? </p>
  
  <pre><code>$mock_isam_junction_member = MockResource.new 'isam_junction_member', {
    :params =&gt; {
      :reverseproxy_id =&gt; nil,
      :junction_point =&gt; nil,
      :junction_type =&gt; nil,
      :server_port =&gt; nil,
      :virtual_hostname =&gt; nil,
      :virtual_https_hostname =&gt; nil,
      :server_dn =&gt; nil,
      :query_contents =&gt; nil,
      :stateful_junction =&gt; nil,
      :case_sensitive_url =&gt; nil,
      :windows_style_url =&gt; nil,
      :https_port =&gt; nil,
      :http_port =&gt; nil,
      :proxy_hostname =&gt; nil,
      :proxy_port =&gt; nil,
      :sms_environment =&gt; nil,
      :vhost_label =&gt; nil,
      :admin_rest_url =&gt; nil,
      :admin_ssl =&gt; nil,
      :admin_verify_ssl =&gt; nil,
      :admin_rest_username =&gt; nil,
      :admin_rest_password =&gt; nil
    }
  }
  
  $junctionmember_hashes = [
    {
      :isam_servername =&gt; '145.70.150.207',
      :reverseproxy_id =&gt; 'reverseproxy_id',
      :name =&gt; 'http.backendserver.internalcorp.net',
      :junction_point =&gt; 'a-virtual-junction-point',
      :junction_type =&gt; 'tcp',
      :server_port =&gt; 1234,
      :virtual_hostname =&gt; 'afund.pensions.nl',
      :virtual_https_hostname =&gt; nil,
      :server_dn =&gt; 'distinguished.afund.pensions.nl',
      :query_contents =&gt; 'query_contents.exe',
      :stateful_junction =&gt; true,
      :case_sensitive_url =&gt; 'no',
      :windows_style_url =&gt; 'yes',
      :https_port =&gt; 443,
      :http_port =&gt; 80,
      :proxy_hostname =&gt; 'abc''',
      :proxy_port =&gt; 5678,
      :sms_environment =&gt; 'ghi',
      :vhost_label =&gt; 'xyz',
    }, {
      :isam_servername =&gt; '145.70.150.207',
      :reverseproxy_id =&gt; 'reverseproxy_id',
      :name =&gt; 'https.backendserver.internalcorp.net',
      :junction_point =&gt; 'a-virtual-junction-point',
      :junction_type =&gt; 'ssl',
      :server_port =&gt; 5678,
      :virtual_hostname =&gt; 'afund.pensions.nl',
      :server_dn =&gt; 'distinguished.afund.pensions.nl',
      :query_contents =&gt; 'query_contents.exe',
      :stateful_junction =&gt; true,
      :case_sensitive_url =&gt; 'no',
      :windows_style_url =&gt; 'yes',
      :https_port =&gt; 443,
      :sms_environment =&gt; 'abc',
      :vhost_label =&gt; 'def',
    }
  ]
  </code></pre>
  
  <p>And this is the code</p>
  
  <pre><code>class addon::isam::junctionmember::config (
    $data_isamjunctionmember = {}
  ) {
  
    $appliance_servername = $data_isamjunctionmember['isam_servername']
  
    $data_isamappliance = hiera('drdc_base', undef)['isamappliances'][$appliance_servername]
  
    $port = $data_isamjunctionmember['server_port']
    $protocol = $data_isamjunctionmember['server_protocol']
    $server_hostname = $data_isamjunctionmember['server_hostname']
  
    dsc_xfirewall {
      downcase("${appliance_servername}_IsamJunctionMember"):
        dsc_name        =&gt; 'DRDC-IsamJunctionMember',
        dsc_displayname =&gt; 'DRDC ISAM Junction Member',
        dsc_localport   =&gt; sprintf('%d', $port),
        dsc_protocol    =&gt; $protocol,
        dsc_profile     =&gt; ['Domain', 'Private', 'Public'],
        dsc_description =&gt; "Firewall rule to allow the ISAM server to forward traffic to a backend server. [${protocol}://${server_hostname}:${port}]"
    }
  
    class { 'isam_junction_member':
      reverseproxy_id        =&gt; $data_isamjunctionmember['reverseproxy_id'],
      name                   =&gt; $server_hostname,
      junction_point         =&gt; $data_isamjunctionmember['junction_point'],
      junction_type          =&gt; $data_isamjunctionmember['junction_type'],
      server_port            =&gt; $port,
      virtual_hostname       =&gt; $data_isamjunctionmember['virtual_hostname'],
      virtual_https_hostname =&gt; $data_isamjunctionmember['virtual_https_hostname'],
      server_dn              =&gt; $data_isamjunctionmember['server_dn'],
      query_contents         =&gt; $data_isamjunctionmember['query_contents'],
      stateful_junction      =&gt; $data_isamjunctionmember['stateful_junction'],
      case_sensitive_url     =&gt; $data_isamjunctionmember['case_sensitive_url'],
      windows_style_url      =&gt; $data_isamjunctionmember['windows_style_url'],
      https_port             =&gt; $data_isamjunctionmember['https_port'],
      http_port              =&gt; $data_isamjunctionmember['http_port'],
      proxy_hostname         =&gt; $data_isamjunctionmember['proxy_hostname'],
      proxy_port             =&gt; $data_isamjunctionmember['proxy_port'],
      sms_environment        =&gt; $data_isamjunctionmember['sms_environment'],
      vhost_label            =&gt; $data_isamjunctionmember['vhost_label'],
      admin_rest_url         =&gt; "https://${appliance_servername}",
      admin_ssl              =&gt; $data_isamappliance['admin_ssl'],
      admin_verify_ssl       =&gt; $data_isamappliance['admin_ssl_verify'],
      admin_rest_username    =&gt; $data_isamappliance['admin_rest_username'],
      admin_rest_password    =&gt; $data_isamappliance['admin_rest_password']
    }
  }
  </code></pre>