|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | require 'spec_helper'
|
| 4 | +require 'puma' |
4 | 5 |
|
5 | 6 | RSpec.describe Capybara::Server do
|
6 | 7 | it 'should spool up a rack server' do
|
|
102 | 103 | it 'should call #clamp on the puma configuration to ensure that environment is a string' do
|
103 | 104 | Capybara.server = :puma
|
104 | 105 | app_proc = proc { |_env| [200, {}, ['Hello Puma!']] }
|
105 |
| - require 'puma' |
106 | 106 | allow(Puma::Server).to receive(:new).and_wrap_original do |method, app, events, options|
|
107 | 107 | # If #clamp is not called on the puma config then this will be a Proc
|
108 | 108 | expect(options.fetch(:environment)).to be_a(String)
|
|
118 | 118 | Capybara.server = :default
|
119 | 119 | end
|
120 | 120 |
|
| 121 | + it 'should ignore puma config files' do |
| 122 | + Capybara.server = :puma |
| 123 | + Dir.mkdir('config') unless Dir.exist?('config') |
| 124 | + File.open('config/puma.rb', 'w') do |file| |
| 125 | + file.puts 'debug' # puma default is debug: false, which we don't override |
| 126 | + end |
| 127 | + allow(Puma::Server).to receive(:new).and_call_original |
| 128 | + app_proc = proc { |_env| [200, {}, ['Hello Puma!']] } |
| 129 | + server = described_class.new(app_proc).boot |
| 130 | + expect(Puma::Server).to have_received(:new).with( |
| 131 | + anything, |
| 132 | + anything, |
| 133 | + satisfy { |opts| opts.final_options[:debug] == false } |
| 134 | + ) |
| 135 | + ensure |
| 136 | + Capybara.server = :default |
| 137 | + FileUtils.rm_rf('config') |
| 138 | + end |
| 139 | + |
121 | 140 | it 'should not emit any warnings when booting puma' do
|
122 | 141 | Capybara.server = :puma
|
123 | 142 | app_proc = proc { |_env| [200, {}, ['Hello Puma!']] }
|
|
0 commit comments