From 00eadabc7cdabf04454ad9af7182b5da23238222 Mon Sep 17 00:00:00 2001 From: osc-bot Date: Wed, 16 Oct 2024 02:48:41 +0000 Subject: [PATCH] lint a random file --- .../generators/pun_config_generator_spec.rb | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/nginx_stage/spec/generators/pun_config_generator_spec.rb b/nginx_stage/spec/generators/pun_config_generator_spec.rb index b5bc5434b2..27dd35279a 100644 --- a/nginx_stage/spec/generators/pun_config_generator_spec.rb +++ b/nginx_stage/spec/generators/pun_config_generator_spec.rb @@ -1,42 +1,42 @@ +# frozen_string_literal: true + require 'spec_helper' require 'nginx_stage' describe NginxStage::PunConfigGenerator do - let(:test_user) { "spec" } + let(:test_user) { 'spec' } let(:test_user_gid) { 1000 } - before(:each) { + before do etc_stub = { - :gid => test_user_gid, + :gid => test_user_gid, :name => test_user } allow(Etc).to receive(:getpwnam).with(test_user).and_return(Struct.new(*etc_stub.keys).new(*etc_stub.values)) allow(Etc).to receive(:getgrgid).with(test_user_gid).and_return(Struct.new(*etc_stub.keys).new(*etc_stub.values)) allow_any_instance_of(NginxStage::User).to receive(:get_groups).and_return([test_user]) - } + end it 'has the correct options' do - expect(NginxStage::PunConfigGenerator.options.keys).to eq([:user, :skip_nginx, :app_init_url, :pre_hook_root_cmd]) + expect(described_class.options.keys).to eq([:user, :skip_nginx, :app_init_url, :pre_hook_root_cmd]) end it 'requires the user option' do - expect { described_class.new }.to raise_error(NginxStage::MissingOption, "missing option: user") + expect { described_class.new }.to raise_error(NginxStage::MissingOption, 'missing option: user') end - describe 'pre_hook_root_cmd' do - - let(:generator){ + let(:generator) do described_class.new({ - :user => test_user, - :pre_hook_root_cmd => '/opt/pre_hook' - }) - } + :user => test_user, + :pre_hook_root_cmd => '/opt/pre_hook' + }) + end - let(:hook){ + let(:hook) do generator.class.hooks[:exec_pre_hook] - } + end it 'invokes the right root pre hook' do allow(Open3).to receive(:capture3).with('/opt/pre_hook', '--user', test_user) @@ -44,7 +44,8 @@ end it 'logs exceptions from underlying script' do - allow(Open3).to receive(:capture3).with('/opt/pre_hook', '--user', test_user).and_raise(StandardError.new "this is a test") + allow(Open3).to receive(:capture3).with('/opt/pre_hook', '--user', + test_user).and_raise(StandardError.new('this is a test')) allow_any_instance_of(Syslog::Logger).to receive(:error).with("/opt/pre_hook threw exception 'this is a test' for spec") generator.instance_eval(&hook) end @@ -52,7 +53,7 @@ it 'logs non-zero exits from underlying script' do allow(Open3).to receive(:capture3) .with('/opt/pre_hook', '--user', test_user) - .and_return(["", "this is the test stderr message", double(:success? => false, :exitstatus => 3)]) + .and_return(['', 'this is the test stderr message', double(:success? => false, :exitstatus => 3)]) allow_any_instance_of(Syslog::Logger).to receive(:error) .with("/opt/pre_hook exited with 3 for user spec. stderr was 'this is the test stderr message'") @@ -60,4 +61,4 @@ generator.instance_eval(&hook) end end -end \ No newline at end of file +end