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'
describe 'Foreman Report Processor' do
# TODO improve this parsing
@foreman_url = 'http://localhost:3000'
let(:foreman_url) { 'http://localhost:3000' }
# Parse ERB and create a file we can require - need an instance variable for ERB
template=File.join(File.dirname(__FILE__), '../..', 'templates', 'foreman-report.rb.erb')
output=File.join(File.dirname(__FILE__), '..', 'fixtures', 'foreman-report.rb')
File.write(output,ERB.new(File.read(template), nil, '-').result(binding))
require File.join(File.dirname(__FILE__), '..', 'fixtures', 'foreman-report')
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, "#{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.