Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually, quite to the contrary, I think it's more semantic. What you probably don't know is that `Foo#bar` is the way of describing an instance method `bar` in class `Foo` and `Foo.bar` is a class method. RSpec's `describe` announces what unit of code you're writing specs for and `context` (although functionally equivalent to `describe`) is used to enumerate the different contexts in which you're going to test a method.

A typical spec looks like this:

    describe Foo do
      describe "#bar" do
        # specs for Foo#bar ...
      end

      describe ".baz" do
        # specs for Foo.baz ...
      end
    end
The reason I say that using the method names for `describe` is more semantic is because it says exactly what you're describing. Also, as a side note, RSpec is smart enough to realize that "#bar" or ".baz" are referring to methods. In the above example, a spec for `Foo#bar` would be described like this: "Foo#bar should return 42". That's the description that is printed out when the spec fails or if you use a long-form output formatter.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: