Fix 17 previously failing specs
This commit is contained in:

committed by
Sebastian Serth

parent
0280c0282e
commit
cf58be97ee
@ -2,36 +2,34 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
class Controller < AnonymousController
|
||||
include SubmissionScoring
|
||||
end
|
||||
|
||||
# This is broken since the Runner was added.
|
||||
describe SubmissionScoring, skip: true do
|
||||
let(:controller) { Controller.new }
|
||||
describe SubmissionScoring do
|
||||
let(:submission) { FactoryBot.create(:submission, cause: 'submit') }
|
||||
|
||||
before do
|
||||
controller.instance_variable_set(:@current_user, FactoryBot.create(:external_user))
|
||||
controller.instance_variable_set(:@_params, {})
|
||||
end
|
||||
|
||||
describe '#collect_test_results' do
|
||||
after { controller.send(:collect_test_results, submission) }
|
||||
let(:runner) { FactoryBot.create :runner }
|
||||
|
||||
before do
|
||||
allow(Runner).to receive(:for).and_return(runner)
|
||||
allow(runner).to receive(:copy_files)
|
||||
allow(runner).to receive(:execute_interactively).and_return(1.0)
|
||||
end
|
||||
|
||||
after { submission.calculate_score }
|
||||
|
||||
it 'executes every teacher-defined test file' do
|
||||
allow(submission).to receive(:score_submission)
|
||||
submission.collect_files.select(&:teacher_defined_assessment?).each do |file|
|
||||
allow(controller).to receive(:execute_test_file).with(file, submission).and_return({})
|
||||
allow(submission).to receive(:test_result).with(any_args, file).and_return({})
|
||||
end
|
||||
end
|
||||
|
||||
it 'scores the submission' do
|
||||
allow(submission).to receive(:score_submission).and_return([])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#score_submission', cleaning_strategy: :truncation do
|
||||
after { controller.score_submission(submission) }
|
||||
|
||||
it 'collects the test results' do
|
||||
allow(controller).to receive(:collect_test_results).and_return([])
|
||||
end
|
||||
after { submission.score_submission([]) }
|
||||
|
||||
it 'assigns a score to the submissions' do
|
||||
expect(submission).to receive(:update).with(score: anything)
|
||||
|
Reference in New Issue
Block a user