slagyr / speclj

pronounced "speckle": a TDD/BDD framework for Clojure.
MIT License
459 stars 58 forks source link

Nested stubs and more granular expectations on stubs #76

Closed mylesmegyesi closed 10 years ago

mylesmegyesi commented 10 years ago

This PR addresses the following use cases:

Granular expectations

(let [f (stub :the-stub)]
  (f :one :two)
  (f :three :four)
  (should-have-invoked :the-stub {:with [:one :two]})
  (should-have-invoked :the-stub {:with [:three :four]}))

Nested stubs

(it "allows for nested should-invoke's"
  (should-pass!
    (should-invoke reverse {:times 1}
      (should-invoke println {:times 1}
        (println "hello!")
        (reverse [1 2])))))

This offers a backwards compatible implementation that allows nesting multiple should-invokes. GH-74 tries to accomplish the same thing but unfortunately changes the API of should-invoke.