gurke 3.3.5 → 3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 322a0da4f1144d8731c128defb26359658b933496b2f7033123e413cb754a74c
4
- data.tar.gz: 6d14692f0061b371be67376920f3c5f76a8adc3dd8cc6a01b84dbe8d5796ea73
3
+ metadata.gz: f25197fd297ba62d42f9d4895bd3df3bd556882cd5fc66769b0bb717ebe1c16e
4
+ data.tar.gz: fd92245e82302cd497b236ba92bbcb14917dbcee30cbc0923c8ce9c9867de028
5
5
  SHA512:
6
- metadata.gz: e9daef2468e65bd5df367479f6ab74ca0b492e9093f9984e4d7847fdb8e71d73fcea728e123593d09825967ee1ac41ef7b0abe03f2516d5f8edbd92938cf6749
7
- data.tar.gz: 8c39e5a7be118c60a9c9a9996d7e2982b570640490d0d7e3e4f56bde0930507363343268360011cc3c85d563457f671c4734c8889c8b125f68c9e467056a3d43
6
+ metadata.gz: 914606fbd5b71e005980a8dec79d0842093d544299282018a2c0b2cbc4cbdce35dcbf6aa30799417ec1fca855a07bfbf958aa7abaf9f737a698b3f99b887426b
7
+ data.tar.gz: 0cd6bb85c10f9edcea212902844cc6417c857133584b1f852d31b5ae75707c8c9f2cdbec17b227f7303f90ebfe30e13eae41a54ab8b5fc852464e50e584760e8
data/CHANGELOG.md CHANGED
@@ -1,75 +1,165 @@
1
1
  # Changelog
2
2
 
3
- ## 3.3.5
3
+ All notable changes to this project will be documented in this file.
4
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`
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
7
 
10
- ## 3.3.4
8
+ ## [Unreleased]
11
9
 
12
- * Replace renamed trollop dependency with optimist
10
+ ## [3.5.0] - 2025-04-09
13
11
 
14
- ## 3.3.3
12
+ ### Added
15
13
 
16
- * Fix a TC reporter issues reporting all scenarios as aborted
14
+ - Add `--color=[(auto)|on|off]` command line flag
17
15
 
18
- ## 3.3.2
16
+ ## [3.4.0] - 2024-08-28
19
17
 
20
- * Fix teamcity and compact reporter
18
+ ### Added
21
19
 
22
- ## 3.3.1
20
+ - Support expectations in step hooks
23
21
 
24
- * Add option for default retry of failed scenarios
25
- * Make number of default and flaky retries configurable
22
+ ## [3.3.5] - 2023-10-28
26
23
 
27
- ## 3.2.2
24
+ ### Changed
28
25
 
29
- * Fix some default reporter formatting issues
26
+ - Test with Ruby 2.7, 3.0, 3.1, and 3.2
27
+ - Upgrade to Ruby 2.7+
28
+ - Fix required `StringIO` usage
29
+ - Fix `send :include`
30
30
 
31
- ## 3.2.1
31
+ ## [3.3.4] - 2018-10-26
32
32
 
33
- * Reset world between retried scenario runs
33
+ ### Changed
34
34
 
35
- ## 3.2.0
35
+ - Replace renamed trollop dependency with optimist
36
36
 
37
- * Add @flaky tag support for retrying flaky scenarios once
37
+ ## [3.3.3] - 2018-07-27
38
38
 
39
- ## 3.1.0
39
+ ### Changed
40
40
 
41
- * Update TeamCity formatter to extend default formatter
41
+ - Fix a TC reporter issues reporting all scenarios as aborted
42
42
 
43
- ## 3.0.0
43
+ ## [3.3.2] - 2018-07-27
44
44
 
45
- * Drop support for MRI < 2.3
45
+ ### Changed
46
46
 
47
- ## 2.3.0
47
+ - Fix TeamCity and compact reporter
48
48
 
49
- * Step inclusion can be scoped to specific tags (45cea9ab)
49
+ ## [3.3.1] - 2018-07-26
50
50
 
51
- ## 2.2.2
51
+ ### Changed
52
52
 
53
- * TeamCityReporter: Fixing mark test as pending
53
+ - Add option for default retry of failed scenarios
54
+ - Make number of default and flaky retries configurable
54
55
 
55
- ## 2.2.1
56
+ ## [3.2.2] - 2018-04-11
56
57
 
57
- * BugFix (missing argument in cli.rb)
58
- * BugFix in after_feature hook call (missing feature argument)
58
+ ### Changed
59
59
 
60
- ## 2.2.0
60
+ - Fix some default reporter formatting issues
61
61
 
62
- + Support executing all features inside one directory
63
- + Support reporter selection via cli
64
- + Add TeamCityReporter (`gurke --formatter team_city`)
65
- * Support string as step definitions correctly
66
- * Smaller bugfix in improved exception formatting
62
+ ## [3.2.1] - 2018-04-11
67
63
 
64
+ ### Changed
68
65
 
69
- ## 2.1.0
66
+ - Reset world between retried scenario runs
70
67
 
71
- * Improve exception formating
68
+ ## [3.2.0] - 2018-04-11
72
69
 
73
- ## 2.0.0
70
+ ### Changed
74
71
 
75
- * Project start
72
+ - Add `@flaky` tag support for retrying flaky scenarios once
73
+
74
+ ## [3.1.0] - 2018-02-26
75
+
76
+ ### Changed
77
+
78
+ - Update TeamCity formatter to extend default formatter
79
+
80
+ ## [3.0.0] - 2018-02-26
81
+
82
+ ### Changed
83
+
84
+ - Drop support for MRI < 2.3
85
+
86
+ ## [2.4.2] - 2016-05-10
87
+
88
+ ## [2.4.1] - 2016-02-10
89
+
90
+ ## [2.4.0] - 2015-05-28
91
+
92
+ ## [2.3.0] - 2014-02-26
93
+
94
+ ### Changed
95
+
96
+ - Step inclusion can be scoped to specific tags (45cea9ab)
97
+
98
+ ## [2.2.2] - 2014-07-02
99
+
100
+ ### Changed
101
+
102
+ - `TeamCityReporter`: Fixing mark test as pending
103
+
104
+ ## [2.2.1] - 2014-06-27
105
+
106
+ ### Changed
107
+
108
+ - Bug fix (missing argument in `cli.rb`)
109
+ - Bug fix in after_feature hook call (missing feature argument)
110
+
111
+ ## [2.2.0] - 2014-06-27
112
+
113
+ ### Changed
114
+
115
+ - Support executing all features inside one directory
116
+ - Support reporter selection via CLI
117
+ - Add `TeamCityReporter` (`gurke --formatter team_city`)
118
+ - Support string as step definitions correctly
119
+ - Smaller bug fix in improved exception formatting
120
+
121
+ ## [2.1.0] - 2014-06-27
122
+
123
+ ### Changed
124
+
125
+ - Improve exception formatting
126
+
127
+ ## [2.0.3] - 2014-06-24
128
+
129
+ ## [2.0.2] - 2014-06-24
130
+
131
+ ## [2.0.1] - 2014-06-18
132
+
133
+ ## [2.0.0] - 2014-06-06
134
+
135
+ ## [1.0.1] - 2014-01-22
136
+
137
+ ## [1.0.0] - 2013-12-04
138
+
139
+ [Unreleased]: https://github.com/jgraichen/gurke/compare/v3.5.0...HEAD
140
+ [3.5.0]: https://github.com/jgraichen/gurke/compare/v3.4.0...v3.5.0
141
+ [3.4.0]: https://github.com/jgraichen/gurke/compare/v3.3.5...v3.4.0
142
+ [3.3.5]: https://github.com/jgraichen/gurke/compare/v3.3.4...v3.3.5
143
+ [3.3.4]: https://github.com/jgraichen/gurke/compare/v3.3.3...v3.3.4
144
+ [3.3.3]: https://github.com/jgraichen/gurke/compare/v3.3.2...v3.3.3
145
+ [3.3.2]: https://github.com/jgraichen/gurke/compare/v3.3.1...v3.3.2
146
+ [3.3.1]: https://github.com/jgraichen/gurke/compare/v3.2.2...v3.3.1
147
+ [3.2.2]: https://github.com/jgraichen/gurke/compare/v3.2.1...v3.2.2
148
+ [3.2.1]: https://github.com/jgraichen/gurke/compare/v3.2.0...v3.2.1
149
+ [3.2.0]: https://github.com/jgraichen/gurke/compare/v3.1.0...v3.2.0
150
+ [3.1.0]: https://github.com/jgraichen/gurke/compare/v3.0.0...v3.1.0
151
+ [3.0.0]: https://github.com/jgraichen/gurke/compare/v2.4.2...v3.0.0
152
+ [2.4.2]: https://github.com/jgraichen/gurke/compare/v2.4.1...v2.4.2
153
+ [2.4.1]: https://github.com/jgraichen/gurke/compare/v2.4.0...v2.4.1
154
+ [2.4.0]: https://github.com/jgraichen/gurke/compare/v2.3.0...v2.4.0
155
+ [2.3.0]: https://github.com/jgraichen/gurke/compare/v2.2.2...v2.3.0
156
+ [2.2.2]: https://github.com/jgraichen/gurke/compare/v2.2.1...v2.2.2
157
+ [2.2.1]: https://github.com/jgraichen/gurke/compare/v2.2.0...v2.2.1
158
+ [2.2.0]: https://github.com/jgraichen/gurke/compare/v2.1.0...v2.2.0
159
+ [2.1.0]: https://github.com/jgraichen/gurke/compare/v2.0.3...v2.1.0
160
+ [2.0.3]: https://github.com/jgraichen/gurke/compare/v2.0.2...v2.0.3
161
+ [2.0.2]: https://github.com/jgraichen/gurke/compare/v2.0.1...v2.0.2
162
+ [2.0.1]: https://github.com/jgraichen/gurke/compare/v2.0.0...v2.0.1
163
+ [2.0.0]: https://github.com/jgraichen/gurke/compare/v1.0.1...v2.0.0
164
+ [1.0.1]: https://github.com/jgraichen/gurke/compare/v1.0.0...v1.0.1
165
+ [1.0.0]: https://github.com/jgraichen/gurke/tree/v1.0.0
data/gurke.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = 'https://github.com/jgraichen/gurke'
13
13
  spec.license = 'MIT'
14
14
 
15
- spec.summary = \
15
+ spec.summary =
16
16
  'An alternative gherkin feature runner inspired by rspec and turnip.'
17
17
 
18
18
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -28,5 +28,4 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'colorize'
30
30
  spec.add_dependency 'gherkin', '~> 2.0'
31
- spec.add_dependency 'optimist', '~> 3.0'
32
31
  end
data/lib/gurke/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optimist'
3
+ require 'optparse'
4
4
 
5
5
  module Gurke
6
6
  class CLI
@@ -10,13 +10,103 @@ module Gurke
10
10
  # @param argv [Array<String>] Tokenized argument list.
11
11
  #
12
12
  def run(argv)
13
- call parser.parse(argv), argv
14
- rescue Optimist::VersionNeeded
15
- print_version && exit
16
- rescue Optimist::HelpNeeded
17
- print_help && exit
18
- rescue Optimist::CommandlineError => e
19
- warn "Error: #{e}"
13
+ options = {
14
+ backtrace: false,
15
+ drb_server: false,
16
+ drb: false,
17
+ force_color: false,
18
+ formatter: 'default',
19
+ pattern: 'features/**/*.feature',
20
+ require: [],
21
+ tags: [],
22
+ }
23
+
24
+ OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
25
+ opts.banner = 'Usage: gurke [options] [files...]'
26
+
27
+ opts.on('-h', '--help', 'Print this help.') do
28
+ puts opts
29
+ exit
30
+ end
31
+
32
+ opts.on('-v', '--version', 'Show program version information.') do
33
+ puts "gurke v#{Gurke::VERSION}"
34
+ exit
35
+ end
36
+
37
+ opts.on('-b', '--backtrace', 'Show full error backtraces.') do
38
+ options[:backtrace] = true
39
+ end
40
+
41
+ opts.on(
42
+ '-f', '--formatter=<s>',
43
+ 'Select a special formatter as reporter (default: "default")',
44
+ ) do |arg|
45
+ options[:formatter] = arg.to_s
46
+ end
47
+
48
+ opts.on(
49
+ '-r', '--require=<s>',
50
+ 'Files matching this pattern will be required after loading ' \
51
+ 'environment but before running features. ' \
52
+ '(Default: features/steps/**/*.rb, features/support/steps/**/*.rb)',
53
+ ) do |arg|
54
+ options[:require] << arg.to_s
55
+ end
56
+
57
+ opts.on(
58
+ '-t', '--tags=<s>',
59
+ 'Only run features and scenarios matching given tag ' \
60
+ 'filtering expression. (Default: ~wip)',
61
+ ) do |arg|
62
+ options[:tags] << arg.to_s
63
+ end
64
+
65
+ opts.on(
66
+ '-p', '--pattern=<s>',
67
+ 'File pattern matching feature files to be run. (Default: features/**/*.feature)',
68
+ ) do |arg|
69
+ options[:pattern] = arg.to_s
70
+ end
71
+
72
+ opts.on('--drb', 'Run features on already started DRb server. (experimental)') do
73
+ options[:drb] = true
74
+ end
75
+
76
+ opts.on('--drb-server', 'Run features on already started DRb server. (experimental)') do
77
+ options[:drb_server] = true
78
+ end
79
+
80
+ opts.on('-c', '--color=<mode>', 'Colored output (default: "auto")') do |arg|
81
+ value = arg.to_s.downcase
82
+ if value == 'auto'
83
+ options[:color] = :auto
84
+ elsif %w[1 yes on true t force].include?(value)
85
+ options[:color] = true
86
+ elsif %w[0 no off false f].include?(value)
87
+ options[:color] = false
88
+ else
89
+ warn "Invalid value for color: #{value}"
90
+ warn 'Supported values are: 0, 1, yes, no, true, false, t, f, force, auto'
91
+ exit 255
92
+ end
93
+ end
94
+ end.parse!(argv)
95
+
96
+ if options[:require].empty?
97
+ options[:require] << 'features/steps/**/*.rb'
98
+ options[:require] << 'features/support/steps/**/*.rb'
99
+ end
100
+
101
+ if options[:tags].empty?
102
+ options[:tags] << '~wip'
103
+ end
104
+
105
+ pp options
106
+
107
+ call(options, argv)
108
+ rescue OptionParser::InvalidOption => e
109
+ warn e.message
20
110
  warn "Run with `-h' for more information on available arguments."
21
111
  exit 255
22
112
  end
@@ -45,40 +135,6 @@ module Gurke
45
135
  Kernel.exit runner.run files
46
136
  end
47
137
 
48
- def print_version
49
- $stdout.puts <<~VSTR
50
- gurke v#{Gurke::VERSION}
51
- VSTR
52
- end
53
-
54
- def print_help
55
- parser.educate($stdout)
56
- end
57
-
58
- def parser
59
- @parser ||= Optimist::Parser.new do
60
- opt :help, 'Print this help.'
61
- opt :version, 'Show program version information.'
62
- opt :backtrace, 'Show full error backtraces.'
63
- opt :formatter, 'Select a special formatter as reporter', \
64
- default: 'default'
65
- opt :pattern, 'File pattern matching feature files to be run.',
66
- default: 'features/**/*.feature'
67
- opt :require, 'Files matching this pattern will be required after' \
68
- 'loading environment but before running features.',
69
- default: ['features/steps/**/*.rb',
70
- 'features/support/steps/**/*.rb',],
71
- multi: true
72
- opt :tags, 'Only run features and scenarios matching given tag ' \
73
- 'filtering expression. TODO: Description.',
74
- default: ['~wip'],
75
- multi: true
76
- opt :drb_server, 'Run gurke DRb server. (experimental)', short: :none
77
- opt :drb, 'Run features on already started DRb server. (experimental)',
78
- short: :none
79
- end
80
- end
81
-
82
138
  private
83
139
 
84
140
  def expand_files(files, options)
data/lib/gurke/feature.rb CHANGED
@@ -65,7 +65,7 @@ module Gurke
65
65
 
66
66
  def self.new(*args)
67
67
  if args.size == 1 && (f = args.first).is_a?(self)
68
- super f.file, f.line, f.tags, f.raw
68
+ super(f.file, f.line, f.tags, f.raw)
69
69
  else
70
70
  super
71
71
  end
@@ -36,6 +36,8 @@ module Gurke
36
36
  retry_scenario
37
37
  ].freeze
38
38
 
39
+ def initialize(**kwargs); end
40
+
39
41
  # Called before the execution of any feature and before any
40
42
  # before-features hook is invoked.
41
43
  #
@@ -293,7 +295,7 @@ module Gurke
293
295
  end
294
296
  end
295
297
 
296
- if err.respond_to?(:cause) && err.cause && err.cause.respond_to?(:message)
298
+ if err.respond_to?(:cause) && err.cause.respond_to?(:message)
297
299
  s << (' ' * indent) << 'caused by: '
298
300
  s << format_exception(
299
301
  err.cause, backtrace: backtrace, indent: indent,
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+
5
+ # Colors
6
+ # :black, :red, :green, :yellow, :blue,
7
+ # :magenta, :cyan, :white, :default, :light_black,
8
+ # :light_red, :light_green, :light_yellow, :light_blue,
9
+ # :light_magenta, :light_cyan, :light_white
10
+ #
11
+ module Gurke::Reporters
12
+ module Colored
13
+ def initialize(color: nil, **kwargs)
14
+ super(**kwargs)
15
+
16
+ case color
17
+ when :auto, nil
18
+ @colored = io.tty?
19
+ when TrueClass
20
+ @colored = true
21
+ when FalseClass
22
+ @colored = false
23
+ end
24
+ end
25
+
26
+ def color?
27
+ (@color == :auto && io.tty?) || @color
28
+ end
29
+
30
+ protected
31
+
32
+ %i[black red green yellow blue
33
+ magenta cyan white default light_black
34
+ light_red light_green light_yellow light_blue
35
+ light_magenta light_cyan light_white].each do |color|
36
+ define_method(color) do |str|
37
+ @colored ? str.send(color) : str
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,20 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'colorize'
4
-
5
- # Colors
6
- # :black, :red, :green, :yellow, :blue,
7
- # :magenta, :cyan, :white, :default, :light_black,
8
- # :light_red, :light_green, :light_yellow, :light_blue,
9
- # :light_magenta, :light_cyan, :light_white
10
- #
11
3
  module Gurke::Reporters
12
4
  class CompactReporter < NullReporter
5
+ include Colored
6
+
13
7
  attr_reader :io
14
8
 
15
- def initialize(io = $stdout)
16
- super()
9
+ def initialize(io: $stdout, **kwargs)
17
10
  @io = io
11
+ super(**kwargs)
18
12
  end
19
13
 
20
14
  def after_step(result, scenario, *)
@@ -125,12 +119,5 @@ module Gurke::Reporters
125
119
 
126
120
  light_black("# #{path}:#{line}")
127
121
  end
128
-
129
- %i[black red green yellow blue
130
- magenta cyan white default light_black
131
- light_red light_green light_yellow light_blue
132
- light_magenta light_cyan light_white].each do |color|
133
- define_method(color) {|str| io.tty? ? str.send(color) : str }
134
- end
135
122
  end
136
123
  end
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Colors
4
- # :black, :red, :green, :yellow, :blue,
5
- # :magenta, :cyan, :white, :default, :light_black,
6
- # :light_red, :light_green, :light_yellow, :light_blue,
7
- # :light_magenta, :light_cyan, :light_white
8
- #
9
3
  module Gurke::Reporters
10
4
  #
11
5
  # The {DefaultReporter} prints features, scenarios and
@@ -14,11 +8,13 @@ module Gurke::Reporters
14
8
  # That includes colorized step results reports etc.
15
9
  #
16
10
  class DefaultReporter < NullReporter
11
+ include Colored
12
+
17
13
  attr_reader :io
18
14
 
19
- def initialize(io = $stdout)
20
- super()
15
+ def initialize(io: $stdout, **kwargs)
21
16
  @io = io
17
+ super(**kwargs)
22
18
  end
23
19
 
24
20
  def before_feature(feature)
@@ -155,12 +151,5 @@ module Gurke::Reporters
155
151
 
156
152
  light_black("# #{path}:#{line}")
157
153
  end
158
-
159
- %i[black red green yellow blue
160
- magenta cyan white default light_black
161
- light_red light_green light_yellow light_blue
162
- light_magenta light_cyan light_white].each do |color|
163
- define_method(color) {|str| io.tty? ? str.send(color) : str }
164
- end
165
154
  end
166
155
  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 # rubocop:disable Style/DocumentDynamicEvalDefinition
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
@@ -16,7 +16,7 @@ module Gurke
16
16
  .map(&:capitalize)
17
17
  .join
18
18
 
19
- Reporters.const_get(r).new
19
+ Reporters.const_get(r).new(color: options[:color])
20
20
  end
21
21
  end
22
22
 
@@ -200,16 +200,7 @@ module Gurke
200
200
  end
201
201
 
202
202
  def world
203
- @world ||= begin
204
- cls = Class.new
205
- cls.send :include, Gurke.world
206
-
207
- Gurke.config.inclusions.each do |incl|
208
- cls.send :include, incl.mod if incl.match?(tag_names)
209
- end
210
- cls.send :include, Gurke::Steps
211
- cls.new
212
- end
203
+ @world ||= Gurke::World.create(tag_names: tag_names)
213
204
  end
214
205
  end
215
206
  end
data/lib/gurke/step.rb CHANGED
@@ -46,19 +46,18 @@ module Gurke
46
46
  def run(runner, reporter, scenario, world)
47
47
  reporter.invoke :before_step, self, scenario
48
48
 
49
- result = runner.hook(:step, self, world) do
50
- run_step runner, reporter, scenario, world
49
+ run_step(runner, reporter, scenario, world).tap do |result|
50
+ reporter.invoke :after_step, result, scenario
51
51
  end
52
-
53
- reporter.invoke :after_step, result, scenario
54
52
  end
55
53
 
56
54
  private
57
55
 
58
56
  def run_step(runner, reporter, scenario, world)
59
- reporter.invoke :start_step, self, scenario
60
-
61
- result = find_and_run_step runner, scenario, world
57
+ result = runner.hook(:step, self, world) do
58
+ reporter.invoke :start_step, self, scenario
59
+ find_and_run_step runner, scenario, world
60
+ end
62
61
  rescue Interrupt
63
62
  scenario.abort!
64
63
  result = StepResult.new self, scenario, :aborted
data/lib/gurke/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Gurke
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 3
7
- PATCH = 5
6
+ MINOR = 5
7
+ PATCH = 0
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.').freeze
10
10
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gurke
4
+ module World
5
+ class << self
6
+ def create(tag_names: [])
7
+ Class.new.tap do |cls|
8
+ cls.send :include, Gurke.world
9
+
10
+ Gurke.config.inclusions.each do |incl|
11
+ cls.send :include, incl.mod if incl.match?(tag_names)
12
+ end
13
+
14
+ cls.send :include, Gurke::Steps
15
+ end.new
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/gurke.rb CHANGED
@@ -20,8 +20,11 @@ module Gurke
20
20
  require 'gurke/steps'
21
21
  require 'gurke/step_definition'
22
22
  require 'gurke/reporter'
23
+ require 'gurke/world'
23
24
 
24
25
  module Reporters
26
+ require 'gurke/reporters/colored'
27
+
25
28
  require 'gurke/reporters/null_reporter'
26
29
  require 'gurke/reporters/compact_reporter'
27
30
  require 'gurke/reporters/default_reporter'
@@ -61,7 +64,7 @@ module Gurke
61
64
 
62
65
  # @api private
63
66
  def world
64
- @world ||= const_set(:World, Module.new)
67
+ @world ||= World
65
68
  end
66
69
  end
67
70
  end
@@ -6,7 +6,7 @@ require 'spec_helper'
6
6
 
7
7
  RSpec.describe Gurke::Reporters::CompactReporter do
8
8
  subject(:out) do
9
- reporter = described_class.new(StringIO.new)
9
+ reporter = described_class.new(io: StringIO.new)
10
10
  reporter.send(*action)
11
11
  reporter.io.string
12
12
  end
@@ -6,11 +6,13 @@ require 'spec_helper'
6
6
 
7
7
  RSpec.describe Gurke::Reporters::DefaultReporter do
8
8
  subject(:out) do
9
- reporter = described_class.new(StringIO.new)
9
+ reporter = described_class.new(io: StringIO.new, color: color)
10
10
  reporter.send(*action)
11
11
  reporter.io.string
12
12
  end
13
13
 
14
+ let(:color) { nil }
15
+
14
16
  let(:feature) { instance_double(Gurke::Feature) }
15
17
  let(:scenario) { instance_double(Gurke::Scenario) }
16
18
  let(:step) { instance_double(Gurke::Step) }
@@ -37,6 +39,21 @@ RSpec.describe Gurke::Reporters::DefaultReporter do
37
39
  .
38
40
  TEXT
39
41
  end
42
+
43
+ context 'with colors' do
44
+ let(:color) { true }
45
+
46
+ it 'outputs ASCII color codes' do
47
+ expect(out).to eq unindent <<~TEXT
48
+ \e[0;33;49mFeature\e[0m: Demo feature \e[0;90;49m# features/file.feature:1\e[0m
49
+ \e[0;90;49m As a developer
50
+ I would like have this spec passed
51
+ In order to work on\e[0m
52
+ .
53
+ .
54
+ TEXT
55
+ end
56
+ end
40
57
  end
41
58
 
42
59
  describe '#start_background' do
@@ -6,7 +6,7 @@ require 'spec_helper'
6
6
 
7
7
  RSpec.describe Gurke::Reporters::TeamCityReporter do
8
8
  subject(:statements) do
9
- reporter = described_class.new(StringIO.new)
9
+ reporter = described_class.new(io: StringIO.new)
10
10
  reporter.send(*action)
11
11
  reporter.io.string.scan(/##teamcity\[.*\]/)
12
12
  end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Gurke::Step do
6
+ let(:step) do
7
+ described_class.new('./fake.feature', 1337, :when, raw)
8
+ end
9
+
10
+ let(:reporter) { instance_double Gurke::Reporters::NullReporter }
11
+ let(:runner) { instance_double Gurke::Runner }
12
+ let(:scenario) { instance_double Gurke::Scenario }
13
+ let(:raw) { instance_double Gherkin::Formatter::Model::Step }
14
+ let(:world) { Gurke::World.create }
15
+
16
+ before do
17
+ world.class.When 'I run something' do
18
+ true
19
+ end
20
+
21
+ allow(raw).to receive(:name).and_return('I run something')
22
+ allow(reporter).to receive(:invoke)
23
+ allow(runner).to receive(:hook) {|_, _, &block| block.call }
24
+ allow(runner).to receive(:with_filtered_backtrace) {|*, &block| block.call }
25
+ allow(scenario).to receive_messages(pending?: false, failed?: false, aborted?: false)
26
+ end
27
+
28
+ describe '#run' do
29
+ subject(:result) { step.run(runner, reporter, scenario, world) }
30
+
31
+ it 'passes the step' do
32
+ expect(result).to be_passed
33
+ end
34
+
35
+ context 'with exception in after step hook' do
36
+ before do
37
+ allow(scenario).to receive(:failed!)
38
+
39
+ allow(runner).to receive(:hook) do |_, _, &block|
40
+ block.call
41
+ raise exception
42
+ end
43
+ end
44
+
45
+ let(:exception) { RuntimeError.new('faily') }
46
+
47
+ it 'fails the step' do
48
+ expect(result).to be_failed
49
+ expect(scenario).to have_received(:failed!)
50
+ .with(exception)
51
+ end
52
+ end
53
+
54
+ context 'with exception in before step hook' do
55
+ before do
56
+ allow(scenario).to receive(:failed!)
57
+
58
+ allow(runner).to receive(:hook) do
59
+ raise exception
60
+ end
61
+ end
62
+
63
+ let(:exception) { RuntimeError.new('faily') }
64
+
65
+ it 'fails the step' do
66
+ expect(result).to be_failed
67
+ expect(scenario).to have_received(:failed!)
68
+ .with(exception)
69
+ end
70
+ end
71
+ end
72
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  require 'rspec'
4
4
  require 'simplecov'
5
- SimpleCov.start
5
+ require 'simplecov-cobertura'
6
6
 
7
- if ENV['CI']
8
- require 'codecov'
9
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
- end
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ SimpleCov::Formatter::CoberturaFormatter,
10
+ ])
11
+ SimpleCov.start
11
12
 
12
13
  require 'gurke'
13
14
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gurke
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.5
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-10-28 00:00:00.000000000 Z
10
+ date: 2025-04-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: colorize
@@ -38,21 +37,6 @@ dependencies:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: optimist
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- description:
56
40
  email:
57
41
  - jgraichen@altimos.de
58
42
  executables:
@@ -90,6 +74,7 @@ files:
90
74
  - lib/gurke/feature.rb
91
75
  - lib/gurke/feature_list.rb
92
76
  - lib/gurke/reporter.rb
77
+ - lib/gurke/reporters/colored.rb
93
78
  - lib/gurke/reporters/compact_reporter.rb
94
79
  - lib/gurke/reporters/default_reporter.rb
95
80
  - lib/gurke/reporters/null_reporter.rb
@@ -103,6 +88,7 @@ files:
103
88
  - lib/gurke/steps.rb
104
89
  - lib/gurke/tag.rb
105
90
  - lib/gurke/version.rb
91
+ - lib/gurke/world.rb
106
92
  - spec/gurke/feature_list_spec.rb
107
93
  - spec/gurke/reporters/compact_reporter_spec.rb
108
94
  - spec/gurke/reporters/default_reporter_spec.rb
@@ -110,13 +96,13 @@ files:
110
96
  - spec/gurke/run_list_spec.rb
111
97
  - spec/gurke/scenario_spec.rb
112
98
  - spec/gurke/step_definition_spec.rb
99
+ - spec/gurke/step_spec.rb
113
100
  - spec/spec_helper.rb
114
101
  homepage: https://github.com/jgraichen/gurke
115
102
  licenses:
116
103
  - MIT
117
104
  metadata:
118
105
  rubygems_mfa_required: 'true'
119
- post_install_message:
120
106
  rdoc_options: []
121
107
  require_paths:
122
108
  - lib
@@ -131,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
117
  - !ruby/object:Gem::Version
132
118
  version: '0'
133
119
  requirements: []
134
- rubygems_version: 3.4.21
135
- signing_key:
120
+ rubygems_version: 3.6.2
136
121
  specification_version: 4
137
122
  summary: An alternative gherkin feature runner inspired by rspec and turnip.
138
123
  test_files: []