[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Jesse Wolfe
jes5199 at gmail.com
Wed Jul 14 10:35:25 UTC 2010
The following commit has been merged in the upstream branch:
commit 4ef40b88f246a6c158cc3ea91ea44dc941d4ac41
Author: Rein Henrichs <rein at puppetlabs.com>
Date: Fri Jun 25 14:36:40 2010 -0700
maint: Rework testing of Reports http processor to be self contained
* do not monkey patch Net::HTTP in a way that breaks other specs
* Use fakes to sense behavior of Net::HTTP
diff --git a/spec/unit/reports/http_spec.rb b/spec/unit/reports/http_spec.rb
index 2c7c32c..cc73464 100644
--- a/spec/unit/reports/http_spec.rb
+++ b/spec/unit/reports/http_spec.rb
@@ -4,25 +4,39 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
require 'puppet/reports'
-class Net::HTTP
+# FakeHTTP fakes the behavior of Net::HTTP#request and acts as a sensor for an
+# otherwise difficult to trace method call.
+#
+class FakeHTTP
REQUESTS = {}
- alias_method :old_request, :request
- def request(req, body=nil, &block)
+ def self.request(req)
REQUESTS[req.path] = req
- old_request(req, body, &block)
end
end
processor = Puppet::Reports.report(:http)
describe processor do
+ before { Net::HTTP.any_instance.stubs(:start).yields(FakeHTTP) }
subject { Puppet::Transaction::Report.new.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
@@ -38,5 +52,5 @@ describe processor do
private
- def reports_request; Net::HTTP::REQUESTS[URI.parse(Puppet[:reporturl]).path] end
+ def reports_request; FakeHTTP::REQUESTS[URI.parse(Puppet[:reporturl]).path] end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list