I've wanted to improve my testing for some time now and so I'm pairing on the RSpec book with my friend,
Allan Miller. We're going to work through the book/examples in tandem and get together regularly to review what we've learned. We just downloaded
the RSpec book by Pragmatic and assigned Chapters 1-3 (this is the book that was highly recommended by our
Ruby Meetup folks). We'll work through this and then meet in a couple of days to see how things went and move on to the next group of chapters.
For now, I'm running all this on my MacBook, without any IDE... just straight terminal access and MacVIM. Chapters 1 & 2 are introduction; chapter 3 is where you start actually doing stuff.
First problem (minor) that I ran into was that the rspec installation wasn't clean; I got the following errors:
Successfully installed rspec-1.2.8
1 gem installed
Installing ri documentation for rspec-1.2.8...
Installing RDoc documentation for rspec-1.2.8...
Could not find main page README.rdoc
Could not find main page README.rdoc
Could not find main page README.rdoc
Could not find main page README.rdoc
So far, this doesn't seem to have affected anything -- I just ignored it and moved on (so far, I don't use the ri or RDoc information at all).
The cucumber installation was a little more disconcerting:
Installing ri documentation for builder-2.1.2...
ERROR: While generating documentation for builder-2.1.2
... MESSAGE: Unhandled special: Special: type=17, text=""
... RDOC args: --ri --op /Library/Ruby/Gems/1.8/doc/builder-2.1.2/ri --title Builder -- Easy XML Building --main README --line-numbers --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-2.1.2 Documentation
(continuing with the rest of the installation)
but again, it was only documentation so I moved on from here as well (have to pick your battles, you know).
Everything went just fine, except for a couple of glitches: one was just some missing default snippets and the other was a result of those missing snippets. Here's what happened:
- The first attempt at cucumber did NOT display the snippets for the 3 undefined steps (pp 27-28 in my beta copy of the book) as expected. Rather than being able to copy and modify them I had to type them in by hand. [I tried the command twice just to make sure.. sure enough, didn’t display, although a later point where I had only one step undefined, it DID display the snippet template. Go figure.]
- Because of #1, I made a transcription error in the regexp for step 3: I omitted the ‘^’ exclusion character. This cost me several minutes (regexp’s are like that!). I have a feeling that there may be more of these... hopefully I’ll be able to get the step snippets more reliably in the future and then just copy them into my step definitions as a starting point.
All in all, a successful beginning... But I do have a concern -- given that we're using regexp's, there are MANY opportunities for small errors that can cost time. Seems like a bit of a contradiction: cucumber is a "higher level" testing language than rspec, but it uses one of the lowest level syntaxes to accomplish this.
I'll just have to wait and see what this leads to... and I'm sure going to copy/paste those snippets whenever I can.
7 comments: