Forked from GregSutcliffe/foreman_report_processor.rb
Last active
December 21, 2015 10:39
-
-
Save domcleal/6293521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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