How to name RSpec describe blocks for methods

So far our convention has been

  describe :method_name do 
    ...
  end

But this has some obvious drawback like separation of instance/class methods.
I hope we can now all agree on the unambiguous convention Mr Heinrich found in a great rspec presentation:

  • use “description” for non-methods
  • use pound “#method” for instance methods
  • use dot “.method” for class methods

This also makes prettier specdoc output ๐Ÿ™‚

3 thoughts on “How to name RSpec describe blocks for methods

  1. I don’t understand the use of `.`. It’s ambiguous. Since the inception of RDoc, `::` has been used to denote a class method and `#` has been used to denote an instance method. Why not follow these pre-existing and ubiquitous standards in the testing suite?

  2. Yes that would be totally valid and maybe more consistent. I mostly because I hate using “::” for static method calls and don’t want to further encourage it or expose any user to it ๐Ÿ™‚

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s