gurke 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce0e4ed76f5703f456d4b61652d9513c638aceb0
4
- data.tar.gz: 382649bd5fc1a0cc66c9130ebb00ec0554a7c07e
3
+ metadata.gz: 2ae8f014fa9426bee265884de381e9896f1f137b
4
+ data.tar.gz: 0f6f7c9ce66c5324ce8e674314bfc4fc53102af0
5
5
  SHA512:
6
- metadata.gz: 03fd359c067a79572e4a3397bae0934f63fcfa8b260d1e3110badd7ae387ec2bf73b5947b5cb7da01a41f3306031d9ab6b13cfa817608de40cb921ba2068f6ca
7
- data.tar.gz: 299a6b0be5c7793327f37da4401771bf087614231eedcd9e41cb8ef5e7831f745f5d75a7da238afbeba9c8198e49a55b7cc938afdb1c17fbef921af791eeaaad
6
+ metadata.gz: 6b8083fd8df6ab67d1b81c82a9338e957e0b38c09c643dbd4acc7129d596b5e99c8456d0147ad99b3cc9e2e6e44065d92884dc69c9a7437b19fab550494fcd58
7
+ data.tar.gz: 7dd59266bd30336400e5dc8c61baf00b0e11e5d4bbb6b9cc5ae3f90d84dded6bc2a8e4c6ca2ad929613c5b3815a5336dc15343a45a98d485b0917451b1ad5a09
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.0
4
+
5
+ * Step inclusion can be scoped to specific tags (45cea9ab)
6
+
3
7
  ## 2.2.2
4
8
 
5
9
  * TeamCityReporter: Fixing mark test as pending
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"
@@ -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
@@ -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
@@ -1,8 +1,8 @@
1
1
  module Gurke
2
2
  module VERSION
3
3
  MAJOR = 2
4
- MINOR = 2
5
- PATCH = 2
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  STAGE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
8
8
 
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.2.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-07-01 00:00:00.000000000 Z
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