Sha256: 8198c02cb05886ef06d38a1d75d42982a546a33c672eac54ef733b83a177a744

Contents?: true

Size: 1.36 KB

Versions: 20

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'puppet/reports'

# FakeHTTP fakes the behavior of Net::HTTP#request and acts as a sensor for an
# otherwise difficult to trace method call.
#
class FakeHTTP
  REQUESTS = {}
  def self.request(req)
    REQUESTS[req.path] = req
  end
end

processor = Puppet::Reports.report(:http)

describe processor do
  before  { Net::HTTP.any_instance.stubs(:start).yields(FakeHTTP) }
  subject { Puppet::Transaction::Report.new("apply").extend(processor) }

  it { should respond_to(:process) }

  it "should use the reporturl setting's host and port" do
    uri = URI.parse(Puppet[:reporturl])
    Net::HTTP.expects(:new).with(uri.host, uri.port).returns(stub_everything('http'))
    subject.process
  end

  describe "request" do
    before { subject.process }

    describe "path" do
      it "should use the path specified by the 'reporturl' setting" do
        reports_request.path.should == URI.parse(Puppet[:reporturl]).path
      end
    end

    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; FakeHTTP::REQUESTS[URI.parse(Puppet[:reporturl]).path] end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
puppet-2.7.13 spec/unit/reports/http_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
puppet-2.7.12 spec/unit/reports/http_spec.rb
puppet-2.7.11 spec/unit/reports/http_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/reports/http_spec.rb
puppet-2.7.9 spec/unit/reports/http_spec.rb
puppet-2.7.8 spec/unit/reports/http_spec.rb
puppet-2.7.6 spec/unit/reports/http_spec.rb
puppet-2.7.5 spec/unit/reports/http_spec.rb
puppet-2.7.4 spec/unit/reports/http_spec.rb
puppet-2.7.3 spec/unit/reports/http_spec.rb
puppet-2.7.1 spec/unit/reports/http_spec.rb