diff options
| author | Rein Henrichs <rein@puppetlabs.com> | 2010-05-20 14:41:22 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | c00285c395647bc19237ec6c60099d11997592bb (patch) | |
| tree | e30bcff922d76c087774a9ba47629940091b2543 /spec/unit | |
| parent | 1d49defe9b2a5f7725d74d2d73880ed342399d83 (diff) | |
| download | puppet-c00285c395647bc19237ec6c60099d11997592bb.tar.gz puppet-c00285c395647bc19237ec6c60099d11997592bb.tar.xz puppet-c00285c395647bc19237ec6c60099d11997592bb.zip | |
[#3810] Add http reports processor and `reporturl` setting
Example puppet.conf:
[puppetmasterd]
reports = store, http
reporturl = http://localhost:3000/reports
* Group reporturl and reportdir in new reports section of
Puppet::Settings
* Add specs for both
Diffstat (limited to 'spec/unit')
| -rw-r--r-- | spec/unit/reports/http.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/reports/http.rb b/spec/unit/reports/http.rb new file mode 100644 index 000000000..2c7c32c18 --- /dev/null +++ b/spec/unit/reports/http.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/reports' + +class Net::HTTP + REQUESTS = {} + alias_method :old_request, :request + def request(req, body=nil, &block) + REQUESTS[req.path] = req + old_request(req, body, &block) + end +end + +processor = Puppet::Reports.report(:http) + +describe processor do + subject { Puppet::Transaction::Report.new.extend(processor) } + + it { should respond_to(:process) } + + describe "request" do + before { subject.process } + + describe "body" do + it "should be the report as YAML" do + reports_request.body.should == subject.to_yaml + end + end + + describe "content type" do + it "should be 'application/x-yaml'" do + reports_request.content_type.should == "application/x-yaml" + end + end + end + + private + + def reports_request; Net::HTTP::REQUESTS[URI.parse(Puppet[:reporturl]).path] end +end |
