kanoah_rspec_formatter 0.1.3.1 → 0.2.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
  SHA1:
3
- metadata.gz: 1e61de747c44665881b2c67e40521427e4d66ab2
4
- data.tar.gz: ccd111f5fe76378bbb3cd6ec0e8cca0650fb7bc4
3
+ metadata.gz: 0235e51a6b5a2f2e062ea4c9a61924483d25fb53
4
+ data.tar.gz: 71b1c7d618eb4d4fc7d66643fc33d2ee9de08cba
5
5
  SHA512:
6
- metadata.gz: 1da4efe354ef03611ea1152f7911bd7901bc9ddcf3163b45d026f6426d2a978686b474f17800aa9a51608a9d4be0769e52ea744ee80a3972ed96cbf70e1dbbec
7
- data.tar.gz: c0495976df8760d445e17e611f4b645efcef63bf6d2f52723a26b788c62dc0dc84f2d363bb0c626e3bb165917abb5cea7824b030d6f1db1a0bc27871bcddca35
6
+ metadata.gz: 20fcd45cad1e7b48efc5dcb144fde233d89d76ea70b72220eb62f95370724e25ab6f4275f1d681936c33a4e886b2d5d91be7352c825826ab7e88f1f8fdb1369c
7
+ data.tar.gz: 435d22006e7c1ff09dfe1fcc3c32ff8ac6c2446395ec746b71ebf32d4e65ac33ede56400af25214460129ac485cfda626cb510618fa0cf593b1b3d163b037003
@@ -0,0 +1,46 @@
1
+ class KanoahOutputFormatter < RSpec::Core::Formatters::DocumentationFormatter
2
+ RSpec::Core::Formatters.register self, :example_group_finished, :example_passed, :example_failed, :dump_failures, :dump_summary
3
+
4
+ def initialize(output)
5
+ super
6
+ @group_level = 0
7
+ end
8
+
9
+ def example_group_finished(_notification)
10
+ @group_level -= 1
11
+ end
12
+
13
+ def example_passed(passed)
14
+ passed_output(passed.example)
15
+ end
16
+
17
+ def example_failed(failure)
18
+ failure_output(failure.example)
19
+ end
20
+
21
+ private
22
+
23
+ def passed_output(example)
24
+ super(example)
25
+ format_output(example)
26
+ end
27
+
28
+ def failure_output(example)
29
+ super(example)
30
+ format_output(example)
31
+ end
32
+
33
+ def format_output(example)
34
+ example.metadata[:steps].each do |step|
35
+ output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{' ' * (@group_level + 1)}step #{step[:index] + 1}: #{step[:step_name]}",current_color(step[:status]))
36
+ end
37
+ end
38
+
39
+ def current_color(status)
40
+ case status
41
+ when 'Pass' then :success
42
+ when 'Fail' then :failure
43
+ else :pending
44
+ end
45
+ end
46
+ end
@@ -12,17 +12,14 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
12
12
  end
13
13
 
14
14
  def example_passed(notification)
15
- format_output(notification.example)
16
15
  proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
17
16
  end
18
17
 
19
18
  def example_failed(notification)
20
- format_output(notification.example)
21
19
  proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
22
20
  end
23
21
 
24
22
  def example_pending(notification)
25
- format_output(notification.example)
26
23
  proccess_result(notification.example) if notification.example.metadata.has_key?(:test_id) && !test_id(notification.example).empty?
27
24
  end
28
25
 
@@ -32,22 +29,6 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
32
29
 
33
30
  private
34
31
 
35
- def format_output(example)
36
- example.metadata[:steps].each do |step|
37
- @output << "#{current_color(step[:status])}\s\s\s\s\sstep #{step[:index] + 1}: #{step.delete(:step_name)} \n"
38
- @output << "\e[0m"
39
- end
40
- end
41
-
42
- # TODO: get this to work with RSpec.configuration
43
- def current_color(status)
44
- case status
45
- when 'Pass' then "\e[92m"
46
- when 'Fail' then "\e[31m"
47
- else "\e[93m"
48
- end
49
- end
50
-
51
32
  def proccess_result(example)
52
33
  body = {
53
34
  test_case: test_id(example),
@@ -75,8 +56,10 @@ class KanoahResultFormatter < KanoahRSpecFormatter::BaseFormatter
75
56
  scenario[:kanoah_evidence][:title] + "\n" + scenario[:kanoah_evidence][:path] unless scenario[:kanoah_evidence].nil?
76
57
  end
77
58
 
78
- def steps(scenario)
79
- scenario[:steps]
59
+ def steps(scenario) # TODO: Make this better
60
+ arr = []
61
+ scenario[:steps].each { |s| arr << s.reject{ |k,v| k == :step_name } }
62
+ arr
80
63
  end
81
64
 
82
65
  def status_code(status)
@@ -5,3 +5,4 @@ require_relative 'kanoah_rspec_formatter/configuration'
5
5
  require_relative 'kanoah_rspec_formatter/rspec_steps'
6
6
  require_relative 'kanoah_rspec_formatter/adapter'
7
7
  require_relative 'kanoah_result_formatter'
8
+ require_relative 'kanoah_output_formatter'
@@ -6,7 +6,6 @@ module KanoahRSpecFormatter
6
6
  yield block
7
7
  @metadata[:steps].push({ step_name: _step,index: @metadata[:step_index], status: 'Pass' })
8
8
  rescue Exception => e
9
- @exception = e
10
9
  @metadata[:steps].push({ step_name: _step, index: @metadata[:step_index], status: 'Fail', comment: e })
11
10
  fail
12
11
  end
@@ -1,3 +1,3 @@
1
1
  module KanoahRSpecFormatter
2
- VERSION = '0.1.3.1'
2
+ VERSION = '0.2.0'
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.1.3.1
4
+ version: 0.2.0
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-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,6 +68,7 @@ files:
68
68
  - bin/setup
69
69
  - kanoah_rspec_formatter.gemspec
70
70
  - lib/kanoah_formatter/base_formatter.rb
71
+ - lib/kanoah_output_formatter.rb
71
72
  - lib/kanoah_result_formatter.rb
72
73
  - lib/kanoah_rspec_formatter.rb
73
74
  - lib/kanoah_rspec_formatter/adapter.rb
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  version: '0'
95
96
  requirements: []
96
97
  rubyforge_project:
97
- rubygems_version: 2.6.10
98
+ rubygems_version: 2.6.11
98
99
  signing_key:
99
100
  specification_version: 4
100
101
  summary: ''