rspec-html_messages 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: fc3b59ac0f83077258fad4cb42234bc719e03c9546bc538ea18df41f6b86dced
4
- data.tar.gz: a635ad05e6f767d73e5a824cec99478e5bd23753cd3e34fc3ce4ece324dd1cc6
3
+ metadata.gz: ff30f0e2f8f4dd1f05c17b9b7c8e5eb956368199b8e218d7e62a8341cdb30415
4
+ data.tar.gz: a344112ac2e4f7a472b2b55c137235e9cef74552fbde2461512252fec6627a6c
5
5
  SHA512:
6
- metadata.gz: c2ca977899e3481b5bed885c536153a2dc3f1b6c3483112b820059ad8cf3c414c2ccbab1ebdae6294d713a9eff4ae3216c267b03a17ac365dac2b88b42d719fb
7
- data.tar.gz: 3e28af8ae246b95686960a4b52da458780dcc16d69707f9777b83532eac074331204e00ce40ccb5fe4b0637d14a7ac1db82572dbd6e7978734c6688572c64a9e
6
+ metadata.gz: 4fadac33c3ffdb698e5a89aa6e4ebdf8939d0a06ac8ac1e82069c25ec21bfae9b56927db70806c1d2504a5041773633522b64dae249598d561b4da58cbb83be9
7
+ data.tar.gz: b5dd13e48a046a0ddfd841798a51ab02ca1d777bebc68fd41d0fa2ece19ef06ec523a2ce5a4c9e1b7c4135f2327f13dc823927b8573f74ace660745ff9d86b8e
data/README.md CHANGED
@@ -267,8 +267,11 @@ Renders just the exception details section. Returns `nil` if no exception.
267
267
  #### `backtrace_html(**options)`
268
268
  Renders just the backtrace section. Returns `nil` if no backtrace.
269
269
 
270
+ #### `status_html(**options)`
271
+ Renders just the status section.
272
+
270
273
  #### `render_html(**options)`
271
- Convenience method that renders all three sections in a standard layout.
274
+ Convenience method that renders all four sections in a standard layout.
272
275
 
273
276
  ### Class Methods
274
277
 
@@ -0,0 +1,3 @@
1
+ <div class="alert <%= css_class %>" role="alert">
2
+ <%= message %>
3
+ </div>
@@ -1,6 +1,12 @@
1
1
  <div class="rspec-html-messages">
2
- <% if output_content = output_html(**@options) %>
2
+ <% if status_content = status_html(**@options) %>
3
3
  <div>
4
+ <%= status_content %>
5
+ </div>
6
+ <% end %>
7
+
8
+ <% if output_content = output_html(**@options) %>
9
+ <div class="mt-3">
4
10
  <%= output_content %>
5
11
  </div>
6
12
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rspec
4
4
  class HtmlMessages
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -81,16 +81,27 @@ module Rspec
81
81
  render_template("_backtrace")
82
82
  end
83
83
 
84
+ def status_html(**options)
85
+ if passed?
86
+ css_class = "alert-success"
87
+ message = "This test passed!"
88
+ else
89
+ css_class = "alert-warning"
90
+ message = "The test did not pass."
91
+ end
92
+ render_template("_status", css_class: css_class, message: message)
93
+ end
94
+
84
95
  # Public boolean methods so users can make their own decisions
85
96
  def has_output?
86
97
  # Don't show output for errors before assertions
87
98
  return false if error_before_assertion?
88
99
 
89
- status == "failed" || has_actual?
100
+ failed? || has_actual?
90
101
  end
91
102
 
92
103
  def has_failure_message?
93
- status == "failed" && !error_before_assertion? && failure_message.present?
104
+ failed? && !error_before_assertion? && failure_message.present?
94
105
  end
95
106
 
96
107
  def has_exception_details?
@@ -142,6 +153,14 @@ module Rspec
142
153
 
143
154
  private
144
155
 
156
+ def passed?
157
+ status == "passed"
158
+ end
159
+
160
+ def failed?
161
+ status == "failed"
162
+ end
163
+
145
164
  def default_options
146
165
  {
147
166
  force_diffable: FORCE_DIFFABLE_MATCHERS,
@@ -174,7 +193,7 @@ module Rspec
174
193
  end
175
194
 
176
195
  def calculate_failure_message
177
- return nil unless status == "failed"
196
+ return nil unless failed?
178
197
 
179
198
  message = example.dig("exception", "message")
180
199
  return nil unless message
@@ -314,8 +333,6 @@ module Rspec
314
333
  end
315
334
  end
316
335
 
317
- private
318
-
319
336
  def validate_example!(example)
320
337
  raise ArgumentError, "Example cannot be nil" if example.nil?
321
338
  raise ArgumentError, "Example must be a Hash" unless example.is_a?(Hash)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-html_messages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
@@ -111,6 +111,7 @@ files:
111
111
  - lib/rspec/html_messages/templates/_diff.html.erb
112
112
  - lib/rspec/html_messages/templates/_exception_details.html.erb
113
113
  - lib/rspec/html_messages/templates/_failure_message.html.erb
114
+ - lib/rspec/html_messages/templates/_status.html.erb
114
115
  - lib/rspec/html_messages/templates/example.html.erb
115
116
  - lib/rspec/html_messages/value_formatter.rb
116
117
  - lib/rspec/html_messages/version.rb