Skip to content

Commit

Permalink
Clean specs up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Jan 5, 2011
1 parent c380065 commit 90ec458
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bacon_spec.nu
Expand Up @@ -9,6 +9,15 @@
)
)

(macro createRequirement (description block report)
`((BaconRequirement alloc) initWithContext:self
description:,description
block:,block
before:emptyArray
after:emptyArray
report:,report)
)

; Hooray for meta-testing.
(set succeed
(do (block)
Expand Down Expand Up @@ -41,25 +50,13 @@
))

(it "catches any type of exception so the spec suite can continue" (do ()
(set requirement ((BaconRequirement alloc) initWithContext:self
description:"throws"
block:(do () throw "ohnoes")
before:emptyArray
after:emptyArray
report:nil))
(-> (requirement run) should not raise)
(-> ((createRequirement "throws" (do () throw "ohnoes") nil) run) should not raise)
))

; NOTE: this requirement will print that the requirement failed/flunked, but in fact it does not!
(it "flunks a requirement if it contains no assertions" (do ()
(set numberOfFailuresBefore ($BaconSummary failures))
(set requirement ((BaconRequirement alloc) initWithContext:self
description:"flunks"
block:(do ()) ; very very empty
before:emptyArray
after:emptyArray
report:t))
(requirement run)
((createRequirement "flunks" (do ()) t) run)
(~ ($BaconSummary failures) should equal:(+ numberOfFailuresBefore 1))
(($BaconSummary valueForIvar:"counters") setValue:numberOfFailuresBefore forKey:"failures")
))
Expand Down

0 comments on commit 90ec458

Please sign in to comment.