gurke 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +20 -1
- data/features/gurke/include_by_tags.feature +66 -0
- data/lib/gurke/configuration.rb +18 -0
- data/lib/gurke/scenario.rb +9 -1
- data/lib/gurke/version.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ae8f014fa9426bee265884de381e9896f1f137b
|
4
|
+
data.tar.gz: 0f6f7c9ce66c5324ce8e674314bfc4fc53102af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b8083fd8df6ab67d1b81c82a9338e957e0b38c09c643dbd4acc7129d596b5e99c8456d0147ad99b3cc9e2e6e44065d92884dc69c9a7437b19fab550494fcd58
|
7
|
+
data.tar.gz: 7dd59266bd30336400e5dc8c61baf00b0e11e5d4bbb6b9cc5ae3f90d84dded6bc2a8e4c6ca2ad929613c5b3815a5336dc15343a45a98d485b0917451b1ad5a09
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -72,6 +72,26 @@ module MySteps
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
+
You can include some steps to only scenarios with specific tags:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
module MyStepsA
|
79
|
+
step(/I do something/) { ... }
|
80
|
+
end
|
81
|
+
|
82
|
+
Gurke.configure{|c| c.include FileSteps, tags: 'tagA' }
|
83
|
+
|
84
|
+
module MyStepsB
|
85
|
+
step(/I do something/) { ... }
|
86
|
+
end
|
87
|
+
|
88
|
+
Gurke.configure do |c|
|
89
|
+
c.include FileSteps, tags: [:tagB, 'bType'] # At least one tag has to match
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
Therefore you can use different step implementations for same named steps depending on the tags of the the feature and scenario.
|
94
|
+
|
75
95
|
### Keyword specific step definitions
|
76
96
|
|
77
97
|
You can also define steps for only a specific keyword. This also allows you to use the same step pattern for different keywords, e.g.
|
@@ -164,7 +184,6 @@ Remember to restart background server when changing hooks, configuration or remo
|
|
164
184
|
|
165
185
|
## TODO
|
166
186
|
|
167
|
-
* Import (step definition) modules based on tags (rspec: `config.include MyCLISteps, cli: true`)
|
168
187
|
* Add `context`/`ctx` object to world providing current feature/scenario/step
|
169
188
|
* Allow to define scenario/feature specific after hook in steps e.g. to close opened resources
|
170
189
|
* Random run order (rspec)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: Include by tags
|
2
|
+
As a developer
|
3
|
+
In order to be flexible with my step names
|
4
|
+
I want to include some steps only to scenarios with a specific tags
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am in a project using gurke
|
8
|
+
And a file "features/test_a.feature" with the following content exists
|
9
|
+
"""
|
10
|
+
@step1a
|
11
|
+
Feature: Feature 1
|
12
|
+
|
13
|
+
@step2a
|
14
|
+
Scenario: Scenario 1
|
15
|
+
Given this is the feature step
|
16
|
+
And this is the scenario step
|
17
|
+
"""
|
18
|
+
And a file "features/test_b.feature" with the following content exists
|
19
|
+
"""
|
20
|
+
@step1b
|
21
|
+
Feature: Feature 2
|
22
|
+
|
23
|
+
@step2b
|
24
|
+
Scenario: Scenario 2
|
25
|
+
Given this is the feature step
|
26
|
+
And this is the scenario step
|
27
|
+
"""
|
28
|
+
And a file "features/support/steps/test_steps_1a.rb" with the following content exists
|
29
|
+
"""
|
30
|
+
module Test1ASteps
|
31
|
+
Given("this is the feature step") { puts "DO STEP 1A" }
|
32
|
+
end
|
33
|
+
|
34
|
+
Gurke.config.include Test1ASteps, tags: :step1a
|
35
|
+
"""
|
36
|
+
And a file "features/support/steps/test_steps_2a.rb" with the following content exists
|
37
|
+
"""
|
38
|
+
module Test2ASteps
|
39
|
+
Given("this is the scenario step") { puts "DO STEP 2A" }
|
40
|
+
end
|
41
|
+
|
42
|
+
Gurke.config.include Test2ASteps, tags: :step2a
|
43
|
+
"""
|
44
|
+
And a file "features/support/steps/test_steps_1b.rb" with the following content exists
|
45
|
+
"""
|
46
|
+
module Test1BSteps
|
47
|
+
Given("this is the feature step") { puts "DO STEP 1B" }
|
48
|
+
end
|
49
|
+
|
50
|
+
Gurke.config.include Test1BSteps, tags: :step1b
|
51
|
+
"""
|
52
|
+
And a file "features/support/steps/test_steps_2b.rb" with the following content exists
|
53
|
+
"""
|
54
|
+
module Test2BSteps
|
55
|
+
Given("this is the scenario step") { puts "DO STEP 2B" }
|
56
|
+
end
|
57
|
+
|
58
|
+
Gurke.config.include Test2BSteps, tags: [:step2b, :anotherTag]
|
59
|
+
"""
|
60
|
+
|
61
|
+
Scenario: It should include the matching step definitions
|
62
|
+
When I execute "bundle exec gurke"
|
63
|
+
Then the program output should include "DO STEP 1A"
|
64
|
+
Then the program output should include "DO STEP 2A"
|
65
|
+
Then the program output should include "DO STEP 1B"
|
66
|
+
Then the program output should include "DO STEP 2B"
|
data/lib/gurke/configuration.rb
CHANGED
@@ -85,6 +85,24 @@ module Gurke
|
|
85
85
|
@mod = mod
|
86
86
|
@opts = opts
|
87
87
|
end
|
88
|
+
|
89
|
+
def tags
|
90
|
+
@tags ||= begin
|
91
|
+
tags = opts.fetch(:tags, [])
|
92
|
+
tags = [tags] unless tags.is_a?(Array)
|
93
|
+
tags
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def match?(tags)
|
98
|
+
return true if self.tags.empty?
|
99
|
+
|
100
|
+
self.tags.each do |tag|
|
101
|
+
return true if tags.include?(tag.to_s)
|
102
|
+
end
|
103
|
+
|
104
|
+
false
|
105
|
+
end
|
88
106
|
end
|
89
107
|
|
90
108
|
# @api private
|
data/lib/gurke/scenario.rb
CHANGED
@@ -62,6 +62,14 @@ module Gurke
|
|
62
62
|
feature.backgrounds
|
63
63
|
end
|
64
64
|
|
65
|
+
# Return a list of tag names as strings.
|
66
|
+
#
|
67
|
+
# @return [Array<String>] Tag names.
|
68
|
+
#
|
69
|
+
def tag_names
|
70
|
+
@tag_names ||= tags.map(&:name)
|
71
|
+
end
|
72
|
+
|
65
73
|
# Check if scenario is pending.
|
66
74
|
#
|
67
75
|
# @return [Boolean] True if pending, false otherwise.
|
@@ -134,7 +142,7 @@ module Gurke
|
|
134
142
|
cls.send :include, Gurke.world
|
135
143
|
|
136
144
|
Gurke.config.inclusions.each do |incl|
|
137
|
-
cls.send :include, incl.mod
|
145
|
+
cls.send :include, incl.mod if incl.match?(tag_names)
|
138
146
|
end
|
139
147
|
cls.send :include, Gurke::Steps
|
140
148
|
cls.new
|
data/lib/gurke/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gurke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- features/gurke.rb
|
83
83
|
- features/gurke/backtrace_filtering.feature
|
84
84
|
- features/gurke/filter_by_tags.feature
|
85
|
+
- features/gurke/include_by_tags.feature
|
85
86
|
- features/gurke/other_reporter.feature
|
86
87
|
- features/gurke/pending_steps.feature
|
87
88
|
- features/gurke/run_specific_directories.feature
|
@@ -146,6 +147,7 @@ test_files:
|
|
146
147
|
- features/gurke.rb
|
147
148
|
- features/gurke/backtrace_filtering.feature
|
148
149
|
- features/gurke/filter_by_tags.feature
|
150
|
+
- features/gurke/include_by_tags.feature
|
149
151
|
- features/gurke/other_reporter.feature
|
150
152
|
- features/gurke/pending_steps.feature
|
151
153
|
- features/gurke/run_specific_directories.feature
|