You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.
I am trying to use a macro in a step definition, and instead of having access to the value passed in to my step definition I get a symbol.
This is perhaps nothing more than me being relatively new to Clojure but it's certainly unexpected.
Given the the following scenario:
Scenario: Using macros inside step defintionsGiven my words are replaced:
""" My word is %{word} """
When I run my cukes with a step defintion like:
;; Step definition
(defmacrofmt [^String string]
(let [-re #"%\{(.*?)\}"
fstr (clojure.string/replace string -re "%s")
fargs (map #(read-string (second %)) (re-seq -re string))]
`(format ~fstr ~@fargs)))
(Given#"my words are replaced:" [string]
(let [word "interpolated"]
(assert (= (fmt string) "My word is interpolated")))
Then I get an error of:
Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.CharSequence
at clojure.core$re_matcher.invoke(core.clj:4386)
at clojure.core$re_seq.invoke(core.clj:4411)
at cucumber.runtime.clj$fmt.invoke(api_steps.clj:18)
at clojure.lang.Var.invoke(Var.java:423)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.lang.Compiler.macroexpand1(Compiler.java:6468)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6546)
I've gisted the full backtrace if that's of use, and I'm running cukes via lein-cucumber.
From: cucumber/cucumber-jvm#631
The text was updated successfully, but these errors were encountered: