gurke 2.4.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -0
  3. data/bin/gurke +2 -0
  4. data/features/gurke.feature +2 -5
  5. data/features/gurke.rb +2 -1
  6. data/features/gurke/backtrace_filtering.feature +3 -4
  7. data/features/gurke/context_in_hooks.feature +1 -2
  8. data/features/gurke/filter_by_tags.feature +5 -6
  9. data/features/gurke/include_by_tags.feature +1 -2
  10. data/features/gurke/other_reporter.feature +3 -4
  11. data/features/gurke/pending_steps.feature +1 -4
  12. data/features/gurke/run_specific_directories.feature +4 -5
  13. data/features/gurke/run_specific_scenarios.feature +5 -6
  14. data/features/gurke/step_specific_definitions.feature +1 -4
  15. data/features/support/steps/cli_steps.rb +17 -8
  16. data/features/support/steps/file_steps.rb +2 -9
  17. data/gurke.gemspec +10 -9
  18. data/lib/gurke.rb +3 -0
  19. data/lib/gurke/background.rb +2 -0
  20. data/lib/gurke/builder.rb +10 -11
  21. data/lib/gurke/capybara.rb +2 -0
  22. data/lib/gurke/cli.rb +35 -27
  23. data/lib/gurke/configuration.rb +9 -6
  24. data/lib/gurke/dsl.rb +9 -5
  25. data/lib/gurke/feature.rb +6 -8
  26. data/lib/gurke/feature_list.rb +11 -7
  27. data/lib/gurke/reporter.rb +41 -34
  28. data/lib/gurke/reporters/compact_reporter.rb +137 -0
  29. data/lib/gurke/reporters/default_reporter.rb +57 -16
  30. data/lib/gurke/reporters/null_reporter.rb +4 -2
  31. data/lib/gurke/reporters/team_city_reporter.rb +11 -13
  32. data/lib/gurke/rspec.rb +2 -0
  33. data/lib/gurke/run_list.rb +2 -0
  34. data/lib/gurke/runner.rb +12 -6
  35. data/lib/gurke/scenario.rb +41 -2
  36. data/lib/gurke/step.rb +24 -14
  37. data/lib/gurke/step_definition.rb +3 -1
  38. data/lib/gurke/steps.rb +3 -1
  39. data/lib/gurke/tag.rb +5 -1
  40. data/lib/gurke/version.rb +5 -3
  41. data/spec/gurke/feature_list_spec.rb +4 -2
  42. data/spec/gurke/reporters/default_reporter_spec.rb +201 -0
  43. data/spec/gurke/run_list_spec.rb +2 -0
  44. data/spec/gurke/scenario_spec.rb +5 -3
  45. data/spec/gurke/step_definition_spec.rb +3 -1
  46. data/spec/spec_helper.rb +10 -1
  47. metadata +8 -6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gurke
2
4
  class Step
3
5
  #
@@ -20,21 +22,23 @@ module Gurke
20
22
 
21
23
  # @api private
22
24
  def initialize(file, line, type, raw)
23
- @file, @line = file, line
24
- @type, @raw = type, raw
25
+ @file = file
26
+ @line = line
27
+ @type = type
28
+ @raw = raw
25
29
  end
26
30
 
27
31
  def name
28
32
  raw.name
29
33
  end
30
- alias_method :to_s, :name
34
+ alias to_s name
31
35
 
32
36
  def keyword
33
- raw.keyword
37
+ raw.keyword.strip
34
38
  end
35
39
 
36
40
  def doc_string
37
- raw.doc_string.value if raw.doc_string
41
+ raw.doc_string&.value
38
42
  end
39
43
 
40
44
  # @api private
@@ -55,10 +59,14 @@ module Gurke
55
59
  reporter.invoke :start_step, self, scenario
56
60
 
57
61
  result = find_and_run_step runner, scenario, world
62
+ rescue Interrupt
63
+ scenario.abort!
64
+ result = StepResult.new self, :aborted
65
+ raise
58
66
  rescue StepPending => e
59
67
  scenario.pending! e
60
68
  result = StepResult.new self, :pending, e
61
- rescue Exception => e
69
+ rescue Exception => e # rubocop:disable RescueException
62
70
  scenario.failed! e
63
71
  result = StepResult.new self, :failed, e
64
72
  ensure
@@ -69,14 +77,14 @@ module Gurke
69
77
  runner.with_filtered_backtrace do
70
78
  match = Steps.find_step self, world, type
71
79
 
72
- if scenario.pending? || scenario.failed?
80
+ if scenario.pending? || scenario.failed? || scenario.aborted?
73
81
  return StepResult.new self, :skipped
74
82
  end
75
83
 
76
84
  m = world.method match.method_name
77
85
  world.send match.method_name, *(match.params + [self])[0...m.arity]
78
86
 
79
- StepResult.new self, :success
87
+ StepResult.new self, :passed
80
88
  end
81
89
  end
82
90
 
@@ -85,13 +93,15 @@ module Gurke
85
93
  attr_reader :step, :exception, :state
86
94
 
87
95
  def initialize(step, state, err = nil)
88
- @step, @state, @exception = step, state, err
96
+ @step = step
97
+ @state = state
98
+ @exception = err
89
99
  end
90
100
 
91
101
  Step.public_instance_methods(false).each do |mth|
92
- class_eval <<-EOS, __FILE__, __LINE__
93
- def #{mth}(*args) @step.send #{mth}, *args; end
94
- EOS
102
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
103
+ def #{mth}(*args) @step.send(:#{mth}, *args); end
104
+ RUBY
95
105
  end
96
106
 
97
107
  def failed?
@@ -106,8 +116,8 @@ module Gurke
106
116
  @state == :skipped
107
117
  end
108
118
 
109
- def success?
110
- @state == :success
119
+ def passed?
120
+ @state == :passed
111
121
  end
112
122
  end
113
123
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gurke
2
4
  class StepDefinition
3
- attr_reader :pattern, :method_name, :opts
5
+ attr_reader :pattern, :opts
4
6
 
5
7
  def initialize(pattern, opts = {})
6
8
  @pattern = pattern
@@ -1,7 +1,8 @@
1
- # rubocop:disable MethodName
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Gurke
4
4
  module Steps
5
+ # rubocop:disable MethodName
5
6
  def Given(step)
6
7
  rst = self.class.find_step(step, self, :given)
7
8
  send rst.method_name
@@ -16,6 +17,7 @@ module Gurke
16
17
  rst = self.class.find_step(step, self, :then)
17
18
  send rst.method_name
18
19
  end
20
+ # rubocop:enable MethodName
19
21
 
20
22
  class << self
21
23
  def find_step(step, world, type)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gurke
2
4
  class Tag
3
5
  #
@@ -18,7 +20,9 @@ module Gurke
18
20
 
19
21
  # @api private
20
22
  def initialize(file, line, raw)
21
- @file, @line, @raw = file, line, raw
23
+ @file = file
24
+ @line = line
25
+ @raw = raw
22
26
  end
23
27
 
24
28
  def name
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gurke
2
4
  module VERSION
3
- MAJOR = 2
4
- MINOR = 4
5
- PATCH = 2
5
+ MAJOR = 3
6
+ MINOR = 0
7
+ PATCH = 0
6
8
  STAGE = nil
7
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
8
10
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Gurke::FeatureList do
@@ -42,8 +44,8 @@ describe Gurke::FeatureList do
42
44
 
43
45
  subject
44
46
 
45
- expect(@scopes).to eq [:before_features, :start_features,
46
- :end_features, :after_features]
47
+ expect(@scopes).to eq %i[before_features start_features
48
+ end_features after_features]
47
49
  end
48
50
  end
49
51
  end
@@ -0,0 +1,201 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable MissingCopEnableDirective
4
+ # rubocop:disable Style/Semicolon
5
+
6
+ require 'spec_helper'
7
+
8
+ RSpec.describe Gurke::Reporters::DefaultReporter do
9
+ let(:output) { StringIO.new }
10
+ let(:reporter) { described_class.new(output) }
11
+ subject { output.string }
12
+
13
+ describe '#before_feature' do
14
+ let(:feature) { double('feature') }
15
+
16
+ before do
17
+ expect(feature).to receive(:name).and_return 'Demo feature'
18
+ expect(feature).to receive(:file).and_return \
19
+ File.join(Dir.getwd, 'features', 'file.feature')
20
+ expect(feature).to receive(:line).and_return 1
21
+ expect(feature).to receive(:description).and_return \
22
+ "As a developer\nI would like have this spec passed\nIn order to work on"
23
+ end
24
+
25
+ subject { reporter.before_feature(feature); super() }
26
+
27
+ it do
28
+ is_expected.to eq unindent <<~TEXT
29
+ Feature: Demo feature # features/file.feature:1
30
+ As a developer
31
+ I would like have this spec passed
32
+ In order to work on
33
+ .
34
+ .
35
+ TEXT
36
+ end
37
+ end
38
+
39
+ describe '#start_background' do
40
+ let(:feature) { double('feature') }
41
+
42
+ subject { reporter.start_background(feature); super() }
43
+
44
+ it do
45
+ is_expected.to eq unindent <<~TEXT
46
+ . Background:
47
+ .
48
+ TEXT
49
+ end
50
+ end
51
+
52
+ describe '#before_scenario' do
53
+ let(:scenario) { double('scenario') }
54
+
55
+ before do
56
+ expect(scenario).to receive(:name).and_return 'Running the scenario'
57
+ expect(scenario).to receive(:file).and_return \
58
+ File.join(Dir.getwd, 'features', 'file.feature')
59
+ expect(scenario).to receive(:line).and_return 5
60
+ end
61
+
62
+ subject { reporter.before_scenario(scenario); super() }
63
+
64
+ it do
65
+ is_expected.to eq unindent <<~TEXT
66
+ . Scenario: Running the scenario # features/file.feature:5
67
+ .
68
+ TEXT
69
+ end
70
+ end
71
+
72
+ describe '#before_step' do
73
+ let(:step) { double('step') }
74
+
75
+ before do
76
+ expect(step).to receive(:name).and_return 'the scenario is passing'
77
+ expect(step).to receive(:keyword).and_return 'Given'
78
+ end
79
+
80
+ subject { reporter.before_step(step); super() }
81
+
82
+ it do
83
+ is_expected.to eq unindent <<~TEXT
84
+ . Given the scenario is passing
85
+ TEXT
86
+ end
87
+ end
88
+
89
+ describe '#after_step' do
90
+ let(:step) { double('step') }
91
+
92
+ before do
93
+ expect(step).to receive(:state).and_return state
94
+ end
95
+
96
+ subject { reporter.after_step(step); super() }
97
+
98
+ context 'with step passing' do
99
+ let(:state) { :passed }
100
+
101
+ it do
102
+ is_expected.to eq unindent <<~TEXT
103
+ . (passed)
104
+ .
105
+ TEXT
106
+ end
107
+ end
108
+
109
+ context 'with step pending' do
110
+ let(:state) { :pending }
111
+
112
+ it do
113
+ is_expected.to eq unindent <<~TEXT
114
+ . (pending)
115
+ .
116
+ TEXT
117
+ end
118
+ end
119
+
120
+ context 'with step failing' do
121
+ let(:state) { :failed }
122
+
123
+ before do
124
+ e = double 'exception'
125
+ c = double 'exception'
126
+
127
+ allow(e).to receive(:class).and_return(RuntimeError)
128
+ allow(e).to receive(:message).and_return('An error occurred')
129
+ allow(e).to receive(:backtrace).and_return([
130
+ '/path/to/file.rb:5:in `block (4 levels) in <top (required)>\'',
131
+ '/path/to/file.rb:24:in in `fail_with\''
132
+ ])
133
+
134
+ allow(e).to receive(:cause).and_return(c)
135
+
136
+ allow(c).to receive(:class).and_return(IOError)
137
+ allow(c).to receive(:message).and_return('Socket closed')
138
+ allow(c).to receive(:backtrace).and_return([
139
+ 'script.rb:5:in `a\'',
140
+ 'script.rb:10:in `b\''
141
+ ])
142
+
143
+ expect(step).to receive(:exception).and_return e
144
+ end
145
+
146
+ it do
147
+ is_expected.to eq unindent <<~TEXT
148
+ . (failure)
149
+ . RuntimeError: An error occurred
150
+ . /path/to/file.rb:5:in `block (4 levels) in <top (required)>'
151
+ . /path/to/file.rb:24:in in `fail_with'
152
+ . caused by: IOError: Socket closed
153
+ . script.rb:5:in `a'
154
+ . script.rb:10:in `b'
155
+ .
156
+ .
157
+ TEXT
158
+ end
159
+ end
160
+ end
161
+
162
+ describe '#after_scenario' do
163
+ let(:scenario) { double('scenario') }
164
+
165
+ subject { reporter.after_scenario(scenario); super() }
166
+
167
+ it do
168
+ is_expected.to eq unindent <<~TEXT
169
+ .
170
+ .
171
+ TEXT
172
+ end
173
+ end
174
+
175
+ describe '#after_feature' do
176
+ let(:feature) { double('feature') }
177
+
178
+ subject { reporter.after_feature(feature); super() }
179
+
180
+ it do
181
+ is_expected.to eq unindent <<~TEXT
182
+ .
183
+ .
184
+ TEXT
185
+ end
186
+ end
187
+
188
+ describe '#after_features' do
189
+ let(:features) { [] }
190
+
191
+ subject { reporter.after_features(features); super() }
192
+
193
+ it do
194
+ is_expected.to eq unindent <<~TEXT
195
+ .0 scenarios: 0 failing, 0 pending
196
+ .
197
+ .
198
+ TEXT
199
+ end
200
+ end
201
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Gurke::RunList do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Gurke::Scenario do
@@ -7,7 +9,7 @@ describe Gurke::Scenario do
7
9
  let(:backgrounds) { double('backgrounds') }
8
10
 
9
11
  before do
10
- allow(feature).to receive(:backgrounds).ordered.and_return(backgrounds)
12
+ allow(feature).to receive(:backgrounds).and_return(backgrounds)
11
13
  allow(backgrounds).to receive(:run)
12
14
  allow(runner).to receive(:hook) {|_, _, &block| block.call }
13
15
  end
@@ -44,8 +46,8 @@ describe Gurke::Scenario do
44
46
 
45
47
  subject
46
48
 
47
- expect(@scopes).to eq [:before_scenario, :start_scenario,
48
- :end_scenario, :after_scenario]
49
+ expect(@scopes).to eq %i[before_scenario start_scenario
50
+ end_scenario after_scenario]
49
51
  end
50
52
  end
51
53
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'spec_helper'
4
6
 
5
7
  describe Gurke::StepDefinition do
6
- let(:pattern) { nil }
8
+ let(:pattern) { nil }
7
9
  let(:step_definition) { described_class.new pattern }
8
10
  subject { step_definition }
9
11
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
2
4
  require 'coveralls'
3
5
  Coveralls.wear! do
@@ -10,8 +12,15 @@ Bundler.require
10
12
 
11
13
  require 'gurke'
12
14
 
13
- Dir[File.expand_path('spec/support/**/*.rb')].each{|f| require f }
15
+ Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
16
+
17
+ module Helper
18
+ def unindent(str)
19
+ str.rstrip.gsub(/^\./, '')
20
+ end
21
+ end
14
22
 
15
23
  RSpec.configure do |config|
16
24
  config.order = 'random'
25
+ config.include Helper
17
26
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gurke
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 3.0.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: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: trollop
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: colorize
42
+ name: trollop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -102,6 +102,7 @@ files:
102
102
  - lib/gurke/feature.rb
103
103
  - lib/gurke/feature_list.rb
104
104
  - lib/gurke/reporter.rb
105
+ - lib/gurke/reporters/compact_reporter.rb
105
106
  - lib/gurke/reporters/default_reporter.rb
106
107
  - lib/gurke/reporters/null_reporter.rb
107
108
  - lib/gurke/reporters/team_city_reporter.rb
@@ -115,6 +116,7 @@ files:
115
116
  - lib/gurke/tag.rb
116
117
  - lib/gurke/version.rb
117
118
  - spec/gurke/feature_list_spec.rb
119
+ - spec/gurke/reporters/default_reporter_spec.rb
118
120
  - spec/gurke/run_list_spec.rb
119
121
  - spec/gurke/scenario_spec.rb
120
122
  - spec/gurke/step_definition_spec.rb
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
141
  version: '0'
140
142
  requirements: []
141
143
  rubyforge_project:
142
- rubygems_version: 2.2.5
144
+ rubygems_version: 2.7.3
143
145
  signing_key:
144
146
  specification_version: 4
145
147
  summary: An alternative gherkin feature runner inspired by rspec and turnip.
@@ -158,8 +160,8 @@ test_files:
158
160
  - features/support/steps/cli_steps.rb
159
161
  - features/support/steps/file_steps.rb
160
162
  - spec/gurke/feature_list_spec.rb
163
+ - spec/gurke/reporters/default_reporter_spec.rb
161
164
  - spec/gurke/run_list_spec.rb
162
165
  - spec/gurke/scenario_spec.rb
163
166
  - spec/gurke/step_definition_spec.rb
164
167
  - spec/spec_helper.rb
165
- has_rdoc: