# encoding: utf-8 describe ServerCommands::Rackup do context '#initialize' do it 'requires a listen statement' do pid_file = create_file 'pid', $$ config_file = create_file 'config.ru' expect { ServerCommands::Rackup.new( listen: 'localhost:8080', pid_file: pid_file, config_file: config_file, ) }.not_to raise_error end end context '#to_s' do it 'has defaults' do command = ServerCommands::Rackup.new expect(command.to_s).to eq("rackup -E development -P #{LocalPac.config.pid_file} -o 127.0.0.1 -p 8080 #{File.expand_path('../../../config.ru', __FILE__)}") end it 'respects changed environment' do command = ServerCommands::Rackup.new( environment: '-E super_env' ) expect(command.to_s).to include('-E super_env') end it 'respects changed pid file' do pid_file = create_file 'pid', $$ command = ServerCommands::Rackup.new( pid_file: pid_file, ) expect(command.to_s).to include("-P #{pid_file}") end it 'respects changed config_file' do config_file = create_file 'config.ru' command = ServerCommands::Rackup.new( config_file: config_file, ) expect(command.to_s).to include(config_file) end end end