From 0c07738ebe2d67958b94ed88910a191490d3e769 Mon Sep 17 00:00:00 2001 From: Micah Date: Mon, 29 Jan 2024 15:59:01 -0700 Subject: [PATCH] fixes bug where spec don't execute in the ns where they are defined --- CHANGES.md | 4 ++++ examples/prime_factors/prime_factors.clj | 2 +- project.clj | 4 ++-- spec/speclj/core_spec.cljc | 2 +- spec/speclj/running_spec.clj | 8 ++++++-- src/speclj/running.cljc | 9 +++++---- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3cdb58a..bc16a69 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/examples/prime_factors/prime_factors.clj b/examples/prime_factors/prime_factors.clj index 0b04bcc..37ad563 100644 --- a/examples/prime_factors/prime_factors.clj +++ b/examples/prime_factors/prime_factors.clj @@ -46,4 +46,4 @@ ; (should= [mercene] (factors-of mercene)))) ) -(run-specs) \ No newline at end of file +(run-specs) diff --git a/project.clj b/project.clj index 0b2d6b2..4d0cabf 100644 --- a/project.clj +++ b/project.clj @@ -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"] diff --git a/spec/speclj/core_spec.cljc b/spec/speclj/core_spec.cljc index 3aaa927..60a6121 100644 --- a/spec/speclj/core_spec.cljc +++ b/spec/speclj/core_spec.cljc @@ -370,4 +370,4 @@ (should= 1 @non-lazy-with-all-calls))) ;(run-specs :tags ["two"]) -(run-specs) +;(run-specs) diff --git a/spec/speclj/running_spec.clj b/spec/speclj/running_spec.clj index 807b3ab..bc39df7 100644 --- a/spec/speclj/running_spec.clj +++ b/spec/speclj/running_spec.clj @@ -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] @@ -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) diff --git a/src/speclj/running.cljc b/src/speclj/running.cljc index 1ef647e..9dbd9a0 100644 --- a/src/speclj/running.cljc +++ b/src/speclj/running.cljc @@ -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]