1. Jan 30th, 2007

    RSpec better than sliced bread with olive tapenade

    context "Blog post" do
      specify "should be fun to read" do
        words.size.should_be < 500
        images.should_not_be_empty
        reader.should_respond_to :post
      end
    end

    I just started using RSpec, and loving every minute of it.

    The first few test cases felt a bit weird. Badly written English in the passive voice: this.should_be_that. Enough shoulds to drive any English major nuts.

    But I like the fact that my test cases look the opposite of my code. And somehow, they end up shorter and more fun to write than assertions. I can’t explain why, I just know with test cases, every bit of motivation helps.

    This one is a keeper.

    1. Jan 30th, 2007

      Ryan Garver

      I will certainly agree with you: rSpec is a beautiful framework. I should warn anyone else looking at this as a solution. This is not for the impatient or claustrophobic. There is a bit of a learning curve which is steeper if you are trying to integrate with Rails (don’t try this for the first time if you are in a rush). Also, rSpec code often grows uncontrollably; it has a beautiful code structure (which I and others would like to see extended) but if you aren’t careful about your file/directory structure the spec files can start to run long and verbose and end up difficult to navigate. I’m eager to hear more about your work with this, and I hope that is works well for you.

      …And please tell me that I’m silly and that there is an obvious way to organize my specs without infinite growth.

    2. Jan 30th, 2007

      Sterling Camden

      Wow!

    3. Jan 30th, 2007

      Assaf

      In the project I’m working on right now, there’s one test file per code file, mirroring the same organization of features. That happens to work very well for this particular project, but in other projects I can see whey there might need to be “meta contexts”. A file that includes several related contexts that are not specific to one source file, class or module.

      Inside each file, I create contexts for entities and their properties, and group them by entities, a few blank lines between each pair of contexts to make them easy to find.

      Entities and properties sometimes map to model/attributes, but not always. For example, I have a test case for project, and separate one for sub-project. They both come from the same class, but behavior-wise, you can say different things about each one.

      I would consider a user name an interesting property, so a “user name” context. Password? Not so much, but another interesting property of user is the username/password combination, or the “user credentials” context.

    4. Jan 31st, 2007

      Chipping the web – something smells — Chip’s Quips

      [...] Assaf turned me on to RSpec: “a framework for practicing Behaviour Driven Development (BDD) in Ruby”. Outstanding. [...]

    5. Mar 1st, 2007

      Little Money

      Do you guys recommend using rSpec framework?

    6. Mar 1st, 2007

      Assaf

      After a month of working with RSpec, my answer is: ABSOLUTELY!

    Your comment, here ⇓