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
Shared Examples #13
Comments
Doesn't this violate the one assertion per test principal? ;) FWIW, I agree with this practices, but just goes to show that the other rule is more of a guideline. |
I don't believe it violates the 'one assertion rule' by definition. It will depend entirely on how you define your shared example. The intent is to group behavior, so it can include multiple single assertion cases. See https://www.relishapp.com/rspec/rspec-core/v/2-11/docs/example-groups/shared-examples for examples of this. |
The GOOD example is missing the actual shared examples, so this code doesn't make sense unless someone knows how shared examples work. |
@gavingmiller absolutely right. Shared examples definition part is missing. It is confusing. |
@gavingmiller - Not only is the GOOD shared example missing, but it seems to have nothing to do with the BAD code. |
Hmm, so shared examples is just a replacement for copy paste right? I had a hard time parsing the original documentation. For those familiar with jest, I believe it behaves similar to describe.each
|
What about this https://stackoverflow.com/questions/6453235/what-does-damp-not-dry-mean-when-talking-about-unit-tests ? Isn't DRY a bad idea for tests? (in general) |
Yep, I agree that DAMP is often better than DRY in specs. It's a trade off between dryness and readability. That SO question is excellent. Testing is an art, not a science. So I think there is room for personal style here... |
Write your thoughts about the "shared examples" best practice.
The text was updated successfully, but these errors were encountered: