rspec-ci-prettify 0.1.0 → 0.2.0

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: 5a2e3078e3f88cb494342835d5dd5a82c8e7a5a55df5ea7dca66c0f34d22008d
4
- data.tar.gz: 9b570af8c0d2710379e801ea0a6239b588c5ea1e1fd4564194268c4bd462bf4d
3
+ metadata.gz: cf3101b2b7072996c975de110df7bac584d6205895ab9bf552bcf41fa35617b8
4
+ data.tar.gz: 1845bf2494e6b29d36dee4c2c27141e54e3aa832b979717b4fcff2a5f78dc54d
5
5
  SHA512:
6
- metadata.gz: 425d510af634ee01ad47c3eb8e3c2289f2f2e7c1b099cec3aa6a52df29bb0531d93170828391768832b6335d8b6e8f57497c432ace485c3c14fd2490e127a3dd
7
- data.tar.gz: 5a1fef723c7ff99386fb14557bfb8a032936cf37ffad3f7361f68229fa2cb9378162e87f3f63aaa7adfbe324fa3f226b8562d3e970a042e93bb0d41cef1f26a8
6
+ metadata.gz: 9614286b2c32940116ddbfb04d60945c334f3ee03deb77b099480ab41814748cdd1b16d023654eee04faf14fb97fb4b0494e04bc86559671a5723515ac4bd84d
7
+ data.tar.gz: 26fca45f6d8e042fb3907bdb098b977128079d56e2eed9e821588c4f375532b1b3ff0cc50df4bdd71c1630eaa516fdf426371f61eda1ef20af6e0c93e94d23cd
@@ -4,7 +4,7 @@ module RSpec
4
4
  module Ci
5
5
  module Prettify
6
6
  module Constants
7
- SEPARATOR = "\n\n#{'-' * 55}"
7
+ SEPARATOR = "#{'-' * 55}"
8
8
  end
9
9
  end
10
10
  end
@@ -17,37 +17,43 @@ module RSpec
17
17
  end
18
18
 
19
19
  def dump_summary(summary)
20
- @output << RSpec::Ci::Prettify::Constants::SEPARATOR
21
- @output << format_colour("\n\nSUMMARY:\n\t", :cyan)
20
+ @output << "\n\n"
21
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
22
+ @output << "\n\n"
23
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap("SUMMARY:", :cyan)
22
24
 
23
25
  build_summary(summary)
24
26
  end
25
27
 
26
28
  def dump_pending(notification)
27
- @output << RSpec::Ci::Prettify::Constants::SEPARATOR
28
- @output << format_colour("\n\nPENDING:\n\t", :pending)
29
+ @output << "\n\n"
30
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
31
+ @output << "\n\n"
32
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap("PENDING:", :pending)
33
+ @output << "\n\n\t"
29
34
 
30
35
  @output << notification.pending_examples.map do |example|
31
- format_colour(format_example_summary(example), :pending)
36
+ RSpec::Core::Formatters::ConsoleCodes.wrap(format_example_summary(example), :pending)
32
37
  end.join("\n\t")
33
38
  end
34
39
 
35
40
  def dump_failures(notification)
36
- @output << RSpec::Ci::Prettify::Constants::SEPARATOR
37
- @output << format_colour("\n\nFAILURES:\n\t", :failure)
41
+ @output << "\n\n"
42
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
43
+ @output << "\n\n"
44
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap("FAILURES:", :failure)
45
+ @output << "\n\n\t"
38
46
  @output << failed_examples_output(notification)
39
47
  end
40
48
 
41
49
  def example_passed(example)
42
- # @output << RSpec::Core::Formatters::ConsoleCodes.wrap(".", :success)
50
+
43
51
  end
44
52
 
45
53
  def example_failed(example)
46
- # @output << RSpec::Core::Formatters::ConsoleCodes.wrap("F", :failure)
47
54
  end
48
55
 
49
56
  def example_pending(example)
50
- # @output << RSpec::Core::Formatters::ConsoleCodes.wrap("*", :pending)
51
57
  end
52
58
 
53
59
  def close(_notification)
@@ -63,44 +69,48 @@ module RSpec
63
69
 
64
70
  failure_count = summary.failed_examples.count
65
71
  pass_count = total_tests_ran - failure_count
66
-
72
+ @output << "\n"
67
73
  @output << build_test_suite_duration(summary, total_tests_ran)
74
+ @output << "\n"
68
75
  @output << build_pending_summary(pending_count, total_test_count)
69
76
 
70
77
  if pass_count == total_tests_ran
71
- @output << format_colour("\n All #{total_tests_ran} tests ran passed!!!", :magenta)
78
+ @output << "\n"
79
+ @output << RSpec::Core::Formatters::ConsoleCodes.wrap("All #{total_tests_ran} tests ran passed!!!", :magenta)
72
80
  return
73
81
  end
74
-
82
+ @output << "\n"
75
83
  @output << build_failure_summary(failure_count, total_tests_ran)
84
+ @output << "\n"
76
85
  @output << build_pass_summary(pass_count, total_tests_ran)
86
+ @output << "\n"
77
87
  end
78
88
 
79
89
  def build_test_suite_duration(summary, test_run_count)
80
90
  duration = RSpec::Core::Formatters::Helpers.format_duration(summary.duration)
81
- duration_text = "\nRan #{test_run_count} tests overall in #{duration}."
91
+ duration_text = "Ran #{test_run_count} tests overall in #{duration}."
82
92
 
83
- format_colour(duration_text, :cyan)
93
+ RSpec::Core::Formatters::ConsoleCodes.wrap(duration_text, :cyan)
84
94
  end
85
95
 
86
96
  def build_pending_summary(pending_count, total_test_count)
87
97
  pending_percentage = percentage_of_examples(pending_count, total_test_count)
88
- pending_summary = "\n #{pending_percentage} of tests skipped/pending (#{pending_count})"
89
- indent(format_colour(pending_summary, :pending), 4)
98
+
99
+ pending_summary = "#{pending_percentage} of tests skipped/pending (#{pending_count})"
100
+ indent(RSpec::Core::Formatters::ConsoleCodes.wrap(pending_summary, :pending), 4)
90
101
  end
91
102
 
92
103
  def build_failure_summary(failure_count, total_tests_ran)
93
104
  failure_percentage = percentage_of_examples(failure_count, total_tests_ran)
94
- failure_summary = "\n #{failure_percentage} of tests failed (#{failure_count})"
95
- indent(format_colour(failure_summary, :failure), 4)
105
+ failure_summary = "#{failure_percentage} of tests failed (#{failure_count})"
106
+ indent(RSpec::Core::Formatters::ConsoleCodes.wrap(failure_summary, :failure), 4)
96
107
  end
97
108
 
98
109
  def build_pass_summary(pass_count, total_tests_ran)
99
110
  pass_percentage = percentage_of_examples(pass_count, total_tests_ran)
111
+ pass_summary = "#{pass_percentage} of tests passed (#{pass_count})"
100
112
 
101
- pass_summary = "\n #{pass_percentage} of tests passed (#{pass_count})"
102
-
103
- indent(format_colour(pass_summary, :success), 4)
113
+ indent(RSpec::Core::Formatters::ConsoleCodes.wrap(pass_summary, :success), 4)
104
114
  end
105
115
 
106
116
  def percentage_of_examples(count, total)
@@ -120,10 +130,6 @@ module RSpec
120
130
  output.join("\n\n\t")
121
131
  end
122
132
 
123
- def format_colour(str, status)
124
- RSpec::Core::Formatters::ConsoleCodes.wrap(str, status)
125
- end
126
-
127
133
  def format_example_summary(example)
128
134
  full_description = example.full_description
129
135
  location = example.location
@@ -132,10 +138,11 @@ module RSpec
132
138
 
133
139
  def failed_example_output(example)
134
140
  msg = example.execution_result.exception.message
135
- formatted_err_message = sanitize_msg(msg)
136
- summary = format_colour(format_example_summary(example), :failure)
141
+ sanitized_err_message = sanitize_msg(msg)
142
+ formatted_err_message = RSpec::Core::Formatters::ConsoleCodes.wrap(sanitized_err_message, :failure)
143
+ summary = RSpec::Core::Formatters::ConsoleCodes.wrap(format_example_summary(example), :failure)
137
144
 
138
- "#{summary} \n #{formatted_err_message}"
145
+ "#{summary} \n #{formatted_err_message} \n"
139
146
  end
140
147
 
141
148
  def sanitize_msg(msg)
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Ci
5
5
  module Prettify
6
- VERSION = '0.1.0'
6
+ VERSION = '0.2.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-ci-prettify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jjholmes927
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-02 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core