Skip to content

Commit

Permalink
fixes bug where spec don't execute in the ns where they are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
slagyr committed Jan 29, 2024
1 parent d6e9f7e commit 0c07738
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.4.4

* fixes bug where `it` blocks were not executing within the namespace where they were declared.

# 3.4.3

* redefs-around
Expand Down
2 changes: 1 addition & 1 deletion examples/prime_factors/prime_factors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
; (should= [mercene] (factors-of mercene))))
)

(run-specs)
(run-specs)
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(defproject speclj "3.4.3"
(defproject speclj "3.4.4"
:description "speclj: Pronounced 'speckle', is a Behavior Driven Development framework for Clojure."
:url "http://speclj.com"
:license {:name "The MIT License"
:url "file://LICENSE"
:distribution :repo
:comments "Copyright 2011-2023 Micah Martin All Rights Reserved."}
:comments "Copyright 2011-2024 Micah Martin All Rights Reserved."}

:jar-exclusions [#"\.cljx|\.swp|\.swo|\.DS_Store"]
:javac-options ["-target" "1.7" "-source" "1.7"]
Expand Down
2 changes: 1 addition & 1 deletion spec/speclj/core_spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,4 @@
(should= 1 @non-lazy-with-all-calls)))

;(run-specs :tags ["two"])
(run-specs)
;(run-specs)
8 changes: 6 additions & 2 deletions spec/speclj/running_spec.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns speclj.running-spec
(:require [speclj.config :refer [*reporters* *runner* *tag-filter*]]
[speclj.core :refer [after around before-all context describe
it should should-fail should-not
it focus-it should should-fail should-not
should-not-throw should-not= should= tags
with with-all]]
[speclj.platform :as platform]
Expand Down Expand Up @@ -104,4 +104,8 @@

)

(run-specs :color true)
(describe "namespace"
(it "runs in the current namespace"
(should= 'speclj.running-spec (.name *ns*))))

;(run-specs :color true)
9 changes: 5 additions & 4 deletions src/speclj/running.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@

#?(:clj
(defn- with-withs-bound [description body]
(let [withs (concat @(.-withs description) @(.-with-alls description))
ns (the-ns (symbol (.-ns description)))
with-mappings (reduce #(assoc %1 (ns-resolve ns (.-name %2)) %2) {} withs)]
(with-bindings* with-mappings body)))
(let [withs (concat @(.-withs description) @(.-with-alls description))
ns (the-ns (symbol (.-ns description)))
with-mappings (reduce #(assoc %1 (ns-resolve ns (.-name %2)) %2) {} withs)
with-and-ns-mappings (assoc with-mappings #'*ns* ns)]
(with-bindings* with-and-ns-mappings body)))

:cljs
(defn- with-withs-bound [description body]
Expand Down

0 comments on commit 0c07738

Please sign in to comment.