You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't find any guidelines about this, so I wanted to discuss the pros and the cons of each approach.
An advantage of the former is that it looks cleaner. And I believe that the name of the method is self-evident even for those who are not familiar with RSpec's syntax.
What do you think, guys?
The text was updated successfully, but these errors were encountered:
Great thought! I prefer to described_class as it helps reduce redundancy in your code.
Similar to subject, it helps DRY up your test suite. Imagine using Klass.new all over your spec suite. If you were to ever change the name of your class, you'd have to change it everywhere.
https://relishapp.com/rspec/rspec-core/docs/metadata/described-class
I recently started to use
described_class
instead of explicitly stating the class name:I didn't find any guidelines about this, so I wanted to discuss the pros and the cons of each approach.
An advantage of the former is that it looks cleaner. And I believe that the name of the method is self-evident even for those who are not familiar with RSpec's syntax.
What do you think, guys?
The text was updated successfully, but these errors were encountered: