New Website Step 0 – Understanding RSpec
The more alert among you will have noticed that my “work one day, post the next” regarding my new project has pretty much fallen dead. I’ve found this “testing” thing fairly difficult to get into. Part of it is just the syntax or rspec, some of it is just the mindset required to to Test Driven Development.
- RSpec syntax takes a bit to get used to
- RSpec philosphies take a bit to get used to…. understanding the :before block, lets, contexts, descriptions, and subjects are all great, but it’s even better to have an idea about the best practices associated with them
- The overall idea of TDD. Do you want to test the actions that a user is taking? IE: “Create an object”, “alter an object”. Or do you test each individual function in the system? IE: new() create() destroy(), etc. If the latter, are you expected to test all the functions you don’t create, ie: the built in object methods that you get when you have any class?
- How far do you take TDD if you’re just trying to get a 3 function class off the ground?
Luckily the test-driven @dkubb was there to help me out a bit, and gave me this nice setup to start with. This let me see the proper (or at least how Dan did it) setup for where a context/let/description/etc block goes. All good stuff.
Now I have a model (so to speak) I can work from, so now I can finally get off my ass and get some code written. Dan’s philosphy is that if you code for more than a few minutes at a time you’re doing something wrong, and you should be testing, coding, testing, coding and then doing some more testing before you do more coding.
No related posts.
June 19th, 2010 at 3:30 am
I ran into similar problems a couple weeks ago, i found rspec’s dsl less intuitive than test units and their documentation is lacking/geared towards more experienced testers, but after pairing with someone who had used it a lot it really helped me get my head around some of the concepts.