1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Call conf.clamp for puma options to convert the default :environment Proc into a String (#2413)

* Call conf.clamp for puma options to convert the default :environment Proc into a String
This commit is contained in:
Nathan Broadbent 2020-11-01 02:33:45 +08:00 committed by GitHub
parent 6962d8cbcb
commit 48bb29ab79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -28,6 +28,7 @@ Capybara.register_server :puma do |app, port, host, **options|
options = default_options.merge(options)
conf = Rack::Handler::Puma.config(app, options)
conf.clamp
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
puma_ver = Gem::Version.new(Puma::Const::PUMA_VERSION)

View file

@ -99,6 +99,21 @@ RSpec.describe Capybara::Server do
expect(uri.to_hash).to include(scheme: 'http', host: server.host, port: server.port)
end
it 'should call #clamp on the puma configuration to ensure that environment is a string' do
Capybara.server = :puma
app_proc = proc { |_env| [200, {}, ['Hello Puma!']] }
require 'puma'
allow(Puma::Server).to receive(:new).and_wrap_original do |method, app, events, options|
# If #clamp is not called on the puma config then this will be a Proc
expect(options.fetch(:environment)).to eq 'development'
method.call(app, events, options)
end
described_class.new(app_proc).boot
expect(Puma::Server).to have_received(:new)
ensure
Capybara.server = :default
end
it 'should support SSL' do
key = File.join(Dir.pwd, 'spec', 'fixtures', 'key.pem')
cert = File.join(Dir.pwd, 'spec', 'fixtures', 'certificate.pem')