Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'spec_helper'
require 'puppet/reports'
require 'webmock/rspec'
require 'ostruct'
class ErbStruct < OpenStruct
def initialize(values)
values.each { |k,v| instance_variable_set("@#{k}", v) }
super
end
def b; binding; end;
end
describe 'Foreman Report Processor' do
before :all do
@settings = ErbStruct.new(
:foreman_url => 'http://localhost:3000',
)
template = File.join(File.dirname(__FILE__), '../..', 'templates', 'foreman-report.rb.erb')
eval ERB.new(File.read(template), nil, '-').result(@settings.b)
end
let(:settings) { @settings }
let(:processor) { Puppet::Reports.report(:foreman) }
subject { Puppet::Transaction::Report.new("apply").extend(processor) }
describe "when making a request" do
it "should use the path specified by the 'foreman_url' setting" do
stub = stub_request(:post, "#{settings.foreman_url}/reports/create?format=yml")
subject.process
stub.should have_been_requested.once
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.