gurke 2.3.0 → 2.4.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: 2ae8f014fa9426bee265884de381e9896f1f137b
4
- data.tar.gz: 0f6f7c9ce66c5324ce8e674314bfc4fc53102af0
3
+ metadata.gz: 1cd784fe71ce083826f06bc56a0c2688468a85ef
4
+ data.tar.gz: e18151208f931bd806513d2be7639221a0e59325
5
5
  SHA512:
6
- metadata.gz: 6b8083fd8df6ab67d1b81c82a9338e957e0b38c09c643dbd4acc7129d596b5e99c8456d0147ad99b3cc9e2e6e44065d92884dc69c9a7437b19fab550494fcd58
7
- data.tar.gz: 7dd59266bd30336400e5dc8c61baf00b0e11e5d4bbb6b9cc5ae3f90d84dded6bc2a8e4c6ca2ad929613c5b3815a5336dc15343a45a98d485b0917451b1ad5a09
6
+ metadata.gz: ac6c0e0c475b508ac69fcb3632e0f2b402fc3db9664f0d9783fa9bdd00be4c880733be1cc1382ce36edaae3a355f892ea8cc2e33f199ff033d5a80e0c02a40a9
7
+ data.tar.gz: 535e2ddbfee0a1f991c1fe60929c3a546f634fcd23741422bfe42f99e6dd43e061ad7039e0fc3d95b4553a359de45ba6216616a3fb02fa1e7ccf6563305f034e
data/README.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  **Gurke** is an experimental, alternative cucumber runner. It ~~steals~~ borrows ideas and concepts from [turnip](https://github.com/jnicklas/turnip), [rspec](http://rspec.info) and tries to avoid [cucumber](https://github.com/cucumber/cucumber/).
6
6
 
7
- That includes * Step definitions in modules * Before, After and Around hooks * Formatters * Partial step inclusion (via modules) * etc. Also new ideas like keyword depended step definitions are planned.
8
-
9
- But still **Gurke** is unfinished, not recommended and highly dangerous!
7
+ That includes * Step definitions in modules * Before, After and Around hooks * Formatters * Partial step inclusion (via modules) * Keyword-dependent steps * Scenario-local world * Running DRb background test server.
10
8
 
11
9
  ## Installation
12
10
 
@@ -158,7 +156,7 @@ You can also specify a list of files that will be run:
158
156
  gurke features/my_feature.feature
159
157
  ```
160
158
 
161
- If you append one or more line numbers - separated by dashes - only the scenarios defined around the given lines will be run:
159
+ If you append one or more line numbers - separated by colons - only the scenarios defined around the given lines will be run:
162
160
 
163
161
  ```
164
162
  gurke features/my_feature.feature:14:34
@@ -185,13 +183,15 @@ Remember to restart background server when changing hooks, configuration or remo
185
183
  ## TODO
186
184
 
187
185
  * Add `context`/`ctx` object to world providing current feature/scenario/step
188
- * Allow to define scenario/feature specific after hook in steps e.g. to close opened resources
186
+ * Define scenario specific after hook in a step (e.g. to close opened resource)
189
187
  * Random run order (rspec)
190
188
  * Using strings with placeholders as step pattern (turnip)
191
189
  * Custom placeholders (turnip)
192
- * Define scenario specific after hook in a step (e.g. to close opened resource)
193
190
  * More reporters (NyanCat / JUnit / TeamCity / Adapter to run multiple reporters)
194
191
  * SimpleCov support (and use it in own tests)
192
+ * Scope hooks by scenario tags
193
+ * Fast-fail
194
+ * Additional feature-scope and global worlds
195
195
 
196
196
  ## History
197
197
 
@@ -0,0 +1,39 @@
1
+ Feature: Access context in hooks
2
+ In order to setup specific things
3
+ As a developer
4
+ I want to access meta data of the context in hooks
5
+
6
+ Background:
7
+ Given I am in a project using gurke
8
+ And a file "features/test.feature" with the following content exists
9
+ """
10
+ Feature: A
11
+ @tag
12
+ Scenario: A
13
+ Then the scenario has tag "tag"
14
+
15
+ """
16
+ And a file "features/support/steps/test_steps.rb" with the following content exists
17
+ """
18
+ require 'test/unit/assertions'
19
+
20
+ module TestSteps
21
+ include Test::Unit::Assertions
22
+
23
+ Then("the scenario has tag \"tag\"") do
24
+ assert @before_tags.include? "tag"
25
+ assert @around_tags.include? "tag"
26
+ end
27
+ end
28
+
29
+ Gurke.configure do |c|
30
+ c.include TestSteps
31
+
32
+ c.before(:each) { |s| @before_tags = s.tags }
33
+ c.around(:each) { |s| @around_tags = s.tags; s.call }
34
+ end
35
+ """
36
+
37
+ Scenario: Assertions should pass
38
+ When I execute all scenarios
39
+ Then all scenarios have passed
@@ -49,7 +49,7 @@ Feature: Run specific features or scenarios
49
49
  require 'test/unit/assertions'
50
50
 
51
51
  module Steps
52
- include MiniTest::Assertions
52
+ include Test::Unit::Assertions
53
53
 
54
54
  Given(/^I am "(.+)"$/) do |name|
55
55
  @me = name
@@ -21,7 +21,7 @@ Feature: Step keyword specific definitions
21
21
  require 'test/unit/assertions'
22
22
 
23
23
  module Steps
24
- include MiniTest::Assertions
24
+ include Test::Unit::Assertions
25
25
 
26
26
  Given(/^I am "(.+)"$/) do |name|
27
27
  @me = name
@@ -27,13 +27,13 @@ module CLISteps
27
27
  end
28
28
 
29
29
  def _cli_include_content(content)
30
- expect(@last_process[1]).to include content
30
+ expect(@last_process[1] + @last_process[2]).to include content
31
31
  end
32
32
 
33
33
  step(/the program output should include "(.*?)"/, :_cli_include_content)
34
34
 
35
35
  def _cli_not_include_content(content)
36
- expect(@last_process[1]).to_not include content
36
+ expect(@last_process[1] + @last_process[2]).to_not include content
37
37
  end
38
38
 
39
39
  step(/the program output should not include "(.*?)"/,
@@ -17,6 +17,7 @@ module FileSteps
17
17
  _write_file 'Gemfile', <<-EOS
18
18
  source 'https://rubygems.org'
19
19
  gem 'gurke', path: '#{File.dirname(Gurke.root)}'
20
+ gem 'test-unit'
20
21
  EOS
21
22
  end
22
23
 
@@ -1,3 +1,5 @@
1
+ require 'forwardable'
2
+
1
3
  module Gurke
2
4
  class Configuration
3
5
  #
@@ -122,18 +124,41 @@ module Gurke
122
124
  end
123
125
  end
124
126
 
125
- def run(world, &block)
126
- @before.each{|hook| hook.run world }
127
- @around.reduce(block){|a, e| proc{ e.run world, a }}.call
127
+ def run(context, world, &block)
128
+ ctx = Context.new context, block
129
+ @before.each{|hook| hook.run world, ctx }
130
+ @around.reduce Context.new(context, block) do |c, e|
131
+ Context.new(context, ->{ e.run world, c })
132
+ end.call
128
133
  ensure
129
134
  @after.each do |hook|
130
135
  begin
131
- hook.run world
136
+ hook.run world, ctx
132
137
  rescue => e
133
138
  warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
134
139
  end
135
140
  end
136
141
  end
142
+
143
+ class Context
144
+ extend Forwardable
145
+
146
+ def initialize(context, block)
147
+ @context, @block = context, block
148
+ end
149
+
150
+ def tags
151
+ @context.tags.map(&:name)
152
+ end
153
+
154
+ def to_proc
155
+ @block
156
+ end
157
+
158
+ def call
159
+ @block.call
160
+ end
161
+ end
137
162
  end
138
163
 
139
164
  # @api private
@@ -149,10 +174,10 @@ module Gurke
149
174
  !opts.any?{|k, v| context.metadata[k] != v }
150
175
  end
151
176
 
152
- def run(context, *args)
177
+ def run(world, *args)
153
178
  block = @block
154
- if context
155
- context.instance_exec(*args, &block)
179
+ if world
180
+ world.instance_exec(*args, &block)
156
181
  else
157
182
  block.call(*args)
158
183
  end
@@ -79,7 +79,7 @@ module Gurke
79
79
  def run(runner, reporter)
80
80
  reporter.invoke :before_feature, self
81
81
 
82
- runner.hook :feature, nil do
82
+ runner.hook :feature, self, nil do
83
83
  run_feature runner, reporter
84
84
  end
85
85
  ensure
@@ -13,7 +13,7 @@ module Gurke
13
13
  def run(runner, reporter)
14
14
  reporter.invoke :before_features, self
15
15
 
16
- runner.hook(:features, nil) do
16
+ runner.hook(:features, nil, nil) do
17
17
  run_features runner, reporter
18
18
  end
19
19
 
@@ -28,8 +28,8 @@ module Gurke
28
28
  features.filter(options, files).run self, reporter
29
29
  end
30
30
 
31
- def hook(scope, world, &block)
32
- config.hooks[scope].run world, &block
31
+ def hook(scope, world, context, &block)
32
+ config.hooks[scope].run world, context, &block
33
33
  end
34
34
 
35
35
  def with_filtered_backtrace
@@ -44,7 +44,7 @@ module Gurke
44
44
 
45
45
  class LocalRunner < Runner
46
46
  def run(*)
47
- hook :system, nil do
47
+ hook :system, nil, nil do
48
48
  super
49
49
  end
50
50
  end
@@ -56,7 +56,7 @@ module Gurke
56
56
  def run(files)
57
57
  require 'drb'
58
58
 
59
- hook :system, nil do
59
+ hook :system, nil, nil do
60
60
  DRb.start_service URI, self
61
61
  $stdout.puts 'DRb Server running...'
62
62
 
@@ -118,7 +118,7 @@ module Gurke
118
118
  def run(runner, reporter)
119
119
  reporter.invoke :before_scenario, self
120
120
 
121
- runner.hook :scenario, world do
121
+ runner.hook :scenario, self, world do
122
122
  run_scenario runner, reporter
123
123
  end
124
124
  ensure
@@ -42,7 +42,7 @@ module Gurke
42
42
  def run(runner, reporter, scenario, world)
43
43
  reporter.invoke :before_step, self, scenario
44
44
 
45
- result = runner.hook(:step, world) do
45
+ result = runner.hook(:step, self, world) do
46
46
  run_step runner, reporter, scenario, world
47
47
  end
48
48
 
@@ -22,9 +22,9 @@ module Gurke
22
22
 
23
23
  return unless match
24
24
 
25
- Match.new(method_name, match.to_a[1..-1])
25
+ Match.new method_name, match.to_a[1..-1]
26
26
  end
27
27
 
28
- class Match < Struct.new(:method_name, :params); end
28
+ Match = Struct.new :method_name, :params
29
29
  end
30
30
  end
@@ -1,7 +1,7 @@
1
1
  module Gurke
2
2
  module VERSION
3
3
  MAJOR = 2
4
- MINOR = 3
4
+ MINOR = 4
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
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.3.0
4
+ version: 2.4.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-08-25 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
@@ -81,6 +81,7 @@ files:
81
81
  - features/gurke.feature
82
82
  - features/gurke.rb
83
83
  - features/gurke/backtrace_filtering.feature
84
+ - features/gurke/context_in_hooks.feature
84
85
  - features/gurke/filter_by_tags.feature
85
86
  - features/gurke/include_by_tags.feature
86
87
  - features/gurke/other_reporter.feature
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.4.6
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: An alternative gherkin feature runner inspired by rspec and turnip.
@@ -146,6 +147,7 @@ test_files:
146
147
  - features/gurke.feature
147
148
  - features/gurke.rb
148
149
  - features/gurke/backtrace_filtering.feature
150
+ - features/gurke/context_in_hooks.feature
149
151
  - features/gurke/filter_by_tags.feature
150
152
  - features/gurke/include_by_tags.feature
151
153
  - features/gurke/other_reporter.feature