kanoah_rspec_formatter 0.2.4 → 0.2.5
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 +4 -4
- data/kanoah_rspec_formatter.gemspec +1 -0
- data/lib/kanoah_formatter/base_formatter.rb +2 -2
- data/lib/kanoah_output_formatter.rb +9 -9
- data/lib/kanoah_result_formatter.rb +13 -14
- data/lib/kanoah_rspec_formatter/adapter.rb +0 -1
- data/lib/kanoah_rspec_formatter/rspec_steps.rb +10 -6
- data/lib/kanoah_rspec_formatter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d981a98762ef01378b796ffd0afc87d941e8f043
|
4
|
+
data.tar.gz: e78ae2742bda24b4136324f16a4e5a130cc9bd77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bbb5eaee3f1655838264328a1ee198ff7f67523cace8bf298411ced29a394d50e2393975cfedf1d803a349b3e4938ddbbad9dd5860019919c258a2210344022
|
7
|
+
data.tar.gz: 3e67a057669e4c37f8ba8c05ab211fef6df263fb1be4f539cc5bda0bb52a64b9509a1628b84875659cd6b3b715af3c8fb631d39aa54005fb3e759fe800fbcbe7
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rspec/core/formatters/base_formatter'
|
2
2
|
module KanoahRSpecFormatter
|
3
3
|
class BaseFormatter < RSpec::Core::Formatters::BaseFormatter
|
4
|
-
NOTIFICATIONS = [
|
4
|
+
NOTIFICATIONS = %i[start example_started example_passed example_failed example_pending].freeze
|
5
5
|
|
6
6
|
def start(_notification)
|
7
7
|
@api = Kanoah::Client.new(base_url: KanoahRSpecFormatter::Config.config.base_url,
|
@@ -12,4 +12,4 @@ module KanoahRSpecFormatter
|
|
12
12
|
password: KanoahRSpecFormatter::Config.config.password)
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rspec/core/formatters/base_text_formatter'
|
2
2
|
class KanoahOutputFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
3
3
|
RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished,
|
4
|
-
|
4
|
+
:example_passed, :example_pending, :example_failed, :example_started
|
5
5
|
|
6
6
|
def initialize(output)
|
7
7
|
super
|
@@ -13,7 +13,7 @@ class KanoahOutputFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def example_group_started(notification)
|
16
|
-
output.puts if @group_level
|
16
|
+
output.puts if @group_level.zero?
|
17
17
|
output.puts "#{current_indentation}#{notification.group.description.strip}"
|
18
18
|
|
19
19
|
@group_level += 1
|
@@ -39,14 +39,14 @@ class KanoahOutputFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def passed_output(example)
|
42
|
-
output.puts
|
42
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success)
|
43
43
|
format_output(example)
|
44
44
|
end
|
45
45
|
|
46
46
|
def pending_output(example, message)
|
47
|
-
output.puts
|
47
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
|
48
48
|
"(PENDING: #{message})",
|
49
|
-
|
49
|
+
:pending)
|
50
50
|
end
|
51
51
|
|
52
52
|
def failure_output(example)
|
@@ -67,15 +67,15 @@ class KanoahOutputFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
|
67
67
|
|
68
68
|
def format_output(example)
|
69
69
|
example.metadata[:steps].each do |step|
|
70
|
-
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{' ' * (@group_level + 1)}step #{step[:index] + 1}: #{step[:step_name]}",current_color(step[:status]))
|
70
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{' ' * (@group_level + 1)}step #{step[:index] + 1}: #{step[:step_name]}", current_color(step[:status]))
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
def current_color(status)
|
75
75
|
case status
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
when 'Pass' then :success
|
77
|
+
when 'Fail' then :failure
|
78
|
+
else :pending
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative 'kanoah_formatter/base_formatter'
|
2
2
|
class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
|
3
|
-
|
4
3
|
RSpec::Core::Formatters.register self, *NOTIFICATIONS
|
5
4
|
|
6
5
|
def initialize(output)
|
@@ -12,15 +11,15 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def example_passed(notification)
|
15
|
-
proccess_result(notification.example) if notification.example.metadata.
|
14
|
+
proccess_result(notification.example) if notification.example.metadata.key?(:test_id) && !test_id(notification.example).empty?
|
16
15
|
end
|
17
16
|
|
18
17
|
def example_failed(notification)
|
19
|
-
proccess_result(notification.example) if notification.example.metadata.
|
18
|
+
proccess_result(notification.example) if notification.example.metadata.key?(:test_id) && !test_id(notification.example).empty?
|
20
19
|
end
|
21
20
|
|
22
21
|
def example_pending(notification)
|
23
|
-
proccess_result(notification.example) if notification.example.metadata.
|
22
|
+
proccess_result(notification.example) if notification.example.metadata.key?(:test_id) && !test_id(notification.example).empty?
|
24
23
|
end
|
25
24
|
|
26
25
|
def example_started(notification)
|
@@ -31,11 +30,11 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
|
|
31
30
|
|
32
31
|
def proccess_result(example)
|
33
32
|
body = {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
test_case: test_id(example),
|
34
|
+
status: status(example.metadata[:execution_result]),
|
35
|
+
comment: comment(example.metadata),
|
36
|
+
execution_time: run_time(example.metadata[:execution_result]),
|
37
|
+
script_results: steps(example.metadata)
|
39
38
|
}
|
40
39
|
@api.test_run_id ? @api.post_new_result_to_run(body) : @api.post_new_result(body)
|
41
40
|
end
|
@@ -58,16 +57,16 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
|
|
58
57
|
|
59
58
|
def steps(scenario) # TODO: Make this better
|
60
59
|
arr = []
|
61
|
-
scenario[:steps].each { |s| arr << s.reject{ |k,
|
60
|
+
scenario[:steps].each { |s| arr << s.reject { |k, _v| k == :step_name } }
|
62
61
|
arr
|
63
62
|
end
|
64
63
|
|
65
64
|
def status_code(status)
|
66
65
|
case status
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
when :failed, :passed then
|
67
|
+
status.to_s.gsub('ed', '').capitalize
|
68
|
+
when :pending then
|
69
|
+
'Blocked'
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
@@ -1,22 +1,26 @@
|
|
1
1
|
module KanoahRSpecFormatter
|
2
2
|
module Example
|
3
|
-
def step(step,
|
3
|
+
def step(step, _options = {}, &block)
|
4
4
|
@metadata[:steps] = [] if @metadata[:steps].nil?
|
5
5
|
begin
|
6
6
|
yield block
|
7
|
-
@metadata[:steps].push(
|
7
|
+
@metadata[:steps].push(step_name: step, index: @metadata[:step_index], status: 'Pass')
|
8
8
|
rescue Exception => e
|
9
|
-
@metadata[:steps].push(
|
10
|
-
|
9
|
+
@metadata[:steps].push(step_name: step, index: @metadata[:step_index], status: 'Fail', comment: process_exception(e))
|
10
|
+
raise
|
11
11
|
ensure
|
12
|
-
@metadata[:step_index] += 1 if @metadata.
|
12
|
+
@metadata[:step_index] += 1 if @metadata.key?(:step_index)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def process_exception(exception)
|
19
|
-
exception.is_a?(RSpec::Expectations::MultipleExpectationsNotMetError) ? exception
|
19
|
+
exception.is_a?(RSpec::Expectations::MultipleExpectationsNotMetError) ? format_exception(exception) : exception
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_exception(exception)
|
23
|
+
exception.failures.join('<br />').gsub("\n", '<br />')
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanoah_rspec_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Automation Wizards
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|