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
Step definitions can be defined by requiring 'jukebox' and using `step`:
66
66
67
-
require jukebox
68
-
69
-
module MyTests
70
-
extend Jukebox # Mixin `Jukebox.step` so it can be used as `step`
71
-
72
-
step 'I have {int} cukes in my belly' do |board, int1|
73
-
pending! # Write code here that turns the phrase above into concrete actions
74
-
board # return the updated board
75
-
end
76
-
77
-
step :before do |board scenario|
78
-
pending! # Write code here that runs before each scenario
79
-
board # return the updated board
80
-
end
81
-
82
-
step :before {:tags "@user and @admin"} do |board|
83
-
pending! # Write code here that will run before each scenario that matches the tag expression
84
-
board # return the updated board
85
-
end
86
-
87
-
step :after do |board scenario|
88
-
pending! # Write code here that runs after each scenario
89
-
board # return the updated board
90
-
end
67
+
```ruby
68
+
require jukebox
91
69
92
-
step :after_step do |board scenario|
93
-
pending! # Write code here that runs before each step
94
-
board # return the updated board
95
-
end
96
-
97
-
step :before_step do |board scenario|
98
-
pending! # Write code here that runs after each step
99
-
board # return the updated board
100
-
end
101
-
end
70
+
moduleMyTests
71
+
extendJukebox# Mixin `Jukebox.step` so it can be used as `step`
72
+
73
+
step 'I have {int} cukes in my belly'do |board, int1|
74
+
pending! # Write code here that turns the phrase above into concrete actions
75
+
board # return the updated board
76
+
end
77
+
78
+
step :beforedo |boardscenario|
79
+
pending! # Write code here that runs before each scenario
80
+
board # return the updated board
81
+
end
82
+
83
+
step :before {:tags"@user and @admin"} do |board|
84
+
pending! # Write code here that will run before each scenario that matches the tag expression
85
+
board # return the updated board
86
+
end
87
+
88
+
step :afterdo |boardscenario|
89
+
pending! # Write code here that runs after each scenario
90
+
board # return the updated board
91
+
end
92
+
93
+
step :after_stepdo |boardscenario|
94
+
pending! # Write code here that runs before each step
95
+
board # return the updated board
96
+
end
97
+
98
+
step :before_stepdo |boardscenario|
99
+
pending! # Write code here that runs after each step
100
+
board # return the updated board
101
+
end
102
+
end
103
+
```
102
104
103
105
### Cucumber Compatibility
104
106
If a step is defined in a cucumber style (`When`, `Then`, etc), then the Ruby jukebox language client will switch to Cucumber compatibility mode. This mode replicates / requires the code to be laid out in the cucumber conventions. In compatibility mode, the `board` is not provided to the step definition, unless the arity supports it.
@@ -107,48 +109,48 @@ If a step is defined in a cucumber style (`When`, `Then`, etc), then the Ruby ju
107
109
### Defining steps with metadata tags
108
110
Functions can be tagged as step definitions using function meta:
109
111
110
-
```clojure
111
-
(defn i-have-cukes-in-my-belly
112
-
"Returns an updated context (`board`)."
113
-
{:scene/step "I have {int} cukes in my belly"}
114
-
[board, int1]
115
-
;; Write code here that turns the phrase above into concrete actions
116
-
(throw (cucumber.api.PendingException.))
117
-
board) ;; Return the board
118
-
```
112
+
```clojure
113
+
(defni-have-cukes-in-my-belly
114
+
"Returns an updated context (`board`)."
115
+
{:scene/step"I have {int} cukes in my belly"}
116
+
[board, int1]
117
+
;; Write code here that turns the phrase above into concrete actions
118
+
(throw (cucumber.api.PendingException.))
119
+
board) ;; Return the board
120
+
```
119
121
120
122
Functions can be tagged as hooks with the metadata keys: `:step/before`, `:step/after`, `:step/before-step`, or `:step/after-step`:
121
-
```clojure
122
-
(defn ^:scene/before webdriver-initialize
123
-
"Initialize a webdriver."
124
-
[board scenario]
125
-
(assoc board :web-driver (web/driver)))
126
-
```
123
+
```clojure
124
+
(defn ^:scene/before webdriver-initialize
125
+
"Initialize a webdriver."
126
+
[board scenario]
127
+
(assoc board :web-driver (web/driver)))
128
+
```
127
129
128
130
### Defining steps with the `step` macro
129
131
Steps can now alternatively be defined with the `step` macro that works like the Ruby version:
130
132
131
-
```clojure
132
-
(ns example.belly
133
-
(:require [fundingcircle.jukebox :refer [step]]))
134
-
135
-
(step "I have {int} cukes in my belly"
136
-
[board int1]
137
-
board) ;; return the updated board
138
-
139
-
(step :before ;; Run before every scenario
140
-
[board scenario]
141
-
board)
142
-
143
-
(step :before-step {:tags "@user and @admin"} ;; Run before the scenarios with the matching tags
144
-
[board scenario]
145
-
board)
146
-
147
-
(step :after ;; Run after each scenario
148
-
[board scenario]
149
-
board)
150
-
151
-
(step :after-step ;; Run after each step
152
-
[board scenario]
153
-
board)
154
-
```
133
+
```clojure
134
+
(nsexample.belly
135
+
(:require [fundingcircle.jukebox :refer [step]]))
136
+
137
+
(step"I have {int} cukes in my belly"
138
+
[board int1]
139
+
board) ;; return the updated board
140
+
141
+
(step:before;; Run before every scenario
142
+
[board scenario]
143
+
board)
144
+
145
+
(step:before-step {:tags"@user and @admin"} ;; Run before the scenarios with the matching tags
0 commit comments