Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,31 @@ def evaluate_result
let(:report_contents) { File.read(report_path) }
let(:container) { subject.send(:create_container, image) }

def copy_dummy_report
def copy_report(contents)
container.start!
container.wait
tar = StringIO.new(Docker::Util.create_tar('report.xml' => report_contents))
tar = StringIO.new(Docker::Util.create_tar('report.xml' => contents))
container.archive_in_stream(Coursemology::Evaluator::Services::
EvaluateProgrammingPackageService::PACKAGE_PATH) do
tar.read
end
end

after { subject.send(:destroy_container, container) }

it 'returns the test report' do
copy_dummy_report
copy_report(report_contents)
test_report = subject.send(:extract_test_report, container)
expect(test_report).to eq(report_contents)
expect(test_report.encoding).to eq Encoding::UTF_8
end

it 'does not crash when report is nil' do
copy_report(nil)
test_report = subject.send(:extract_test_report, container)
expect(test_report).to be_nil
end

context 'when running the tests fails' do
it 'returns nil' do
expect(subject.send(:extract_test_report, container)).to be_nil
Expand Down