Sha256: f9a522739b03ec9f5a37ad5acf7679af106fab80ba44568217ecbfa96a7e7a90

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'
require 'shared_contexts'

describe '<%= @type.name -%>' do
  # by default the hiera integration uses hirea data from the shared_contexts.rb file
  # but basically to mock hiera you first need to add a key/value pair
  # to the specific context in the spec/shared_contexts.rb file
  # Note: you can only use a single hiera context per describe/context block
  # rspec-puppet does not allow you to swap out hiera data on a per test block
  #include_context :hiera

  <%- if @type.type == :definition -%>
  let(:title) { 'XXreplace_meXX' }
  <%- end -%>

  # below is the facts hash that gives you the ability to mock
  # facts on a per describe/context block.  If you use a fact in your
  # manifest you should mock the facts below.
  let(:facts) do
    {}
  end
  # below is a list of the resource parameters that you can override.
  # By default all non-required parameters are commented out,
  # while all required parameters will require you to add a value
  let(:params) do
    {
    <%- @parameters.each do |k,v| -%>
        <%- if v.nil? -%>
      <%= ":#{k} => 'place_value_here'," %>
        <%- else -%>
      <%= "#:#{k} => #{variable_value(v)}," %>
        <%- end -%>
    <%- end -%>
    }
  end
  # add these two lines in a single test block to enable puppet and hiera debug mode
  # Puppet::Util::Log.level = :debug
  # Puppet::Util::Log.newdestination(:console)
  <%- @resources.each do |res| -%>
  it do
    is_expected.to contain_<%= res.type.gsub('::', '__')%>('<%= res.title %>').
             with(<%= res.parameters.to_s.gsub(/\",/, "\",\n                  ") %>)
  end
  <%- end -%>
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-retrospec-0.6.0 lib/retrospec/templates/resource_spec_file.erb