examiner 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/examiner.gemspec +2 -2
- data/lib/examiner/minitest_parser.rb +7 -0
- data/lib/examiner/rake_runner.rb +12 -7
- data/lib/examiner/version.rb +1 -1
- data/spec/examiner/rake_runner_spec.rb +8 -5
- data/spec/support/empty_rakefile/Rakefile +0 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1799a2bafa8549f65627403149d87d4cc005a61
|
4
|
+
data.tar.gz: 40684b52306eb976819c05daf9bb6e73e82ceb05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c656506f027cc09729c0980a1710012f9f72a26bcfee10b5713a1da0984fbfe214582cb0cb3168b1c9b708cc3b8fea5e021e67b8d92df0d54dd465c7a7bdd04
|
7
|
+
data.tar.gz: 70d1c3ef7792ed8398527c4e22eb4e1a5884ed355d191006277c9393597f34c588eeb82bd5cff91a1af2bf7872ae3e823375c1bab5fade2b9862f6706fcc6087
|
data/README.md
CHANGED
@@ -3,11 +3,9 @@
|
|
3
3
|
|
4
4
|
# Examiner
|
5
5
|
|
6
|
-
Grade a student's exercise solution
|
6
|
+
Grade a student's exercise solution, assuming:
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
- The exercise uses [minitest](https://github.com/seattlerb/minitest) to be checkied
|
8
|
+
- The exercise uses [minitest](https://github.com/seattlerb/minitest) to be checked
|
11
9
|
- There is a `Rakefile` in the exercise folder
|
12
10
|
|
13
11
|
## Installation
|
@@ -20,7 +18,9 @@ gem 'examiner'
|
|
20
18
|
|
21
19
|
And then execute:
|
22
20
|
|
23
|
-
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
@@ -31,9 +31,13 @@ the following code.
|
|
31
31
|
exercise_directory = "/path/to/student_exercise_with_rakefile"
|
32
32
|
|
33
33
|
runner = Examiner::RakeRunner.new
|
34
|
-
|
35
|
-
|
34
|
+
begin
|
35
|
+
runner.run exercise_directory
|
36
36
|
puts "Results: #{runner.tests - runner.failures}/#{runner.tests}"
|
37
|
+
rescue Examiner::RakefileMissingError => e
|
38
|
+
puts "Folder does not have any Rakefile"
|
39
|
+
rescue Examiner::MissingDefaultRakeTaskError => e
|
40
|
+
puts "Could not launch tests with 'rake'"
|
37
41
|
end
|
38
42
|
|
39
43
|
# You can display stdout and stderr
|
data/examiner.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["seb@saunier.me"]
|
11
11
|
spec.summary = %q{Grade a student's exercise solution using rake and minitest}
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://github.com/ssaunier/examiner"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
end
|
data/lib/examiner/rake_runner.rb
CHANGED
@@ -2,6 +2,9 @@ require 'open3'
|
|
2
2
|
require_relative 'minitest_parser'
|
3
3
|
|
4
4
|
module Examiner
|
5
|
+
class RakefileMissingError < StandardError; end
|
6
|
+
class MissingDefaultRakeTaskError < StandardError; end
|
7
|
+
|
5
8
|
class RakeRunner
|
6
9
|
attr_reader :stdout_lines, :stderr_lines
|
7
10
|
attr_reader :tests, :failures
|
@@ -13,27 +16,29 @@ module Examiner
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def run(directory)
|
16
|
-
|
19
|
+
raise RakefileMissingError.new(directory) unless rakefile?(directory)
|
17
20
|
|
18
21
|
Open3.popen3('rake', chdir: directory) do |_, stdout, stderr, wait_thr|
|
19
|
-
@stdout_lines, @stderr_lines = stdout.readlines,
|
22
|
+
@stdout_lines, @stderr_lines = stdout.readlines, stderr.readlines
|
23
|
+
parse_stderr(directory)
|
20
24
|
parse_stdout
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
def success?
|
25
|
-
@success
|
26
|
-
end
|
27
|
-
|
28
28
|
private
|
29
29
|
|
30
|
+
def parse_stderr(directory)
|
31
|
+
unless MinitestParser.new.default_rake?(@stderr_lines)
|
32
|
+
raise MissingDefaultRakeTaskError.new(directory)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
def parse_stdout
|
31
37
|
parser = MinitestParser.new
|
32
38
|
parser.parse @stdout_lines
|
33
39
|
if parser.success?
|
34
40
|
@tests = parser.tests
|
35
41
|
@failures = parser.failures
|
36
|
-
@success = true
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
data/lib/examiner/version.rb
CHANGED
@@ -6,13 +6,11 @@ module Exmanier
|
|
6
6
|
let(:runner) { Examiner::RakeRunner.new }
|
7
7
|
|
8
8
|
it "should handle a folder without Rakefile" do
|
9
|
-
runner.run directory("no_rake_file")
|
10
|
-
runner.success?.must_equal false
|
9
|
+
lambda { runner.run directory("no_rake_file") }.must_raise Examiner::RakefileMissingError
|
11
10
|
end
|
12
11
|
|
13
12
|
it "should be successful for 1_test_0_failure use case" do
|
14
13
|
runner.run directory("1_test_0_failure")
|
15
|
-
runner.success?.must_equal true
|
16
14
|
runner.tests.must_equal 1
|
17
15
|
runner.failures.must_equal 0
|
18
16
|
runner.stdout_lines.wont_be_empty
|
@@ -21,7 +19,6 @@ module Exmanier
|
|
21
19
|
|
22
20
|
it "should be successful for 2_tests_1_failure use case" do
|
23
21
|
runner.run directory("2_tests_1_failure")
|
24
|
-
runner.success?.must_equal true
|
25
22
|
runner.tests.must_equal 2
|
26
23
|
runner.failures.must_equal 1
|
27
24
|
runner.stdout_lines.wont_be_empty
|
@@ -30,7 +27,13 @@ module Exmanier
|
|
30
27
|
|
31
28
|
it "should handle a file with syntax errors" do
|
32
29
|
runner.run directory("syntax_error")
|
33
|
-
runner.
|
30
|
+
runner.stderr_lines.wont_be_empty
|
31
|
+
runner.tests.must_equal 0
|
32
|
+
runner.failures.must_equal 0
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should handle a folder with an empty rakefile" do
|
36
|
+
lambda { runner.run directory("empty_rakefile") }.must_raise Examiner::MissingDefaultRakeTaskError
|
34
37
|
end
|
35
38
|
|
36
39
|
def directory(name)
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: examiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Saunier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,8 +61,9 @@ files:
|
|
61
61
|
- spec/spec_helper.rb
|
62
62
|
- spec/support/1_test_0_failure/Rakefile
|
63
63
|
- spec/support/2_tests_1_failure/Rakefile
|
64
|
+
- spec/support/empty_rakefile/Rakefile
|
64
65
|
- spec/support/syntax_error/Rakefile
|
65
|
-
homepage:
|
66
|
+
homepage: http://github.com/ssaunier/examiner
|
66
67
|
licenses:
|
67
68
|
- MIT
|
68
69
|
metadata: {}
|
@@ -92,4 +93,5 @@ test_files:
|
|
92
93
|
- spec/spec_helper.rb
|
93
94
|
- spec/support/1_test_0_failure/Rakefile
|
94
95
|
- spec/support/2_tests_1_failure/Rakefile
|
96
|
+
- spec/support/empty_rakefile/Rakefile
|
95
97
|
- spec/support/syntax_error/Rakefile
|