forked from saasbook/rag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade
executable file
·37 lines (27 loc) · 1.14 KB
/
grade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ruby
# -*- mode: ruby -*-
# An example use of the Ruby autograder
require './lib/auto_grader.rb'
require 'ruby-debug'
def grade(file,spec)
end
def usage
STDERR.puts <<EndOfHelp
Usage: #{$0} submission.rb specfile.rb
Creates an autograder of the RspecGrader subclass (which evaluates student
code based solely on RSpec output) and grades the submission.rb file with it.
For example, try these, where PREFIX=rag/spec/fixtures:
#{$0} $PREFIX/correct_example.rb $PREFIX/correct_example.spec.rb
#{$0} $PREFIX/example_with_syntax_error.rb $PREFIX/correct_example.spec.rb
#{$0} $PREFIX/example_with_runtime_exception.rb $PREFIX/correct_example.spec.rb
EndOfHelp
exit
end
usage() if (ARGV.length!=2 || ARGV[0] =~ /^-?-h/)
g = AutoGrader.create('1', 'WeightedRspecGrader', IO.read(ARGV[0]), :spec => ARGV[1])
g.grade!
puts "Score out of 100: #{g.normalized_score(100)}\n"
puts "---BEGIN rspec comments---\n#{'-'*80}\n#{g.comments}\n#{'-'*80}\n---END rspec comments---"
# PFX = 'spec/fixtures'
# grade "#{PFX}/correct_example.rb", "#{PFX}/correct_example.spec.rb"
# grade "#{PFX}/example_with_syntax_error.rb", "#{PFX}/correct_example.spec.rb"