Skip to content

Commit 49dc042

Browse files
author
matthias-margush
committed
overview formatting
1 parent 52f0785 commit 49dc042

1 file changed

Lines changed: 83 additions & 81 deletions

File tree

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,58 @@ Here are some example step definition snippets:
4949

5050
## Configuration
5151
A jukebox configuration can be defined explicitly if needed in a project by creating a `.jukebox` file with the following (JSON):
52-
```json
53-
{"languages": ["ruby", "clojure"]}
54-
```
52+
```json
53+
{"languages": ["ruby", "clojure"]}
54+
```
5555

5656
In addition, the launcher details can be configured if needed by adding the "language-clients" configuration. These are the defaults:
57-
```json
58-
{"languages": ["ruby", "clojure"]
59-
"language-clients": [{:language "clojure" :launcher "jlc-clj-embedded"}
60-
{:language "ruby" :launcher "jlc-cli" :cmd ["bundle" "exec" "jlc_ruby"]}]}
61-
```
57+
```json
58+
{"languages": ["ruby", "clojure"],
59+
"language-clients": [{"language": "clojure", "launcher": "jlc-clj-embedded"},
60+
{"language": "ruby", "launcher": "jlc-cli", "cmd": ["bundle", "exec", "jlc_ruby"]}]}
61+
```
6262

6363
## Ruby Details
6464
### Defining Step Definitions & Hooks
6565
Step definitions can be defined by requiring 'jukebox' and using `step`:
6666

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
9169

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+
module MyTests
71+
extend Jukebox # 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 :before do |board scenario|
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 :after do |board scenario|
89+
pending! # Write code here that runs after each scenario
90+
board # return the updated board
91+
end
92+
93+
step :after_step do |board scenario|
94+
pending! # Write code here that runs before each step
95+
board # return the updated board
96+
end
97+
98+
step :before_step do |board scenario|
99+
pending! # Write code here that runs after each step
100+
board # return the updated board
101+
end
102+
end
103+
```
102104

103105
### Cucumber Compatibility
104106
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
107109
### Defining steps with metadata tags
108110
Functions can be tagged as step definitions using function meta:
109111

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+
(defn i-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+
```
119121
120122
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+
```
127129

128130
### Defining steps with the `step` macro
129131
Steps can now alternatively be defined with the `step` macro that works like the Ruby version:
130132

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+
(ns example.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
146+
[board scenario]
147+
board)
148+
149+
(step :after ;; Run after each scenario
150+
[board scenario]
151+
board)
152+
153+
(step :after-step ;; Run after each step
154+
[board scenario]
155+
board)
156+
```

0 commit comments

Comments
 (0)