Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Make Clojure DSL syntax cleaner (rewritten as modification of new back-end) #267

merged 1 commit into from

3 participants


No description provided.


This replaces #248, so I closed that one.


You probably want to change the template function for the reified Snippet in clojure-snippet ( to reflect the new syntax.


Hmm, good catch. So this is where it suggests a definition for a missing feature...


I moved the old to ClojureSnippet class from main to test in

Now its only purpose is to test snippets, and we must manually make sure the snippet templates are in sync. That's fine.

I'll go ahead and change it.


I actually wrote it earlier, but there was an internet outage, so I went out to enjoy the nice weather. I'll make it work with this change right now.


Just about to push now :-)

Let me know if that's not right...

@aslakhellesoy aslakhellesoy merged commit f48aa96 into cucumber:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
19 clojure/src/main/clj/cucumber/runtime/clj.clj
@@ -119,19 +119,18 @@
(defmacro step-macros [& names]
(cons 'do
(for [name names]
- `(defmacro ~name [pattern# fun#]
- `(add-step-definition ~pattern# ~fun#
+ `(defmacro ~name [pattern# binding-form# & body#]
+ `(add-step-definition ~pattern#
+ (fn ~binding-form# ~@body#)
'~{:file *file*
:line (:line (meta ~'&form))})))))
Given When Then And But)
-(defmacro Before [& fun]
- (when (not (empty? fun))
- (let [fun (first fun)]
- `(add-hook-definition :before [] ~fun))))
-(defmacro After [& fun]
- (when (not (empty? fun))
- (let [fun (first fun)]
- `(add-hook-definition :after [] ~fun))))
+(defmacro Before [binding-form & body]
+ `(add-hook-definition :before [] (fn ~binding-form ~@body)))
+(defmacro After [binding-form & body]
+ `(add-hook-definition :after [] (fn ~binding-form ~@body)))
36 clojure/src/test/resources/cucumber/runtime/clojure/stepdefs.clj
@@ -2,30 +2,24 @@
(def some-state (atom "'Before' hasn't run."))
- (fn []
- (do
- (reset! some-state "'Before' has run.")
- (println "Executing 'Before'."))))
+(Before []
+ (reset! some-state "'Before' has run.")
+ (println "Executing 'Before'."))
- (fn []
- (println (str "Executing 'After' " @some-state))))
+(After []
+ (println (str "Executing 'After' " @some-state)))
-(Given #"^I have (\d+) cukes in my belly$"
- #(eat (Float. %1)))
+(Given #"^I have (\d+) cukes in my belly$" [cuke-count]
+ (eat (Float. cuke-count)))
-(Given #"^I have this many cukes in my belly:$"
- #(doseq [x (.raw %1)] (eat (Float. (first x)))))
+(Given #"^I have this many cukes in my belly:$" [cuke-table]
+ (doseq [x (.raw cuke-table)] (eat (Float. (first x)))))
-(When #"^there are (\d+) cukes in my belly$"
- (fn [expected]
- (assert (= (last-meal) (Float. expected)))))
+(When #"^there are (\d+) cukes in my belly$" [expected]
+ (assert (= (last-meal) (Float. expected))))
-(Then #"^the (.*) contains (.*)$"
- (fn [container, ingredient]
- (assert (= "glass" container))))
+(Then #"^the (.*) contains (.*)$" [container ingredient]
+ (assert (= "glass" container)))
-(When #"^I add (.*)$"
- (fn [liquid]
- (assert (= "milk" liquid))))
+(When #"^I add (.*)$" [liquid]
+ (assert (= "milk" liquid)))
Something went wrong with that request. Please try again.