gurke 3.3.3 → 3.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +39 -35
- data/features/support/steps/cli_steps.rb +8 -12
- data/gurke.gemspec +6 -13
- data/lib/gurke/background.rb +0 -1
- data/lib/gurke/builder.rb +1 -1
- data/lib/gurke/cli.rb +7 -7
- data/lib/gurke/configuration.rb +4 -6
- data/lib/gurke/dsl.rb +4 -4
- data/lib/gurke/feature_list.rb +4 -4
- data/lib/gurke/reporter.rb +11 -9
- data/lib/gurke/reporters/compact_reporter.rb +5 -6
- data/lib/gurke/reporters/default_reporter.rb +5 -5
- data/lib/gurke/reporters/null_reporter.rb +1 -1
- data/lib/gurke/reporters/team_city_reporter.rb +1 -1
- data/lib/gurke/runner.rb +5 -5
- data/lib/gurke/scenario.rb +0 -1
- data/lib/gurke/step.rb +2 -3
- data/lib/gurke/step_definition.rb +2 -1
- data/lib/gurke/steps.rb +5 -4
- data/lib/gurke/tag.rb +2 -2
- data/lib/gurke/version.rb +2 -2
- data/lib/gurke.rb +2 -2
- data/spec/gurke/feature_list_spec.rb +23 -26
- data/spec/gurke/reporters/compact_reporter_spec.rb +65 -82
- data/spec/gurke/reporters/default_reporter_spec.rb +58 -79
- data/spec/gurke/reporters/team_city_reporter_spec.rb +43 -53
- data/spec/gurke/run_list_spec.rb +10 -12
- data/spec/gurke/scenario_spec.rb +40 -35
- data/spec/gurke/step_definition_spec.rb +10 -10
- data/spec/spec_helper.rb +12 -9
- metadata +13 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322a0da4f1144d8731c128defb26359658b933496b2f7033123e413cb754a74c
|
4
|
+
data.tar.gz: 6d14692f0061b371be67376920f3c5f76a8adc3dd8cc6a01b84dbe8d5796ea73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9daef2468e65bd5df367479f6ab74ca0b492e9093f9984e4d7847fdb8e71d73fcea728e123593d09825967ee1ac41ef7b0abe03f2516d5f8edbd92938cf6749
|
7
|
+
data.tar.gz: 8c39e5a7be118c60a9c9a9996d7e2982b570640490d0d7e3e4f56bde0930507363343268360011cc3c85d563457f671c4734c8889c8b125f68c9e467056a3d43
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.3.5
|
4
|
+
|
5
|
+
* Test with Ruby 2.7, 3.0, 3.1, and 3.2
|
6
|
+
* Upgrade to Ruby 2.7+
|
7
|
+
* Fix required `StringIO` usage
|
8
|
+
* Fix `send :include`
|
9
|
+
|
10
|
+
## 3.3.4
|
11
|
+
|
12
|
+
* Replace renamed trollop dependency with optimist
|
13
|
+
|
3
14
|
## 3.3.3
|
4
15
|
|
5
16
|
* Fix a TC reporter issues reporting all scenarios as aborted
|
data/README.md
CHANGED
@@ -1,16 +1,26 @@
|
|
1
1
|
# Gurke
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Build Status](https://github.com/jgraichen/gurke/actions/workflows/test.yml/badge.svg)](https://github.com/jgraichen/gurke/actions/workflows/test.yml)
|
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
|
7
|
+
That includes:
|
8
|
+
|
9
|
+
* Step definitions in modules
|
10
|
+
* Before, After and Around hooks
|
11
|
+
* Formatters
|
12
|
+
* Partial step inclusion (via modules)
|
13
|
+
* Keyword-dependent steps
|
14
|
+
* Scenario-local world
|
15
|
+
* Running DRb background test server.
|
8
16
|
|
9
17
|
## Installation
|
10
18
|
|
11
19
|
Or install it yourself as:
|
12
20
|
|
13
|
-
|
21
|
+
```console
|
22
|
+
gem install gurke
|
23
|
+
```
|
14
24
|
|
15
25
|
Or add it to your `Gemfile` and install it using bundler.
|
16
26
|
|
@@ -18,11 +28,11 @@ Or add it to your `Gemfile` and install it using bundler.
|
|
18
28
|
|
19
29
|
## Usage
|
20
30
|
|
21
|
-
|
31
|
+
First, create your `*.features` files inside `features/`, for example, `features/user/create_account.feature`. Support files and step definitions can be added as Ruby files to `features/support`.
|
22
32
|
|
23
|
-
|
33
|
+
### Configuration
|
24
34
|
|
25
|
-
|
35
|
+
For example, you can configure the environment or [hooks](#hooks):
|
26
36
|
|
27
37
|
```ruby
|
28
38
|
# features/support/gurke.rb
|
@@ -39,7 +49,9 @@ Gurke.configure do |c|
|
|
39
49
|
end
|
40
50
|
```
|
41
51
|
|
42
|
-
|
52
|
+
### Steps
|
53
|
+
|
54
|
+
Steps can be defined in Ruby modules as methods, for example in `features/support/steps`:
|
43
55
|
|
44
56
|
```ruby
|
45
57
|
# features/support/steps/file_steps.rb
|
@@ -55,7 +67,7 @@ end
|
|
55
67
|
Gurke.configure{|c| c.include FileSteps }
|
56
68
|
```
|
57
69
|
|
58
|
-
You can
|
70
|
+
You can use an existing method as a step too:
|
59
71
|
|
60
72
|
```ruby
|
61
73
|
module MySteps
|
@@ -88,9 +100,9 @@ Gurke.configure do |c|
|
|
88
100
|
end
|
89
101
|
```
|
90
102
|
|
91
|
-
Therefore you can use different step implementations for same named steps depending on the tags of the
|
103
|
+
Therefore, you can use different step implementations for same named steps depending on the tags of the feature and scenario.
|
92
104
|
|
93
|
-
|
105
|
+
#### Keyword specific step definitions
|
94
106
|
|
95
107
|
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.
|
96
108
|
|
@@ -101,23 +113,23 @@ module PathSteps
|
|
101
113
|
end
|
102
114
|
```
|
103
115
|
|
104
|
-
Therefore you can write your scenarios in a documentary style of facts:
|
116
|
+
Therefore, you can write your scenarios in a documentary style of facts:
|
105
117
|
|
106
|
-
```
|
107
|
-
Scenario: Use the back button
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
118
|
+
```feature
|
119
|
+
Scenario: Use the back button
|
120
|
+
Given I am on the start page
|
121
|
+
When I click on "Go to another page"
|
122
|
+
And I click the back button
|
123
|
+
Then I am on the start page
|
112
124
|
```
|
113
125
|
|
114
126
|
`And` and `But` steps will inherit the keyword type from the step before, e.g. the `And` step above will be of the `when` type.
|
115
127
|
|
116
|
-
###
|
128
|
+
### Hooks
|
117
129
|
|
118
|
-
Each scenario runs in
|
130
|
+
Each scenario runs in its own world. All modules registered to be included will be included in this world. Before and after scenario or step hooks will also be executed within this world. All steps are run in this world.
|
119
131
|
|
120
|
-
You can define hooks similar to
|
132
|
+
You can define hooks similar to `rspec`:
|
121
133
|
|
122
134
|
```ruby
|
123
135
|
Gurke.configure do |config|
|
@@ -152,13 +164,13 @@ Examples:
|
|
152
164
|
|
153
165
|
You can also specify a list of files that will be run:
|
154
166
|
|
155
|
-
```
|
167
|
+
```console
|
156
168
|
gurke features/my_feature.feature
|
157
169
|
```
|
158
170
|
|
159
171
|
If you append one or more line numbers - separated by colons - only the scenarios defined around the given lines will be run:
|
160
172
|
|
161
|
-
```
|
173
|
+
```console
|
162
174
|
gurke features/my_feature.feature:14:34
|
163
175
|
```
|
164
176
|
|
@@ -166,7 +178,7 @@ gurke features/my_feature.feature:14:34
|
|
166
178
|
|
167
179
|
If you have scenarios that might fail sometime, you can mark them as `@flaky`:
|
168
180
|
|
169
|
-
```
|
181
|
+
```feature
|
170
182
|
Feature: F
|
171
183
|
@flaky
|
172
184
|
Scenario: I am flaky
|
@@ -180,7 +192,7 @@ Gurke will retry a marked scenario only once if a step failed.
|
|
180
192
|
|
181
193
|
You can choose another formatter using a command line switch:
|
182
194
|
|
183
|
-
```
|
195
|
+
```console
|
184
196
|
gurke -f team_city
|
185
197
|
```
|
186
198
|
|
@@ -200,9 +212,9 @@ Remember to reload e.g. your step definitions before `:features` to pick up chan
|
|
200
212
|
end
|
201
213
|
```
|
202
214
|
|
203
|
-
Use the after `:system` hook to
|
215
|
+
Use the after `:system` hook to shut down resources.
|
204
216
|
|
205
|
-
Remember to restart background server when changing hooks, configuration or removing/redefining steps as otherwise the changes won't be picked up
|
217
|
+
Remember to restart the running background server when changing hooks, configuration or removing/redefining steps as otherwise the changes won't be picked up, steps won't change, or are ambiguous now.
|
206
218
|
|
207
219
|
## TODO
|
208
220
|
|
@@ -211,16 +223,8 @@ Remember to restart background server when changing hooks, configuration or remo
|
|
211
223
|
* Random run order (rspec)
|
212
224
|
* Using strings with placeholders as step pattern (turnip)
|
213
225
|
* Custom placeholders (turnip)
|
214
|
-
* More reporters (NyanCat / JUnit /
|
226
|
+
* More reporters (NyanCat / JUnit / Adapter to run multiple reporters)
|
215
227
|
* SimpleCov support (and use it in own tests)
|
216
228
|
* Scope hooks by scenario tags
|
217
229
|
* Fast-fail
|
218
230
|
* Additional feature-scope and global worlds
|
219
|
-
|
220
|
-
## History
|
221
|
-
|
222
|
-
Now: * Can finally (start to) test itself.
|
223
|
-
|
224
|
-
## Contributing
|
225
|
-
|
226
|
-
Send me code.
|
@@ -5,21 +5,17 @@ require 'open3'
|
|
5
5
|
module CLISteps
|
6
6
|
def _execute(args = nil)
|
7
7
|
Dir.chdir(@__root) do
|
8
|
-
|
9
|
-
cmd = ['ruby']
|
10
|
-
cmd << '-I' << Gurke.root.join('..', 'lib').realpath
|
11
|
-
cmd << '-S' << Gurke.root.join('..', 'bin', 'gurke').realpath
|
8
|
+
cmd = %w[bundle exec gurke]
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
unless args.to_s.include?('-f ') || args.to_s.include?('--formatter ')
|
11
|
+
cmd << '-f' << 'default'
|
12
|
+
end
|
16
13
|
|
17
|
-
|
14
|
+
cmd << args.to_s
|
18
15
|
|
19
|
-
|
16
|
+
out, err, status = Open3.capture3 cmd.join ' '
|
20
17
|
|
21
|
-
|
22
|
-
end
|
18
|
+
@last_process = [Integer(status), out, err]
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
@@ -46,7 +42,7 @@ module CLISteps
|
|
46
42
|
end
|
47
43
|
|
48
44
|
step(/the program output should not include "(.*?)"/,
|
49
|
-
:_cli_not_include_content)
|
45
|
+
:_cli_not_include_content,)
|
50
46
|
|
51
47
|
step(/all scenarios have passed/) do
|
52
48
|
_cli_include_content 'scenarios: 0 failing, 0 pending'
|
data/gurke.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'gurke/version'
|
6
6
|
|
@@ -8,32 +8,25 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'gurke'
|
9
9
|
spec.version = Gurke::VERSION
|
10
10
|
spec.authors = ['Jan Graichen']
|
11
|
-
spec.email = %w[
|
11
|
+
spec.email = %w[jgraichen@altimos.de]
|
12
12
|
spec.homepage = 'https://github.com/jgraichen/gurke'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
|
-
spec.description = \
|
16
|
-
'An alternative gherkin feature runner inspired by rspec and turnip.'
|
17
15
|
spec.summary = \
|
18
16
|
'An alternative gherkin feature runner inspired by rspec and turnip.'
|
19
17
|
|
18
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
19
|
+
spec.required_ruby_version = '>= 2.7.0'
|
20
|
+
|
20
21
|
spec.files = Dir['**/*'].grep %r{^(
|
21
22
|
(bin/|lib/|test/|spec/|features/)|
|
22
23
|
(\w*\.gemspec|LICENSE.*|README.*|CHANGELOG.*)$
|
23
24
|
)}x
|
24
25
|
|
25
26
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
26
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
27
|
spec.require_paths = %w[lib]
|
28
28
|
|
29
29
|
spec.add_dependency 'colorize'
|
30
30
|
spec.add_dependency 'gherkin', '~> 2.0'
|
31
|
-
spec.add_dependency '
|
32
|
-
|
33
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
34
|
-
|
35
|
-
if ENV['TRAVIS_BUILD_NUMBER'] && !ENV['TRAVIS_TAG']
|
36
|
-
# Append travis build number for auto-releases
|
37
|
-
spec.version = "#{spec.version}.1.b#{ENV['TRAVIS_BUILD_NUMBER']}"
|
38
|
-
end
|
31
|
+
spec.add_dependency 'optimist', '~> 3.0'
|
39
32
|
end
|
data/lib/gurke/background.rb
CHANGED
data/lib/gurke/builder.rb
CHANGED
data/lib/gurke/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'optimist'
|
4
4
|
|
5
5
|
module Gurke
|
6
6
|
class CLI
|
@@ -11,11 +11,11 @@ module Gurke
|
|
11
11
|
#
|
12
12
|
def run(argv)
|
13
13
|
call parser.parse(argv), argv
|
14
|
-
rescue
|
14
|
+
rescue Optimist::VersionNeeded
|
15
15
|
print_version && exit
|
16
|
-
rescue
|
16
|
+
rescue Optimist::HelpNeeded
|
17
17
|
print_help && exit
|
18
|
-
rescue
|
18
|
+
rescue Optimist::CommandlineError => e
|
19
19
|
warn "Error: #{e}"
|
20
20
|
warn "Run with `-h' for more information on available arguments."
|
21
21
|
exit 255
|
@@ -56,7 +56,7 @@ module Gurke
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def parser
|
59
|
-
@parser ||=
|
59
|
+
@parser ||= Optimist::Parser.new do
|
60
60
|
opt :help, 'Print this help.'
|
61
61
|
opt :version, 'Show program version information.'
|
62
62
|
opt :backtrace, 'Show full error backtraces.'
|
@@ -67,7 +67,7 @@ module Gurke
|
|
67
67
|
opt :require, 'Files matching this pattern will be required after' \
|
68
68
|
'loading environment but before running features.',
|
69
69
|
default: ['features/steps/**/*.rb',
|
70
|
-
'features/support/steps/**/*.rb'],
|
70
|
+
'features/support/steps/**/*.rb',],
|
71
71
|
multi: true
|
72
72
|
opt :tags, 'Only run features and scenarios matching given tag ' \
|
73
73
|
'filtering expression. TODO: Description.',
|
@@ -85,7 +85,7 @@ module Gurke
|
|
85
85
|
files = Dir[options[:pattern].to_s] if files.empty? && options[:pattern]
|
86
86
|
files.each_with_object([]) do |input, memo|
|
87
87
|
if File.directory? input
|
88
|
-
Dir[input
|
88
|
+
Dir["#{input}/**/*"].each do |file_in_dir|
|
89
89
|
if options[:pattern] &&
|
90
90
|
!File.fnmatch?(options[:pattern], file_in_dir)
|
91
91
|
next
|
data/lib/gurke/configuration.rb
CHANGED
@@ -91,7 +91,7 @@ module Gurke
|
|
91
91
|
feature: HookSet.new,
|
92
92
|
scenario: HookSet.new,
|
93
93
|
step: HookSet.new,
|
94
|
-
system: HookSet.new
|
94
|
+
system: HookSet.new,
|
95
95
|
}
|
96
96
|
|
97
97
|
hooks[:each] = hooks[:scenario]
|
@@ -152,11 +152,9 @@ module Gurke
|
|
152
152
|
end.call
|
153
153
|
ensure
|
154
154
|
@after.each do |hook|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
|
159
|
-
end
|
155
|
+
hook.run world, ctx
|
156
|
+
rescue StandardError => e
|
157
|
+
warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
|
160
158
|
end
|
161
159
|
end
|
162
160
|
|
data/lib/gurke/dsl.rb
CHANGED
@@ -8,7 +8,7 @@ module Gurke
|
|
8
8
|
method_name = nil
|
9
9
|
end
|
10
10
|
|
11
|
-
if method_name &&
|
11
|
+
if method_name && block
|
12
12
|
raise ArgumentError.new <<~ERR.strip
|
13
13
|
You can either specify a method name or given a block, not both.
|
14
14
|
ERR
|
@@ -24,14 +24,14 @@ module Gurke
|
|
24
24
|
step.match(name, s)
|
25
25
|
end
|
26
26
|
|
27
|
-
if
|
27
|
+
if block
|
28
28
|
define_method(step.method_name.to_s, &block)
|
29
29
|
elsif method_name
|
30
30
|
alias_method step.method_name.to_s, method_name
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
# rubocop:disable MethodName
|
34
|
+
# rubocop:disable Naming/MethodName
|
35
35
|
def Given(pattern, method_name = nil, opts = {}, &block)
|
36
36
|
step pattern, method_name, opts.merge(type: :given), &block
|
37
37
|
end
|
@@ -43,6 +43,6 @@ module Gurke
|
|
43
43
|
def Then(pattern, method_name = nil, opts = {}, &block)
|
44
44
|
step pattern, method_name, opts.merge(type: :then), &block
|
45
45
|
end
|
46
|
-
# rubocop:enable MethodName
|
46
|
+
# rubocop:enable Naming/MethodName
|
47
47
|
end
|
48
48
|
end
|
data/lib/gurke/feature_list.rb
CHANGED
@@ -30,7 +30,7 @@ module Gurke
|
|
30
30
|
filter = Filter.new options, files
|
31
31
|
|
32
32
|
each do |feature|
|
33
|
-
file, _lines = files.
|
33
|
+
file, _lines = files.find {|f, _| f == feature.file }
|
34
34
|
next unless file
|
35
35
|
|
36
36
|
f = Feature.new(feature)
|
@@ -53,7 +53,7 @@ module Gurke
|
|
53
53
|
each do |feature|
|
54
54
|
feature.run runner, reporter
|
55
55
|
end
|
56
|
-
rescue Interrupt
|
56
|
+
rescue Interrupt
|
57
57
|
# nothing
|
58
58
|
ensure
|
59
59
|
reporter.invoke :end_features, self
|
@@ -84,7 +84,7 @@ module Gurke
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def filtered_by_line?(scenario)
|
87
|
-
_, lines = files.
|
87
|
+
_, lines = files.find {|f, _| f == scenario.file }
|
88
88
|
|
89
89
|
return false if lines.empty?
|
90
90
|
|
@@ -93,7 +93,7 @@ module Gurke
|
|
93
93
|
|
94
94
|
TagFilter = Struct.new(:tag) do
|
95
95
|
def name
|
96
|
-
@name ||= negated? ? tag[1
|
96
|
+
@name ||= negated? ? tag[1..] : tag
|
97
97
|
end
|
98
98
|
|
99
99
|
def negated?
|
data/lib/gurke/reporter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'stringio'
|
4
|
+
|
3
5
|
module Gurke
|
4
6
|
#
|
5
7
|
# A {Reporter} provides callbacks that will be executed whenever
|
@@ -275,26 +277,26 @@ module Gurke
|
|
275
277
|
|
276
278
|
protected
|
277
279
|
|
278
|
-
def format_exception(
|
279
|
-
s = StringIO.new
|
280
|
-
s << (' ' * indent) <<
|
280
|
+
def format_exception(err, backtrace: true, indent: 0)
|
281
|
+
s = ::StringIO.new
|
282
|
+
s << (' ' * indent) << err.class.to_s << ': ' << err.message.strip << "\n"
|
281
283
|
|
282
|
-
if backtrace &&
|
283
|
-
if
|
284
|
+
if backtrace && err.respond_to?(:backtrace)
|
285
|
+
if err.backtrace.nil?
|
284
286
|
s << (' ' * indent) << ' <no backtrace available>'
|
285
|
-
elsif
|
287
|
+
elsif err.backtrace.empty?
|
286
288
|
s << (' ' * indent) << ' <backtrace empty>'
|
287
289
|
else
|
288
|
-
|
290
|
+
err.backtrace.each do |bt|
|
289
291
|
s << (' ' * indent) << ' ' << bt.strip << "\n"
|
290
292
|
end
|
291
293
|
end
|
292
294
|
end
|
293
295
|
|
294
|
-
if
|
296
|
+
if err.respond_to?(:cause) && err.cause && err.cause.respond_to?(:message)
|
295
297
|
s << (' ' * indent) << 'caused by: '
|
296
298
|
s << format_exception(
|
297
|
-
|
299
|
+
err.cause, backtrace: backtrace, indent: indent,
|
298
300
|
).strip
|
299
301
|
end
|
300
302
|
|
@@ -9,11 +9,11 @@ require 'colorize'
|
|
9
9
|
# :light_magenta, :light_cyan, :light_white
|
10
10
|
#
|
11
11
|
module Gurke::Reporters
|
12
|
-
#
|
13
12
|
class CompactReporter < NullReporter
|
14
13
|
attr_reader :io
|
15
14
|
|
16
15
|
def initialize(io = $stdout)
|
16
|
+
super()
|
17
17
|
@io = io
|
18
18
|
end
|
19
19
|
|
@@ -95,10 +95,10 @@ module Gurke::Reporters
|
|
95
95
|
scenarios = features.map(&:scenarios).flatten
|
96
96
|
|
97
97
|
size = scenarios.size
|
98
|
-
passed = scenarios.
|
99
|
-
failed = scenarios.
|
100
|
-
pending = scenarios.
|
101
|
-
not_run = size - scenarios.
|
98
|
+
passed = scenarios.count(&:passed?)
|
99
|
+
failed = scenarios.count(&:failed?)
|
100
|
+
pending = scenarios.count(&:pending?)
|
101
|
+
not_run = size - scenarios.count(&:run?)
|
102
102
|
|
103
103
|
message = "#{scenarios.size} scenarios: "
|
104
104
|
message += "#{passed} passed, "
|
@@ -130,7 +130,6 @@ module Gurke::Reporters
|
|
130
130
|
magenta cyan white default light_black
|
131
131
|
light_red light_green light_yellow light_blue
|
132
132
|
light_magenta light_cyan light_white].each do |color|
|
133
|
-
|
134
133
|
define_method(color) {|str| io.tty? ? str.send(color) : str }
|
135
134
|
end
|
136
135
|
end
|
@@ -17,6 +17,7 @@ module Gurke::Reporters
|
|
17
17
|
attr_reader :io
|
18
18
|
|
19
19
|
def initialize(io = $stdout)
|
20
|
+
super()
|
20
21
|
@io = io
|
21
22
|
end
|
22
23
|
|
@@ -93,10 +94,10 @@ module Gurke::Reporters
|
|
93
94
|
scenarios = features.map(&:scenarios).flatten
|
94
95
|
|
95
96
|
size = scenarios.size
|
96
|
-
passed = scenarios.
|
97
|
-
failed = scenarios.
|
98
|
-
pending = scenarios.
|
99
|
-
not_run = size - scenarios.
|
97
|
+
passed = scenarios.count(&:passed?)
|
98
|
+
failed = scenarios.count(&:failed?)
|
99
|
+
pending = scenarios.count(&:pending?)
|
100
|
+
not_run = size - scenarios.count(&:run?)
|
100
101
|
|
101
102
|
message = "#{scenarios.size} scenarios: "
|
102
103
|
message += "#{passed} passed, " unless passed == size || passed.zero?
|
@@ -159,7 +160,6 @@ module Gurke::Reporters
|
|
159
160
|
magenta cyan white default light_black
|
160
161
|
light_red light_green light_yellow light_blue
|
161
162
|
light_magenta light_cyan light_white].each do |color|
|
162
|
-
|
163
163
|
define_method(color) {|str| io.tty? ? str.send(color) : str }
|
164
164
|
end
|
165
165
|
end
|
@@ -6,7 +6,7 @@ module Gurke::Reporters
|
|
6
6
|
#
|
7
7
|
class NullReporter < Gurke::Reporter
|
8
8
|
Gurke::Reporter::CALLBACKS.each do |cb|
|
9
|
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
9
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1 # rubocop:disable Style/DocumentDynamicEvalDefinition
|
10
10
|
def #{cb}(*) end
|
11
11
|
RUBY
|
12
12
|
end
|
data/lib/gurke/runner.rb
CHANGED
@@ -11,10 +11,10 @@ module Gurke
|
|
11
11
|
|
12
12
|
def reporter
|
13
13
|
@reporter ||= begin
|
14
|
-
r =
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
r = "#{options[:formatter]}_reporter"
|
15
|
+
.split('_')
|
16
|
+
.map(&:capitalize)
|
17
|
+
.join
|
18
18
|
|
19
19
|
Reporters.const_get(r).new
|
20
20
|
end
|
@@ -27,7 +27,7 @@ module Gurke
|
|
27
27
|
def run(files, reporter = self.reporter)
|
28
28
|
files.map! do |file|
|
29
29
|
split = file.split(':')
|
30
|
-
[split[0], split[1
|
30
|
+
[split[0], split[1..].map {|i| Integer(i) }]
|
31
31
|
end
|
32
32
|
|
33
33
|
features = builder.load(files.map {|file, _| file })
|
data/lib/gurke/scenario.rb
CHANGED
data/lib/gurke/step.rb
CHANGED
@@ -66,7 +66,7 @@ module Gurke
|
|
66
66
|
rescue StepPending => e
|
67
67
|
scenario.pending! e
|
68
68
|
result = StepResult.new self, scenario, :pending, e
|
69
|
-
rescue Exception => e # rubocop:disable RescueException
|
69
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
70
70
|
scenario.failed! e
|
71
71
|
result = StepResult.new self, scenario, :failed, e
|
72
72
|
ensure
|
@@ -88,7 +88,6 @@ module Gurke
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
#
|
92
91
|
class StepResult
|
93
92
|
attr_reader :step, :exception, :state, :scenario
|
94
93
|
|
@@ -100,7 +99,7 @@ module Gurke
|
|
100
99
|
end
|
101
100
|
|
102
101
|
Step.public_instance_methods(false).each do |mth|
|
103
|
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
102
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1 # rubocop:disable Style/DocumentDynamicEvalDefinition
|
104
103
|
def #{mth}(*args) @step.send(:#{mth}, *args); end
|
105
104
|
RUBY
|
106
105
|
end
|
@@ -20,11 +20,12 @@ module Gurke
|
|
20
20
|
def match(name, type = :any)
|
21
21
|
return if self.type != :any && self.type != type
|
22
22
|
return if pattern.is_a?(String) && name != pattern
|
23
|
+
|
23
24
|
match = pattern.match(name)
|
24
25
|
|
25
26
|
return unless match
|
26
27
|
|
27
|
-
Match.new method_name, match.to_a[1
|
28
|
+
Match.new method_name, match.to_a[1..]
|
28
29
|
end
|
29
30
|
|
30
31
|
Match = Struct.new :method_name, :params
|