Sha256: 7124454b82bd88759e3fc812dfb47ca8b0adac06d6a94d86ec760302c8119b4d
Contents?: true
Size: 1.46 KB
Versions: 36
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' require 'puppet/network/http/rack' if Puppet.features.rack? describe "Puppet::Network::HTTP::Rack", :if => Puppet.features.rack? do describe "when called" do before :all do @app = Puppet::Network::HTTP::Rack.new() # let's use Rack::Lint to verify that we're OK with the rack specification @linted = Rack::Lint.new(@app) end before :each do @env = Rack::MockRequest.env_for('/') end it "should create a Request object" do request = Rack::Request.new(@env) expect(Rack::Request).to receive(:new).and_return(request) @linted.call(@env) end it "should create a Response object" do expect(Rack::Response).to receive(:new).and_return(double('rack response', :[]= => nil, :status= => nil, :write => nil, :finish => nil)) @app.call(@env) # can't lint when Rack::Response is a stub end it "should let RackREST process the request" do expect_any_instance_of(Puppet::Network::HTTP::RackREST).to receive(:process).once @linted.call(@env) end it "should catch unhandled exceptions from RackREST" do expect_any_instance_of(Puppet::Network::HTTP::RackREST).to receive(:process).and_raise(ArgumentError, 'test error') expect { @linted.call(@env) }.not_to raise_error end it "should finish() the Response" do expect_any_instance_of(Rack::Response).to receive(:finish).once @app.call(@env) # can't lint when finish is a stub end end end
Version data entries
36 entries across 36 versions & 1 rubygems