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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 193c1179b2445a6633690062c9a080e58114c070
4
- data.tar.gz: ded54df1f658009aa52a5d34c6002dcc73a79900
3
+ metadata.gz: d981a98762ef01378b796ffd0afc87d941e8f043
4
+ data.tar.gz: e78ae2742bda24b4136324f16a4e5a130cc9bd77
5
5
  SHA512:
6
- metadata.gz: f453790865b8f5b9a84977902203c7ee4af4d7e6ac7d6c6da7a2a1a2accb7eac38377c0eaf543758fc79e017bcdceb7b837ce5d8fbcabe35217b1319c62bcd22
7
- data.tar.gz: 6bd9c1e1a719e058e2769bfe9502e50622e0638de6ff7bc8727c882324e50adb6ef9cfea262841d030470f3d6878fbcaa38de0b90869dbf2db22761c39be29ab
6
+ metadata.gz: 9bbb5eaee3f1655838264328a1ee198ff7f67523cace8bf298411ced29a394d50e2393975cfedf1d803a349b3e4938ddbbad9dd5860019919c258a2210344022
7
+ data.tar.gz: 3e67a057669e4c37f8ba8c05ab211fef6df263fb1be4f539cc5bda0bb52a64b9509a1628b84875659cd6b3b715af3c8fb631d39aa54005fb3e759fe800fbcbe7
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'kanoah_rspec_formatter'
@@ -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 = [:start, :example_started, :example_passed, :example_failed, :example_pending]
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
- :example_passed, :example_pending, :example_failed, :example_started
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 == 0
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 RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success)
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 RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
47
+ output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
48
48
  "(PENDING: #{message})",
49
- :pending)
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
- when 'Pass' then :success
77
- when 'Fail' then :failure
78
- else :pending
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.has_key?(:test_id) && !test_id(notification.example).empty?
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.has_key?(:test_id) && !test_id(notification.example).empty?
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.has_key?(:test_id) && !test_id(notification.example).empty?
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
- test_case: test_id(example),
35
- status: status(example.metadata[:execution_result]),
36
- comment: comment(example.metadata),
37
- execution_time: run_time(example.metadata[:execution_result]),
38
- script_results: steps(example.metadata)
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,v| k == :step_name } }
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
- when :failed, :passed then
68
- status.to_s.gsub('ed', '').capitalize
69
- when :pending then
70
- 'Blocked'
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
@@ -3,4 +3,3 @@ module KanoahRSpecFormatter
3
3
  RSpec::Core::Example.send :include, KanoahRSpecFormatter::Example
4
4
  end
5
5
  end
6
-
@@ -1,22 +1,26 @@
1
1
  module KanoahRSpecFormatter
2
2
  module Example
3
- def step(step, options = {}, &block)
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({ step_name: step,index: @metadata[:step_index], status: 'Pass' })
7
+ @metadata[:steps].push(step_name: step, index: @metadata[:step_index], status: 'Pass')
8
8
  rescue Exception => e
9
- @metadata[:steps].push({ step_name: step, index: @metadata[:step_index], status: 'Fail', comment: process_exception(e) })
10
- fail
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.has_key?(:step_index)
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.failures : 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
@@ -1,3 +1,3 @@
1
1
  module KanoahRSpecFormatter
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  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
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-03 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler