Skip to content

Commit

Permalink
midje-grader support
Browse files Browse the repository at this point in the history
  • Loading branch information
rahcola committed Sep 27, 2013
1 parent afad563 commit f5bbda3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .midje-grading-config.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(change-defaults :print-level :print-facts)
(change-defaults :emitter 'midje-grader)
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: clojure
lein: lein2
script: lein2 midje :config .midje-grading-config.clj
jdk:
- openjdk7
notifications:
email: false
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(defproject i-am-a-horse-in-the-land-of-booleans "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.0"]]
:dependencies [[org.clojure/clojure "1.5.0"]
[midje-grader "0.1.0-SNAPSHOT"]]
:profiles {:dev
{:dependencies [[midje "1.5.1"]]
:plugins [[lein-midje "3.0.0"]]}})
52 changes: 30 additions & 22 deletions test/i_am_a_horse_in_the_land_of_booleans_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,61 @@
(:use i-am-a-horse-in-the-land-of-booleans
midje.sweet))

(facts "1 boolean"
(facts "boolean" {:exercise 1
:points 1}
(boolean "foo") => true
(boolean nil) => false
(boolean (+ 2 3)) => true
(boolean true) => true
(boolean false) => false)

(facts "2 abs"
(facts "teen?" {:exercise 2
:points 1}
(teen? 12) => false
(teen? 15) => true
(teen? 13) => true
(teen? 19) => true
(teen? 20) => false
(teen? 27) => false)

(facts "abs" {:exercise 3
:points 1}
(abs -2) => 2
(abs 42) => 42)

(facts "3 divides?"
(facts "divides?" {:exercise 4
:points 1}
(divides? 2 4) => true
(divides? 4 2) => false
(divides? 5 10) => true
(divides? 2 5) => false)

(facts "4 fizzbuzz"
(facts "fizzbuzz" {:exercise 5
:points 1}
(fizzbuzz 2) => ""
(fizzbuzz 45) => "gotcha!"
(fizzbuzz 48) => "fizz"
(fizzbuzz 70) => "buzz")

(facts "5 teen?"
(teen? 12) => false
(teen? 15) => true
(teen? 13) => true
(teen? 19) => true
(teen? 20) => false
(teen? 27) => false)

(facts "6 not-teen?"
(not-teen? 13) => false
(not-teen? 25) => true
(not-teen? 12) => true
(not-teen? 19) => false
(not-teen? 20) => true)

(facts "7 generic-doublificate"
(facts "generic-doublificate" {:exercise 6
:points 1}
(generic-doublificate 1) => 2
(generic-doublificate [1 2]) => 4
(generic-doublificate '(65 21)) => 4
(generic-doublificate {}) => nil
(generic-doublificate []) => nil
(generic-doublificate {:a 1}) => true)

(tabular "8 leap-year?"
(facts "not-teen?" {:exercise 7
:points 1}
(not-teen? 13) => false
(not-teen? 25) => true
(not-teen? 12) => true
(not-teen? 19) => false
(not-teen? 20) => true)

(tabular "leap-year?" {:exercise 8
:points 1}
(fact
(leap-year? ?year) => ?expected)
?year ?expected
Expand All @@ -62,4 +70,4 @@
12 true
20 true
15 false
1913 false)
1913 false)

0 comments on commit f5bbda3

Please sign in to comment.