Sha256: 1e6f91cb7c652828fa3aac6659422e84ce9228a2e72d89cd7134d0607d8c073f

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

<% test.classes.each do |cls| -%>
describe "<%= cls.name %>" do

<% test.nodes.each do |node| -%>
  context "using fact set <%= node.name %>" do
    node_facts = <%= node.fact_set %>
    let(:facts) { node_facts }
<% if node.trusted_set -%>
    trusted_facts = <%= node.trusted_set %>
    let(:trusted_facts) { trusted_facts }
<% end -%>
<% if @before_conditions -%>
    before :each do
<% @before_conditions.each do |function| -%>
      <%= function %>
<% end -%>
    end
<% end -%>

<% if @mock_functions -%>
    # Create a from_json function so that we can parse the output of json for mocked functions
    before :each do
      Puppet::Parser::Functions.newfunction(:from_json, :type => :rvalue) { |args|
          require 'json'
          JSON.parse(args[0])
        }
    end
<% end -%>

<% if @after_conditions -%>
    after :each do
<% @after_conditions.each do |function| -%>
      <%= function %>
<% end -%>
    end
<% end -%>
    let(:pre_condition) {
      pp = <%= '<<' %>-END
$onceover_class = '<%= cls.name %>'
$onceover_node  = '<%= node.name %>'

# Begin user-specified pre_condition
<%= (pre_condition || "").chomp %>
# End user-specified pre_condition

<% if @mock_functions -%>
<% require 'json' -%>
# Mocking functions
<% @mock_functions.each do |function,params| -%>
function <%= function %> (*$args) { from_json('<%= params['returns'].to_json %>') }
<% end -%>
<% end -%>

END
    }

    it { should compile }
  end
<% end -%>
end

<% end -%>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onceover-3.10.0 templates/test_spec.rb.erb