to RSpec or not to RSpec

I took another look at RSpec today. I tried to re-write the script using a test driven development method but am finding it harder to use than expected. I think I just have to shift my brain into programming TDD style. I really didn’t come up with any good code, I must have started over at least 10 times. I started with things like it “should accept a parameter –operation that takes either ‘add’ or ‘sub’ as it’s value” Then I would read RSpec docs and try to test tha…needless to say it’s a good way to learn about RSpec albeit rather slow. Hopefully I can move my brain to this new style of thinking. It seemed so easy at first but once you try it, it’s actually kind of difficult to do.

Here is the list of requirements I’m going to be working off of.

  • it “should accept two parameters, an operation that is either add or sub and a time value formatted at least with one digit. It should also accept two arguments, an in_file and na out_file”
  • it “should add or subtract time based on the set operation”
  • it “should modify the time by the amount passed in as a parameter of –time”
  • it “should read times and all other lines from the first file”
  • it “should write modified times and unmodified other lines to the second file”

IF you can get these tests to pass, then you’ve got yourself a working program and RSpec test to go with it as well as some documentation!

Until next time…


1 Response to “to RSpec or not to RSpec”

  1. October 5, 2009 at 6:46 am


    I just started learning Ruby with the RPCFN as well. Over the past year I’ve begun to follow a very strong TDD approach for my day job which involves coding in C#. When I began my Ruby script for RPCFN I got caught up on two things: project structure and unit tests.

    I didn’t solve the project structure problem, but I did learn just how much more expressive RSpec can be than standard unit tests with less effort in making them so.

    Now just to learn a little more about rake and git and I think I’ll have enough knowledge to be dangerous.

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


How often I post

October 2009
« Sep   Dec »

This is everything


%d bloggers like this: