A Ruby client for firstdraft Grades
Add this line to your application's Gemfile:
gem "grade_runner"And then execute:
$ bundleAfter installed, run rails grade to run specs.
As of version 0.0.13, you can override the default points used on each test and the overwriting behavior of the spec folder by:
Moving the gem into the :development, :test group in your Gemfile:
# Gemfile
# ...
group :development, :test do
gem "grade_runner", "~> 0.0.13"
# ...
end
# ...Adding this configurable initializer:
# config/initializers/grade_runner.rb
if Rails.env.development? || Rails.env.test?
GradeRunner.config do |config|
config.default_points = 1 # default 1
config.override_local_specs = false # default true
end
endAdding this line to the Rakefile:
# Rakefile
require_relative "config/initializers/grade_runner"And making this change to the spec_helper.rb:
# spec/spec_helper.rb
# ...
# GradeRunner updates on https://github.com/firstdraft/grade_runner/pull/88
# make the formatters available from within the grade_runner gem
require "grade_runner/formatters/json_output_formatter"
require "grade_runner/formatters/hint_formatter"
# require "#{File.expand_path("../support/json_output_formatter", __FILE__)}"
# require "#{File.expand_path("../support/hint_formatter", __FILE__)}"
# ...Note that for that last step, the gem formatters can be overridden by requiring the formatters present in the local project like before.
In order to load and run the Rake task, you need to load it.
This is usually done by making a runnable file1, typically called bin/rails, with contents that look like this:
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "rake"
dir = Gem::Specification.find_by_name("grade_runner").gem_dir
load "#{dir}/lib/tasks/grade.rake"
task_name = ARGV[0]
Rake::Task[task_name].invokeThen you can run bin/rails grade like before. You can even add this file to the PATH so you can run rails grade like with Rails apps.
echo 'export PATH="$PATH:/path/to/project/bin/rails"' >> ~/.bashrc
source ~/.bashrcCopyright (c) 2018 Raghu Betina. See LICENSE.txt for further details.
Footnotes
-
If you get file permissions errors when running
bin/rails gradetry updating the permissions withchmod 755 bin/railsfirst. ↩