gurke 3.3.1 → 3.3.2

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
  SHA256:
3
- metadata.gz: 19dece7b4b59ad3477927b3e8fe8a999d16dd38c76eaf47da0884364a0cf6304
4
- data.tar.gz: 6fd2ad924d46cfb1be7df5d8e8d7aab48d135954168833253155cde3178e56d7
3
+ metadata.gz: 0397cd73d54c76350b72961da6af3a7735b4bfc134e2c4ec85d1aa0698d83fef
4
+ data.tar.gz: ba610c4ef198dc90e5962386a410fc886ec8eebad749dfba177ca0011da61308
5
5
  SHA512:
6
- metadata.gz: 8fe0d861f4689b7b9dfd04f98c5237193e1adfe5d131b43d3db92ba401f300e008d5c1c225ca1cc5c1858da9f1a774ba6246d5cf583727c9b0360f5316aa579e
7
- data.tar.gz: 8883a08e2d30485bf1a765bc5bb9101aebc39d37155b9bc98c3c20bed9891b1815e0f2699b61effe1a48ba73233ca91db05807e01730970bc4b8d9f0f92a897b
6
+ metadata.gz: f62c44c16c881ed3ceac307cf380fd1c7a07a92f0cd499a016d494acb7cc1e0939641f9a6e3153b6d553f2fc409ed22a4ae24d889e195123e76cdae06fce0791
7
+ data.tar.gz: e476dc728f92ebd45dcb594a9a7a60914b580c4e4c346533bfa1d6640724dc645791e3bd985760d7e286ae00f309238fc4235d2e44e2286e0a8f1bd95180d130
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.2
4
+
5
+ * Fix teamcity and compact reporter
6
+
3
7
  ## 3.3.1
4
8
 
5
9
  * Add option for default retry of failed scenarios
@@ -275,28 +275,30 @@ module Gurke
275
275
 
276
276
  protected
277
277
 
278
- def format_exception(ex, backtrace: true)
279
- s = ex.class.to_s << ': ' << ex.message.strip << "\n"
278
+ def format_exception(ex, backtrace: true, indent: 0)
279
+ s = StringIO.new
280
+ s << (' ' * indent) << ex.class.to_s << ': ' << ex.message.strip << "\n"
280
281
 
281
- if backtrace
282
+ if backtrace && ex.respond_to?(:backtrace)
282
283
  if ex.backtrace.nil?
283
- s << ' <no backtrace available>'
284
+ s << (' ' * indent) << ' <no backtrace available>'
284
285
  elsif ex.backtrace.empty?
285
- s << ' <backtrace empty>'
286
+ s << (' ' * indent) << ' <backtrace empty>'
286
287
  else
287
288
  ex.backtrace.each do |bt|
288
- s << ' ' << bt.strip << "\n"
289
+ s << (' ' * indent) << ' ' << bt.strip << "\n"
289
290
  end
290
291
  end
291
292
  end
292
293
 
293
- if ex.respond_to?(:cause) && ex.cause &&
294
- ex.cause.respond_to?(:message) && ex.cause.respond_to?(:backtrace)
295
-
296
- s << 'caused by: ' << format_exception(ex.cause, backtrace: backtrace)
294
+ if ex.respond_to?(:cause) && ex.cause && ex.cause.respond_to?(:message)
295
+ s << (' ' * indent) << 'caused by: '
296
+ s << format_exception(
297
+ ex.cause, backtrace: backtrace, indent: indent
298
+ ).strip
297
299
  end
298
300
 
299
- s
301
+ s.string
300
302
  end
301
303
  end
302
304
  end
@@ -71,8 +71,8 @@ module Gurke::Reporters
71
71
  end
72
72
  end
73
73
 
74
- exout = format_exception(result.exception, backtrace: true)
75
- io.puts red exout.join("\n").gsub(/^/, ' ')
74
+ exout = format_exception(result.exception, backtrace: true, indent: 6)
75
+ io.puts red exout
76
76
  io.puts
77
77
  end
78
78
 
@@ -13,21 +13,27 @@ module Gurke::Reporters
13
13
  end
14
14
 
15
15
  def before_scenario(scenario)
16
- @status_reported = false
17
- @retry = false
18
-
19
16
  publish :testStarted, name: scenario.name
20
17
 
21
18
  super
22
19
  end
23
20
 
24
- def retry_scenario(scenario)
25
- @retry = true
26
-
27
- super
28
- end
29
-
30
21
  def after_scenario(scenario)
22
+ if scenario.failed?
23
+ publish :testFailed,
24
+ name: scenario.name,
25
+ message: scenario.exception.inspect,
26
+ backtrace: scenario.exception.backtrace.join('\n')
27
+ elsif scenario.pending?
28
+ publish :testIgnored,
29
+ name: scenario.name,
30
+ message: 'Step definition missing'
31
+ else
32
+ publish :testIgnored,
33
+ name: scenario.name,
34
+ message: 'Aborted.'
35
+ end
36
+
31
37
  publish :testFinished, name: scenario.name
32
38
 
33
39
  super
@@ -39,46 +45,8 @@ module Gurke::Reporters
39
45
  super
40
46
  end
41
47
 
42
- protected
43
-
44
- def step_pending(step, *)
45
- super
46
-
47
- report :testIgnored,
48
- name: step.scenario.name,
49
- message: 'Step definition missing'
50
- end
51
-
52
- def step_failed(step, *args)
53
- super(step, *args, exception: false)
54
-
55
- unless step.scenario.retryable? && !retry?
56
- # do not report test as failed if it will be retries
57
- report :testFailed,
58
- name: step.scenario.name,
59
- message: step.exception.inspect,
60
- backtrace: step.exception.backtrace.join('\n')
61
- end
62
-
63
- print_exception(step.exception)
64
- end
65
-
66
48
  private
67
49
 
68
- def status_reported?
69
- @status_reported
70
- end
71
-
72
- def retry?
73
- @retry
74
- end
75
-
76
- def report(*args)
77
- return if status_reported?
78
-
79
- publish(*args)
80
- end
81
-
82
50
  def publish(message_name, args)
83
51
  args = [] << message_name.to_s << escaped_array_of(args)
84
52
  args = args.flatten.reject(&:nil?)
@@ -4,7 +4,7 @@ module Gurke
4
4
  module VERSION
5
5
  MAJOR = 3
6
6
  MINOR = 3
7
- PATCH = 1
7
+ PATCH = 2
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
10
10
 
@@ -0,0 +1,215 @@
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::CompactReporter 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
+ subject { reporter.before_feature(feature); super() }
17
+
18
+ it { is_expected.to eq '' }
19
+ end
20
+
21
+ describe '#start_background' do
22
+ let(:feature) { double('feature') }
23
+
24
+ subject { reporter.start_background(feature); super() }
25
+
26
+ it { is_expected.to eq '' }
27
+ end
28
+
29
+ describe '#before_scenario' do
30
+ let(:scenario) { double('scenario') }
31
+
32
+ subject { reporter.before_scenario(scenario); super() }
33
+
34
+ it { is_expected.to eq '' }
35
+ end
36
+
37
+ describe '#before_step' do
38
+ let(:step) { double('step') }
39
+
40
+ subject { reporter.before_step(step); super() }
41
+
42
+ it { is_expected.to eq '' }
43
+ end
44
+
45
+ describe '#after_step' do
46
+ let(:feature) { double('feature') }
47
+ let(:scenario) { double('scenario') }
48
+ let(:step) { double('step') }
49
+ let(:result) { double('result') }
50
+ let(:backgrounds) { [] }
51
+ let(:exception) { nil }
52
+
53
+ let(:steps) do
54
+ [step]
55
+ end
56
+
57
+ before do
58
+ allow(result).to receive(:step).and_return(step)
59
+ allow(result).to receive(:scenario).and_return(scenario)
60
+ allow(result).to receive(:state).and_return(state)
61
+ allow(result).to receive(:exception).and_return(exception)
62
+ end
63
+
64
+ before do
65
+ allow(step).to receive(:name).and_return 'the scenario is passing'
66
+ allow(step).to receive(:keyword).and_return 'Given'
67
+ end
68
+
69
+ before do
70
+ allow(scenario).to receive(:feature).and_return(feature)
71
+ allow(scenario).to receive(:steps).and_return(steps)
72
+
73
+ allow(scenario).to receive(:name).and_return 'Running the scenario'
74
+ allow(scenario).to receive(:file).and_return \
75
+ File.join(Dir.getwd, 'features', 'file.feature')
76
+ allow(scenario).to receive(:line).and_return 5
77
+ end
78
+
79
+ before do
80
+ allow(feature).to receive(:backgrounds).and_return(backgrounds)
81
+
82
+ allow(feature).to receive(:name).and_return 'Demo feature'
83
+ allow(feature).to receive(:file).and_return \
84
+ File.join(Dir.getwd, 'features', 'file.feature')
85
+ allow(feature).to receive(:line).and_return 1
86
+ allow(feature).to receive(:description).and_return \
87
+ "As a developer\nI would like have this spec passed\nIn order to work on"
88
+ end
89
+
90
+ subject { reporter.after_step(result, scenario); super() }
91
+
92
+ context 'with step passing' do
93
+ let(:state) { :passed }
94
+
95
+ it { is_expected.to eq '' }
96
+ end
97
+
98
+ context 'with step pending' do
99
+ let(:state) { :pending }
100
+
101
+ it { is_expected.to eq '' }
102
+ end
103
+
104
+ context 'with step pending' do
105
+ let(:state) { nil }
106
+
107
+ it { is_expected.to eq '' }
108
+ end
109
+
110
+ context 'with step failing' do
111
+ let(:state) { :failed }
112
+
113
+ before do
114
+ e = double 'exception'
115
+ c = double 'exception'
116
+
117
+ allow(e).to receive(:class).and_return(RuntimeError)
118
+ allow(e).to receive(:message).and_return('An error occurred')
119
+ allow(e).to receive(:backtrace).and_return([
120
+ '/path/to/file.rb:5:in `block (4 levels) in <top (required)>\'',
121
+ '/path/to/file.rb:24:in in `fail_with\''
122
+ ])
123
+
124
+ allow(e).to receive(:cause).and_return(c)
125
+
126
+ allow(c).to receive(:class).and_return(IOError)
127
+ allow(c).to receive(:message).and_return('Socket closed')
128
+ allow(c).to receive(:backtrace).and_return([
129
+ 'script.rb:5:in `a\'',
130
+ 'script.rb:10:in `b\''
131
+ ])
132
+
133
+ expect(result).to receive(:exception).and_return e
134
+ end
135
+
136
+ it do
137
+ is_expected.to eq unindent <<~TEXT
138
+ .E
139
+ .Feature: Demo feature # features/file.feature:1
140
+ . Scenario: Running the scenario # features/file.feature:5
141
+ . Given the scenario is passing
142
+ . RuntimeError: An error occurred
143
+ . /path/to/file.rb:5:in `block (4 levels) in <top (required)>'
144
+ . /path/to/file.rb:24:in in `fail_with'
145
+ . caused by: IOError: Socket closed
146
+ . script.rb:5:in `a'
147
+ . script.rb:10:in `b'
148
+ .
149
+ .
150
+ TEXT
151
+ end
152
+ end
153
+ end
154
+
155
+ describe '#retry_scenario' do
156
+ let(:scenario) { double('scenario') }
157
+
158
+ subject { reporter.retry_scenario(scenario); super() }
159
+
160
+ it { is_expected.to eq '' }
161
+ end
162
+
163
+ describe '#after_scenario' do
164
+ let(:scenario) { double('scenario') }
165
+
166
+ subject { reporter.after_scenario(scenario); super() }
167
+
168
+ before do
169
+ allow(scenario).to receive(:failed?).and_return(false)
170
+ allow(scenario).to receive(:passed?).and_return(true)
171
+ allow(scenario).to receive(:pending?).and_return(false)
172
+ end
173
+
174
+ it { is_expected.to eq '.' }
175
+
176
+ context '<failed>' do
177
+ before do
178
+ allow(scenario).to receive(:failed?).and_return(true)
179
+ end
180
+
181
+ it { is_expected.to eq '' }
182
+ end
183
+
184
+ context '<pending>' do
185
+ before do
186
+ allow(scenario).to receive(:pending?).and_return(true)
187
+ end
188
+
189
+ it { is_expected.to eq '?' }
190
+ end
191
+ end
192
+
193
+ describe '#after_feature' do
194
+ let(:feature) { double('feature') }
195
+
196
+ subject { reporter.after_feature(feature); super() }
197
+
198
+ it { is_expected.to eq '' }
199
+ end
200
+
201
+ describe '#after_features' do
202
+ let(:features) { [] }
203
+
204
+ subject { reporter.after_features(features); super() }
205
+
206
+ it do
207
+ is_expected.to eq unindent <<~TEXT
208
+ .
209
+ .
210
+ .0 scenarios: 0 passed, 0 failing, 0 pending
211
+ .
212
+ TEXT
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,88 @@
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::TeamCityReporter 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
+ allow(feature).to receive(:name).and_return 'Demo feature'
18
+ allow(feature).to receive(:file).and_return \
19
+ File.join(Dir.getwd, 'features', 'file.feature')
20
+ allow(feature).to receive(:line).and_return 1
21
+ allow(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 'include a testSuiteStarted command' do
28
+ is_expected.to include <<~TXT
29
+ ##teamcity[testSuiteStarted name='Demo feature']
30
+ TXT
31
+ end
32
+ end
33
+
34
+ describe '#before_scenario' do
35
+ let(:scenario) { double('scenario') }
36
+
37
+ before do
38
+ allow(scenario).to receive(:name).and_return 'Running the scenario'
39
+ allow(scenario).to receive(:file).and_return \
40
+ File.join(Dir.getwd, 'features', 'file.feature')
41
+ allow(scenario).to receive(:line).and_return 5
42
+ end
43
+
44
+ subject { reporter.before_scenario(scenario); super() }
45
+
46
+ it do
47
+ is_expected.to include <<~TXT
48
+ ##teamcity[testStarted name='Running the scenario']
49
+ TXT
50
+ end
51
+ end
52
+
53
+ describe '#after_scenario' do
54
+ let(:scenario) { double('scenario') }
55
+
56
+ before do
57
+ allow(scenario).to receive(:name).and_return 'Running the scenario'
58
+ allow(scenario).to receive(:passed?).and_return(true)
59
+ allow(scenario).to receive(:failed?).and_return(false)
60
+ allow(scenario).to receive(:pending?).and_return(false)
61
+ allow(scenario).to receive(:aborted?).and_return(false)
62
+ end
63
+
64
+ subject { reporter.after_scenario(scenario); super() }
65
+
66
+ it do
67
+ is_expected.to include <<~TXT
68
+ ##teamcity[testFinished name='Running the scenario']
69
+ TXT
70
+ end
71
+ end
72
+
73
+ describe '#after_feature' do
74
+ let(:feature) { double('feature') }
75
+
76
+ before do
77
+ allow(feature).to receive(:name).and_return 'Demo feature'
78
+ end
79
+
80
+ subject { reporter.after_feature(feature); super() }
81
+
82
+ it do
83
+ is_expected.to include <<~TXT
84
+ ##teamcity[testSuiteFinished name='Demo feature']
85
+ TXT
86
+ end
87
+ end
88
+ end
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: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-26 00:00:00.000000000 Z
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -118,7 +118,9 @@ files:
118
118
  - lib/gurke/tag.rb
119
119
  - lib/gurke/version.rb
120
120
  - spec/gurke/feature_list_spec.rb
121
+ - spec/gurke/reporters/compact_reporter_spec.rb
121
122
  - spec/gurke/reporters/default_reporter_spec.rb
123
+ - spec/gurke/reporters/team_city_reporter_spec.rb
122
124
  - spec/gurke/run_list_spec.rb
123
125
  - spec/gurke/scenario_spec.rb
124
126
  - spec/gurke/step_definition_spec.rb
@@ -164,7 +166,9 @@ test_files:
164
166
  - features/support/steps/cli_steps.rb
165
167
  - features/support/steps/file_steps.rb
166
168
  - spec/gurke/feature_list_spec.rb
169
+ - spec/gurke/reporters/compact_reporter_spec.rb
167
170
  - spec/gurke/reporters/default_reporter_spec.rb
171
+ - spec/gurke/reporters/team_city_reporter_spec.rb
168
172
  - spec/gurke/run_list_spec.rb
169
173
  - spec/gurke/scenario_spec.rb
170
174
  - spec/gurke/step_definition_spec.rb