When I first heard about the change from context/specify to describe/
it, I thought it was completely bone-headed. A quick glance at an
example changed my mind, but I still don’t feel good about ‘it’.
Considering the number of specifications that will start with
‘should’, why not use — oh I don’t know, ‘should’?
describe Bowling do
before(:each) do @bowling = Bowling.new
end
should “score 0 for gutter game” do
20.times { @bowling.hit(0) } @bowling.score.should == 0
end
end
I must admit that until this thread it had never occurred to me to
use instance_eval for this, even though it’s bloody obvious the
moment you see it written down. I’ll probably roll it into a
framework I’m currently working on and see how it compares to its VB
prototype: it is the one statement I miss from that particular
language as it saves so much unnecessary typing and some runtime
overhead (classic VB’s object model being built on top of COM, the
cost of runtime method lookup on deeply nested objects can be
prohibitive on older hardware).
PS: Thanks for teaching me another British(?) English idiom -
hadn’t known “by dint of” so far.