Fix rubocop offenses - Requires Ruby 3.1+
This commit is contained in:
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe ExerciseService::CheckExternal do
|
||||
describe '.new' do
|
||||
subject(:export_service) { described_class.new(uuid: uuid, codeharbor_link: codeharbor_link) }
|
||||
subject(:export_service) { described_class.new(uuid:, codeharbor_link:) }
|
||||
|
||||
let(:uuid) { SecureRandom.uuid }
|
||||
let(:codeharbor_link) { build(:codeharbor_link) }
|
||||
@ -19,7 +19,7 @@ describe ExerciseService::CheckExternal do
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
subject(:check_external_service) { described_class.call(uuid: uuid, codeharbor_link: codeharbor_link) }
|
||||
subject(:check_external_service) { described_class.call(uuid:, codeharbor_link:) }
|
||||
|
||||
let(:uuid) { SecureRandom.uuid }
|
||||
let(:codeharbor_link) { build(:codeharbor_link) }
|
||||
@ -38,7 +38,7 @@ describe ExerciseService::CheckExternal do
|
||||
|
||||
it 'submits the correct body' do
|
||||
expect(check_external_service).to have_requested(:post, codeharbor_link.check_uuid_url)
|
||||
.with(body: {uuid: uuid}.to_json)
|
||||
.with(body: {uuid:}.to_json)
|
||||
end
|
||||
|
||||
context 'when response contains a JSON with expected keys' do
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe ExerciseService::PushExternal do
|
||||
describe '.new' do
|
||||
subject(:push_external) { described_class.new(zip: zip, codeharbor_link: codeharbor_link) }
|
||||
subject(:push_external) { described_class.new(zip:, codeharbor_link:) }
|
||||
|
||||
let(:zip) { ProformaService::ExportTask.call(exercise: build(:dummy)) }
|
||||
let(:codeharbor_link) { build(:codeharbor_link) }
|
||||
@ -19,14 +19,14 @@ RSpec.describe ExerciseService::PushExternal do
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
subject(:push_external) { described_class.call(zip: zip, codeharbor_link: codeharbor_link) }
|
||||
subject(:push_external) { described_class.call(zip:, codeharbor_link:) }
|
||||
|
||||
let(:zip) { ProformaService::ExportTask.call(exercise: build(:dummy)) }
|
||||
let(:codeharbor_link) { build(:codeharbor_link) }
|
||||
let(:status) { 200 }
|
||||
let(:response) { '' }
|
||||
|
||||
before { stub_request(:post, codeharbor_link.push_url).to_return(status: status, body: response) }
|
||||
before { stub_request(:post, codeharbor_link.push_url).to_return(status:, body: response) }
|
||||
|
||||
it 'calls the correct url' do
|
||||
expect(push_external).to have_requested(:post, codeharbor_link.push_url)
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe ProformaService::ConvertExerciseToTask do
|
||||
describe '.new' do
|
||||
subject(:convert_to_task) { described_class.new(exercise: exercise) }
|
||||
subject(:convert_to_task) { described_class.new(exercise:) }
|
||||
|
||||
let(:exercise) { build(:dummy) }
|
||||
|
||||
@ -16,10 +16,10 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
|
||||
describe '#execute' do
|
||||
subject(:task) { convert_to_task.execute }
|
||||
|
||||
let(:convert_to_task) { described_class.new(exercise: exercise) }
|
||||
let(:convert_to_task) { described_class.new(exercise:) }
|
||||
let(:exercise) do
|
||||
create(:dummy,
|
||||
execution_environment: execution_environment,
|
||||
execution_environment:,
|
||||
instructions: 'instruction',
|
||||
uuid: SecureRandom.uuid,
|
||||
files: files + tests)
|
||||
@ -85,7 +85,7 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
|
||||
|
||||
context 'when exercise has a regular file' do
|
||||
let(:files) { [file] }
|
||||
let(:file) { build(:file, role: 'regular_file', hidden: hidden, read_only: read_only) }
|
||||
let(:file) { build(:file, role: 'regular_file', hidden:, read_only:) }
|
||||
let(:hidden) { true }
|
||||
let(:read_only) { true }
|
||||
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe ProformaService::ConvertTaskToExercise do
|
||||
describe '.new' do
|
||||
subject(:convert_to_exercise_service) { described_class.new(task: task, user: user, exercise: exercise) }
|
||||
subject(:convert_to_exercise_service) { described_class.new(task:, user:, exercise:) }
|
||||
|
||||
let(:task) { Proforma::Task.new }
|
||||
let(:user) { build(:teacher) }
|
||||
@ -24,7 +24,7 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
subject(:convert_to_exercise_service) { described_class.call(task: task, user: user, exercise: exercise) }
|
||||
subject(:convert_to_exercise_service) { described_class.call(task:, user:, exercise:) }
|
||||
|
||||
before { create(:dot_txt) }
|
||||
|
||||
@ -36,10 +36,10 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
uuid: 'uuid',
|
||||
parent_uuid: 'parent_uuid',
|
||||
language: 'language',
|
||||
meta_data: meta_data,
|
||||
model_solutions: model_solutions,
|
||||
files: files,
|
||||
tests: tests
|
||||
meta_data:,
|
||||
model_solutions:,
|
||||
files:,
|
||||
tests:
|
||||
)
|
||||
end
|
||||
let(:user) { create(:teacher) }
|
||||
@ -63,7 +63,7 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
description: 'description',
|
||||
uuid: be_blank,
|
||||
unpublished: true,
|
||||
user: user,
|
||||
user:,
|
||||
files: be_empty,
|
||||
public: false,
|
||||
hide_file_tree: false,
|
||||
@ -80,11 +80,11 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
let(:meta_data) do
|
||||
{
|
||||
CodeOcean: {
|
||||
public: public,
|
||||
hide_file_tree: hide_file_tree,
|
||||
allow_file_creation: allow_file_creation,
|
||||
allow_auto_completion: allow_auto_completion,
|
||||
expected_difficulty: expected_difficulty,
|
||||
public:,
|
||||
hide_file_tree:,
|
||||
allow_file_creation:,
|
||||
allow_auto_completion:,
|
||||
expected_difficulty:,
|
||||
execution_environment_id: execution_environment&.id,
|
||||
files: files_meta_data,
|
||||
},
|
||||
@ -98,7 +98,7 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
description: 'description',
|
||||
uuid: be_blank,
|
||||
unpublished: true,
|
||||
user: user,
|
||||
user:,
|
||||
files: be_empty,
|
||||
public: true,
|
||||
hide_file_tree: true,
|
||||
@ -125,13 +125,13 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
let(:file) do
|
||||
Proforma::TaskFile.new(
|
||||
id: 'id',
|
||||
content: content,
|
||||
filename: filename,
|
||||
content:,
|
||||
filename:,
|
||||
used_by_grader: 'used_by_grader',
|
||||
visible: 'yes',
|
||||
usage_by_lms: usage_by_lms,
|
||||
binary: binary,
|
||||
mimetype: mimetype
|
||||
usage_by_lms:,
|
||||
binary:,
|
||||
mimetype:
|
||||
)
|
||||
end
|
||||
let(:filename) { "#{path}filename.txt" }
|
||||
@ -192,7 +192,7 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
let(:content) { 'test' * (10**5) }
|
||||
|
||||
it 'creates an exercise with a file that has the correct attributes' do
|
||||
expect(convert_to_exercise_service.files.first).to have_attributes(content: content)
|
||||
expect(convert_to_exercise_service.files.first).to have_attributes(content:)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe ProformaService::ExportTask do
|
||||
describe '.new' do
|
||||
subject(:export_task) { described_class.new(exercise: exercise) }
|
||||
subject(:export_task) { described_class.new(exercise:) }
|
||||
|
||||
let(:exercise) { build(:dummy) }
|
||||
|
||||
@ -22,15 +22,15 @@ describe ProformaService::ExportTask do
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
subject(:export_task) { described_class.call(exercise: exercise) }
|
||||
subject(:export_task) { described_class.call(exercise:) }
|
||||
|
||||
let(:task) { Proforma::Task.new }
|
||||
let(:exercise) { build(:dummy) }
|
||||
let(:exporter) { instance_double(Proforma::Exporter, perform: 'zip') }
|
||||
|
||||
before do
|
||||
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise: exercise).and_return(task)
|
||||
allow(Proforma::Exporter).to receive(:new).with(task: task, custom_namespaces: [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]).and_return(exporter)
|
||||
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise:).and_return(task)
|
||||
allow(Proforma::Exporter).to receive(:new).with(task:, custom_namespaces: [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]).and_return(exporter)
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe ProformaService::Import do
|
||||
describe '.new' do
|
||||
subject(:import_service) { described_class.new(zip: zip, user: user) }
|
||||
subject(:import_service) { described_class.new(zip:, user:) }
|
||||
|
||||
let(:zip) { Tempfile.new('proforma_test_zip_file') }
|
||||
let(:user) { build(:teacher) }
|
||||
@ -27,14 +27,14 @@ describe ProformaService::Import do
|
||||
let(:exercise) do
|
||||
create(:dummy,
|
||||
instructions: 'instruction',
|
||||
execution_environment: execution_environment,
|
||||
execution_environment:,
|
||||
files: files + tests,
|
||||
hide_file_tree: true,
|
||||
allow_file_creation: false,
|
||||
allow_auto_completion: true,
|
||||
expected_difficulty: 7,
|
||||
uuid: uuid,
|
||||
user: user)
|
||||
uuid:,
|
||||
user:)
|
||||
end
|
||||
|
||||
let(:uuid) { nil }
|
||||
|
Reference in New Issue
Block a user