Skip to content

Instantly share code, notes, and snippets.

@GregSutcliffe
Created August 21, 2013 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GregSutcliffe/6293472 to your computer and use it in GitHub Desktop.
Save GregSutcliffe/6293472 to your computer and use it in GitHub Desktop.
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