Skip to content

Instantly share code, notes, and snippets.

@tbatchelli
Created November 28, 2010 03:50
Show Gist options
  • Save tbatchelli/718564 to your computer and use it in GitHub Desktop.
Save tbatchelli/718564 to your computer and use it in GitHub Desktop.
test_shell.clj
(deftest test-set-scope
(let [original-ns *ns*]
(try (in-ns 'outer-test-scope)
(use 'clj-coffeescript.shell)
(is (nil? *runtime*)
"Verify that *runtime* is nil before the test")
(let [outer-ns *ns*
new-scope (new-scope)]
(try
(in-ns 'test-new-scope-ns)
(use 'clj-coffeescript.shell)
(is (nil? *runtime*)
"Initially *runtime* has no value")
(set-scope new-scope)
(is (= new-scope *runtime*) "The *runtime* has been set")
(finally
(in-ns (.name outer-ns))
(remove-ns 'test-new-scope-ns))))
(is (= (.name *ns*) 'outer-test-scope)
"Verify that I made it back to the original ns")
(is (nil? *runtime*)
"Verify that *runtime* is still not bound after the test")
(finally
(in-ns (.name original-ns))
(remove-ns 'outer-test-scope)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment