This repository was archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexecution_order.feature
More file actions
79 lines (66 loc) · 2.3 KB
/
execution_order.feature
File metadata and controls
79 lines (66 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Feature: Execution order
Background:
Given I have Dredd installed
And a file named "apiary.apib" with:
"""
# My Api
## GET /message
+ Response 200 (text/plain)
Hello World!
"""
And a file "server.js" with a server responding on "http://localhost:4567/message" with "Hello World!"
Scenario:
Given a file named "hookfile.rb" with:
"""
require 'dredd_hooks/methods'
include DreddHooks::Methods
key = 'hooks_modifications'
before("/message > GET") do |transaction|
transaction[key] ||= []
transaction[key].push "before modification"
end
after("/message > GET") do |transaction|
transaction[key] ||= []
transaction[key].push "after modification"
end
before_validation("/message > GET") do |transaction|
transaction[key] ||= []
transaction[key].push "before validation modification"
end
before_all do |transaction|
transaction[0][key] ||= []
transaction[0][key].push "before all modification"
end
after_all do |transaction|
transaction[0][key] ||= []
transaction[0][key].push "after all modification"
end
before_each do |transaction|
transaction[key] ||= []
transaction[key].push "before each modification"
end
before_each_validation do |transaction|
transaction[key] ||= []
transaction[key].push "before each validation modification"
end
after_each do |transaction|
transaction[key] ||= []
transaction[key].push "after each modification"
end
"""
And I set the environment variables to:
| variable | value |
| TEST_DREDD_HOOKS_HANDLER_ORDER | true |
When I run `dredd ./apiary.apib http://localhost:4567 --server="node server.js" --language="bundle exec dredd-hooks-ruby" --hookfiles=./hookfile.rb --loglevel=debug`
Then the exit status should be 0
And the output should contain:
"""
0 before all modification
1 before each modification
2 before modification
3 before each validation modification
4 before validation modification
5 after modification
6 after each modification
7 after all modification
"""