Merge remote-tracking branch 'origin/rspec-tests-models' into rspec-tests-controllers
This commit is contained in:
4
.rspec
4
.rspec
@ -1,2 +1,6 @@
|
|||||||
--color
|
--color
|
||||||
--format NyanCatWideFormatter
|
--format NyanCatWideFormatter
|
||||||
|
|
||||||
|
--require spec_helper
|
||||||
|
--order random
|
||||||
|
--format documentation
|
||||||
|
@ -48,6 +48,7 @@ class ExecutionEnvironment < ActiveRecord::Base
|
|||||||
def working_docker_image?
|
def working_docker_image?
|
||||||
DockerClient.pull(docker_image) unless DockerClient.image_tags.include?(docker_image)
|
DockerClient.pull(docker_image) unless DockerClient.image_tags.include?(docker_image)
|
||||||
output = DockerClient.new(execution_environment: self).execute_arbitrary_command(VALIDATION_COMMAND)
|
output = DockerClient.new(execution_environment: self).execute_arbitrary_command(VALIDATION_COMMAND)
|
||||||
|
|
||||||
errors.add(:docker_image, "error: #{output[:stderr]}") if output[:stderr].present?
|
errors.add(:docker_image, "error: #{output[:stderr]}") if output[:stderr].present?
|
||||||
rescue DockerClient::Error => error
|
rescue DockerClient::Error => error
|
||||||
errors.add(:docker_image, "error: #{error}")
|
errors.add(:docker_image, "error: #{error}")
|
||||||
|
@ -30,7 +30,7 @@ class Exercise < ActiveRecord::Base
|
|||||||
|
|
||||||
|
|
||||||
def average_percentage
|
def average_percentage
|
||||||
if average_score and maximum_score != 0.0
|
if average_score and maximum_score != 0.0 and submissions.exists?(cause: 'submit')
|
||||||
(average_score / maximum_score * 100).round
|
(average_score / maximum_score * 100).round
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
|
@ -23,7 +23,7 @@ class DockerClient
|
|||||||
def self.clean_container_workspace(container)
|
def self.clean_container_workspace(container)
|
||||||
# remove files when using transferral via Docker API archive_in (transmit)
|
# remove files when using transferral via Docker API archive_in (transmit)
|
||||||
#container.exec(['bash', '-c', 'rm -rf ' + CONTAINER_WORKSPACE_PATH + '/*'])
|
#container.exec(['bash', '-c', 'rm -rf ' + CONTAINER_WORKSPACE_PATH + '/*'])
|
||||||
|
|
||||||
local_workspace_path = local_workspace_path(container)
|
local_workspace_path = local_workspace_path(container)
|
||||||
if local_workspace_path && Pathname.new(local_workspace_path).exist?
|
if local_workspace_path && Pathname.new(local_workspace_path).exist?
|
||||||
Pathname.new(local_workspace_path).children.each{ |p| p.rmtree}
|
Pathname.new(local_workspace_path).children.each{ |p| p.rmtree}
|
||||||
@ -320,12 +320,11 @@ class DockerClient
|
|||||||
Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.include?('<none>') }
|
Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.include?('<none>') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# When @image commented test doesn't work
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@execution_environment = options[:execution_environment]
|
@execution_environment = options[:execution_environment]
|
||||||
# todo: eventually re-enable this if it is cached. But in the end, we do not need this.
|
@image = self.class.find_image_by_tag(@execution_environment.docker_image)
|
||||||
# docker daemon got much too much load. all not 100% necessary calls to the daemon were removed.
|
fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image
|
||||||
#@image = self.class.find_image_by_tag(@execution_environment.docker_image)
|
|
||||||
#fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.initialize_environment
|
def self.initialize_environment
|
||||||
|
@ -50,7 +50,7 @@ describe Exercise do
|
|||||||
|
|
||||||
context 'without submissions' do
|
context 'without submissions' do
|
||||||
it 'returns nil' do
|
it 'returns nil' do
|
||||||
expect(exercise.average_percentage).to be nil
|
expect(exercise.average_percentage).to be 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ describe Exercise do
|
|||||||
|
|
||||||
context 'without submissions' do
|
context 'without submissions' do
|
||||||
it 'returns nil' do
|
it 'returns nil' do
|
||||||
expect(exercise.average_score).to be nil
|
expect(exercise.average_score).to be 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,6 +33,11 @@ RSpec.configure do |config|
|
|||||||
config.filter_run :focus
|
config.filter_run :focus
|
||||||
config.run_all_when_everything_filtered = true
|
config.run_all_when_everything_filtered = true
|
||||||
|
|
||||||
|
|
||||||
|
#for --next-failure feature purpose
|
||||||
|
config.example_status_persistence_file_path = "examples.txt"
|
||||||
|
config.run_all_when_everything_filtered = true
|
||||||
|
|
||||||
# Many RSpec users commonly either run the entire suite or an individual
|
# Many RSpec users commonly either run the entire suite or an individual
|
||||||
# file, and it's useful to allow more verbose output when running an
|
# file, and it's useful to allow more verbose output when running an
|
||||||
# individual spec file.
|
# individual spec file.
|
||||||
|
Reference in New Issue
Block a user