Skip to content

Conversation

@jelaniwoods
Copy link
Contributor

@jelaniwoods jelaniwoods commented Jul 24, 2025

Problem

render_html doesn't explicitly include the status of the test example. The status is important for understanding the output at a glance.

we could add another method to rspec-html_messages in addition to render_html, output_html, failure_message_html, and backtrace_html: status_html. This would display a div.alert.alert-success with "The test passed!" or div.alert.alert-warning with "The test did not pass." And render_html could call that above the rest.

Solution

This PR adds a status_html method that renders a styled alert with a status message.


Important

Adds status_html method to render test status as HTML alert and integrates it into render_html, updating templates and version to 0.2.1.

  • Behavior:
    • Adds status_html method in html_messages.rb to render test status as HTML alert.
    • Integrates status_html into render_html to display status above other sections in example.html.erb.
  • Templates:
    • Adds _status.html.erb for rendering status alerts.
    • Updates example.html.erb to include status content.
  • Version:
    • Updates version to 0.2.1 in version.rb.

This description was created by Ellipsis for ca316b2. You can customize this summary. It will automatically update as commits are pushed.

end
end

private
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a private keyword above this, so I removed this one.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Changes requested ❌

Reviewed everything up to dfcdeb9 in 1 minute and 39 seconds. Click for details.
  • Reviewed 121 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. README.md:267
  • Draft comment:
    New documentation for status_html is clear. Good update to include the new status section in the API reference.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. lib/rspec/html_messages/templates/example.html.erb:2
  • Draft comment:
    The inclusion of the status block via status_html is correct. Note that the extra
    wrapper may be redundant since the _status.html.erb partial already outputs a containing
    element.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50% None
3. lib/rspec/html_messages.rb:101
  • Draft comment:
    Refactoring boolean checks to use the new failed? helper (in place of 'status == "failed"') improves consistency. This change is clear and enhances maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_6vxX3aTq6N4HmEcG

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

end

def status_html(**options)
css_class, message = ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the ambiguous assignment ‘css_class, message = ""’. It’s clearer to initialize variables in their respective branches or initialize them explicitly (e.g., using css_class = '' and message = '') to avoid potential confusion.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed 6502ec6 in 1 minute and 43 seconds. Click for details.
  • Reviewed 16 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. lib/rspec/html_messages.rb:161
  • Draft comment:
    The new failed? method now checks that status == "failed" instead of using !passed?. This means that if an example’s status is "pending", it will no longer be treated as failed. Ensure that this change is intentional and that pending examples are handled appropriately elsewhere.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_Hn0x9crdPcrsCywB

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

<% end %>

<% if output_content = output_html(**@options) %>
<div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this div may need an mt-3 now, for consistency?

Copy link
Contributor

@raghubetina raghubetina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, LGTM

css_class = "alert-success"
message = "This test passed!"
else
css_class = "alert-danger"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
css_class = "alert-danger"
css_class = "alert-warning"

I was thinking of yellow for failures (and avoiding the word "fail" in messages), to be less scary. I used warning below too for the failure message card bg-color.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed ca316b2 in 1 minute and 10 seconds. Click for details.
  • Reviewed 31 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. lib/rspec/html_messages.rb:84
  • Draft comment:
    Remove the redundant initialization 'css_class, message = ""' since both variables are assigned on all paths below. This improves code clarity.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. lib/rspec/html_messages.rb:89
  • Draft comment:
    The change from 'alert-danger' to 'alert-warning' aligns with the updated design. Consider whether tests with status 'pending' should be handled differently.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. lib/rspec/html_messages/templates/example.html.erb:9
  • Draft comment:
    The addition of the 'mt-3' class to the output container ensures proper spacing. For consistency, consider if a similar margin should be applied to the status block.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_inT01b3GwufPK3h6

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@jelaniwoods jelaniwoods merged commit c2b9336 into main Jul 25, 2025
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants