Midje icon indicating copy to clipboard operation
Midje copied to clipboard

remove-ns before loading

Open neapel opened this issue 10 years ago • 1 comments

Midje doesn't remove the namespaces it reloads, which causes old symbols to stick around and cause confusion.

Steps to reproduce:

  • Create a file mytest.clj
(ns mytest (:use [midje.sweet]))
(def x 1)
(fact x => 1)
  • Run (autotest). It loads mytest, checks the fact and succeeds.

Using a new REPL / lein midje run for the next steps behaves as expected, using the same REPL / lein midje :autotest run behaves unexpected:

  • Remove the (def x 1) line. Autotest reloads and succeeds!
  • Change (fact x => 2), autotest reloads and fails with Actual: 1, Expected: 2.
  • Run (remove-ns 'mytest). Save the file again.
  • Now the test fails as expected with a load failure: unable to resolve x. (and then autotest stops without the autotest has been cancelled message it seems)

Prior to loading the changed namespaces there should be a step where midje runs remove-ns for all of them. The documentation says "use with caution" though, so maybe it breaks things(?), in that case an option like (autotest :remove-ns) would be nice.

neapel avatar Jul 27 '14 21:07 neapel

I will experiment with remove-ns in upcoming alphas.

marick avatar Nov 28 '14 21:11 marick