Fix Rubocop offenses

This commit is contained in:
Sebastian Serth
2022-04-20 18:09:15 +02:00
parent f38faa45b8
commit d9f40531fb
7 changed files with 13 additions and 13 deletions

View File

@ -33,7 +33,7 @@ describe Lti do
let(:last_name) { 'Doe' } let(:last_name) { 'Doe' }
let(:full_name) { 'John Doe' } let(:full_name) { 'John Doe' }
let(:provider) { double } let(:provider) { double }
let(:provider_full) { instance_double('IMS::LTI::ToolProvider', lis_person_name_full: full_name) } let(:provider_full) { instance_double(IMS::LTI::ToolProvider, lis_person_name_full: full_name) }
context 'when a full name is provided' do context 'when a full name is provided' do
it 'returns the full name' do it 'returns the full name' do

View File

@ -18,7 +18,7 @@ describe ExecutionEnvironmentsController do
before do before do
allow(Rails.env).to receive(:test?).and_return(false, true) allow(Rails.env).to receive(:test?).and_return(false, true)
allow(Runner.strategy_class).to receive(:sync_environment).and_return(true) allow(Runner.strategy_class).to receive(:sync_environment).and_return(true)
runner = instance_double 'runner' runner = instance_double Runner
allow(Runner).to receive(:for).and_return(runner) allow(Runner).to receive(:for).and_return(runner)
allow(runner).to receive(:execute_command).and_return({}) allow(runner).to receive(:execute_command).and_return({})
perform_request.call perform_request.call
@ -90,7 +90,7 @@ describe ExecutionEnvironmentsController do
let(:command) { 'which ruby' } let(:command) { 'which ruby' }
before do before do
runner = instance_double 'runner' runner = instance_double Runner
allow(Runner).to receive(:for).with(user, execution_environment).and_return runner allow(Runner).to receive(:for).with(user, execution_environment).and_return runner
allow(runner).to receive(:execute_command).and_return({}) allow(runner).to receive(:execute_command).and_return({})
post :execute_command, params: {command: command, id: execution_environment.id} post :execute_command, params: {command: command, id: execution_environment.id}
@ -183,7 +183,7 @@ describe ExecutionEnvironmentsController do
before do before do
allow(Rails.env).to receive(:test?).and_return(false, true) allow(Rails.env).to receive(:test?).and_return(false, true)
allow(Runner.strategy_class).to receive(:sync_environment).and_return(true) allow(Runner.strategy_class).to receive(:sync_environment).and_return(true)
runner = instance_double 'runner' runner = instance_double Runner
allow(Runner).to receive(:for).and_return(runner) allow(Runner).to receive(:for).and_return(runner)
allow(runner).to receive(:execute_command).and_return({}) allow(runner).to receive(:execute_command).and_return({})
put :update, params: {execution_environment: attributes_for(:ruby, pool_size: 1), id: execution_environment.id} put :update, params: {execution_environment: attributes_for(:ruby, pool_size: 1), id: execution_environment.id}

View File

@ -86,7 +86,7 @@ describe SessionsController do
it 'sets the specified locale' do it 'sets the specified locale' do
expect(controller).to receive(:switch_locale).and_call_original expect(controller).to receive(:switch_locale).and_call_original
i18n = instance_double 'i18n', locale: locale.to_s i18n = class_double I18n, locale: locale.to_s
allow(I18n).to receive(:locale=).with(I18n.default_locale).and_call_original allow(I18n).to receive(:locale=).with(I18n.default_locale).and_call_original
allow(I18n).to receive(:locale=).with(locale.to_s).and_return(i18n) allow(I18n).to receive(:locale=).with(locale.to_s).and_return(i18n)
perform_request perform_request

View File

@ -12,7 +12,7 @@ describe Admin::DashboardHelper do
describe '#docker_data' do describe '#docker_data' do
before do before do
create(:ruby) create(:ruby)
dcp = instance_double 'docker_container_pool' dcp = class_double Runner::Strategy::DockerContainerPool
allow(Runner).to receive(:strategy_class).and_return dcp allow(Runner).to receive(:strategy_class).and_return dcp
allow(dcp).to receive(:pool_size).and_return({}) allow(dcp).to receive(:pool_size).and_return({})
end end

View File

@ -118,7 +118,7 @@ describe Runner::Strategy::Poseidon do
let(:response_status) { -1 } let(:response_status) { -1 }
it 'raises an error' do it 'raises an error' do
faraday_connection = instance_double 'Faraday::Connection' faraday_connection = instance_double Faraday::Connection
allow(described_class).to receive(:http_connection).and_return(faraday_connection) allow(described_class).to receive(:http_connection).and_return(faraday_connection)
%i[post patch delete].each {|message| allow(faraday_connection).to receive(message).and_raise(Faraday::TimeoutError) } %i[post patch delete].each {|message| allow(faraday_connection).to receive(message).and_raise(Faraday::TimeoutError) }
expect { action.call }.to raise_error(Runner::Error::FaradayError) expect { action.call }.to raise_error(Runner::Error::FaradayError)
@ -131,7 +131,7 @@ describe Runner::Strategy::Poseidon do
let(:execution_environment) { create(:ruby) } let(:execution_environment) { create(:ruby) }
it 'makes the correct request to Poseidon' do it 'makes the correct request to Poseidon' do
faraday_connection = instance_double 'Faraday::Connection' faraday_connection = instance_double Faraday::Connection
allow(described_class).to receive(:http_connection).and_return(faraday_connection) allow(described_class).to receive(:http_connection).and_return(faraday_connection)
allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: 201)) allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: 201))
action.call action.call
@ -143,7 +143,7 @@ describe Runner::Strategy::Poseidon do
shared_examples 'returns true when the api request was successful' do |status| shared_examples 'returns true when the api request was successful' do |status|
it "returns true on status #{status}" do it "returns true on status #{status}" do
faraday_connection = instance_double 'Faraday::Connection' faraday_connection = instance_double Faraday::Connection
allow(described_class).to receive(:http_connection).and_return(faraday_connection) allow(described_class).to receive(:http_connection).and_return(faraday_connection)
allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: status)) allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: status))
expect(action.call).to be_truthy expect(action.call).to be_truthy
@ -152,7 +152,7 @@ describe Runner::Strategy::Poseidon do
shared_examples 'returns false when the api request failed' do |status| shared_examples 'returns false when the api request failed' do |status|
it "raises an exception on status #{status}" do it "raises an exception on status #{status}" do
faraday_connection = instance_double 'Faraday::Connection' faraday_connection = instance_double Faraday::Connection
allow(described_class).to receive(:http_connection).and_return(faraday_connection) allow(described_class).to receive(:http_connection).and_return(faraday_connection)
allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: status)) allow(faraday_connection).to receive(:put).and_return(Faraday::Response.new(status: status))
expect { action.call }.to raise_exception Runner::Error::UnexpectedResponse expect { action.call }.to raise_exception Runner::Error::UnexpectedResponse
@ -168,7 +168,7 @@ describe Runner::Strategy::Poseidon do
end end
it 'raises an exception if Faraday raises an error' do it 'raises an exception if Faraday raises an error' do
faraday_connection = instance_double 'Faraday::Connection' faraday_connection = instance_double Faraday::Connection
allow(described_class).to receive(:http_connection).and_return(faraday_connection) allow(described_class).to receive(:http_connection).and_return(faraday_connection)
allow(faraday_connection).to receive(:put).and_raise(Faraday::TimeoutError) allow(faraday_connection).to receive(:put).and_raise(Faraday::TimeoutError)
expect { action.call }.to raise_exception Runner::Error::FaradayError expect { action.call }.to raise_exception Runner::Error::FaradayError

View File

@ -153,7 +153,7 @@ describe ExecutionEnvironment do
describe '#working_docker_image?' do describe '#working_docker_image?' do
let(:execution_environment) { create(:ruby) } let(:execution_environment) { create(:ruby) }
let(:working_docker_image?) { execution_environment.send(:working_docker_image?) } let(:working_docker_image?) { execution_environment.send(:working_docker_image?) }
let(:runner) { instance_double 'runner' } let(:runner) { instance_double Runner }
before do before do
allow(execution_environment).to receive(:sync_runner_environment).and_return(true) allow(execution_environment).to receive(:sync_runner_environment).and_return(true)

View File

@ -26,7 +26,7 @@ describe ProformaService::ExportTask do
let(:task) { Proforma::Task.new } let(:task) { Proforma::Task.new }
let(:exercise) { build(:dummy) } let(:exercise) { build(:dummy) }
let(:exporter) { instance_double('Proforma::Exporter', perform: 'zip') } let(:exporter) { instance_double(Proforma::Exporter, perform: 'zip') }
before do before do
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise: exercise).and_return(task) allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise: exercise).and_return(task)