Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selector_assertions/html_selector: No trailing . on content_mismatch #102

Merged
merged 1 commit into from
Jul 14, 2022
Merged

selector_assertions/html_selector: No trailing . on content_mismatch #102

merged 1 commit into from
Jul 14, 2022

Conversation

issyl0
Copy link
Contributor

@issyl0 issyl0 commented Jul 4, 2022

  • I was refreshing my Rails knowledge by following a Rails tutorial (but with the latest gem versions) and I found that when I used assert_select and it failed, the message was printed like:
  1) Failure:
StaticPagesControllerTest#test_should_get_about [/Users/issyl0/repos/issyl0/rails-tutorial/sample_app/test/controllers/static_pages_controller_test.rb:24]:
<About | Ruby on Rails Tutorial Sample App> expected but was
<About| Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.
  • That is, the "expected but was" sentence ends with two periods. There's an example of this output in the release notes for Rails 4.2 about assert_select behaviour changes, so it's pretty old. But even so, the two periods to end the sentence looked weird to me.
  • I did look at the MiniTest code to see if I could upstream this further (if message.end_with?(".") then don't add another period, or something), but I couldn't find the place to do it and I was also surprised that someone else hadn't noticed this before, so I thought I'd leave that alone as there are probably reasons that are way beyond my levels of understanding of the interactions between MiniTest's core functionality vs. this gem!

- I was refreshing my Rails knowledge by following a Rails tutorial
  (but with the latest gem versions) and I found that when I used
  `assert_select` and it failed, the message was printed like:

```
  1) Failure:
StaticPagesControllerTest#test_should_get_about [/Users/issyl0/repos/issyl0/rails-tutorial/sample_app/test/controllers/static_pages_controller_test.rb:24]:
<About | Ruby on Rails Tutorial Sample App> expected but was
<About| Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.
```

- That is, the "expected but was" sentence ends with two periods.
  There's an example of this output in the [release notes for Rails 4.2
  about `assert_select` behaviour
  changes](https://edgeguides.rubyonrails.org/4_2_release_notes.html#assert-select),
  so it's pretty old. But even so, the two periods to end the sentence
  looked weird to me.
- I did look at the MiniTest code to see if I could upstream this
  further (`if message.end_with?(".")` then don't add another period, or
  something), but I couldn't find the place to do it and I was also
  surprised that someone else hadn't noticed this before, so I thought I'd
  leave that alone as there are probably reasons that are way beyond my
  levels of understanding of the interactions between MiniTest's core
  functionality vs. this gem!
Copy link
Member

@sikachu sikachu left a comment

Choose a reason for hiding this comment

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

I think this is the right way to fix it. 👍

@rafaelfranca rafaelfranca merged commit 71ccffb into rails:master Jul 14, 2022
@issyl0 issyl0 deleted the fix-double-period-on-assert_select branch July 14, 2022 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants