Replies: 2 comments 1 reply
-
The RSpec style guide mildly suggests that one expectation per example is legacy. Would you like to harvest some real-world usages and see if this is mostly ignored, or does the one expectation per example still stand? I always tend to tweak the |
Beta Was this translation helpful? Give feedback.
-
I'm very new to all this. The real world usages I think will help me a lot. I've been hoping to discover some project that I can refer to for examples, depth of testing, etc. The In the example the example I cited, would that be the right place to add But, the quest did lead me to some interesting discoveries / growth. Although after I posted my solution, I learned that there are even better ways to do it but I haven't spent the time yet to fully realize them. |
Beta Was this translation helpful? Give feedback.
-
The test that was generated is:
Rubocop complains with "RSpec/NoExpectationExample: No expectation found in this example."
I tracked down RSpec/NoExpectationExample and it has something I can add to the
.rubocop.yml
file. I tried:but now I get "Example has too many expectations [3/1]". Which is true but the outer assert_select is doing two things. It is making sure the form exists but it is also grabbing its children and passing it down to the two inner selects. So... I don't see how to write this using just one assert_select.
And curiously, this example from the RSpec style guide is doing pretty much the same thing. The outer expect is testing things and then passing things down to the inner expect.
So... my guess is that somehow I can tell Rubocop via
.rubocop.yml
that assert_select works the same way. But... looking at default.yml I don't seeexpect
anywhere except underExpectations
so I'm stumped.Beta Was this translation helpful? Give feedback.
All reactions