On Nov 19, 3:08 pm, “David C.” [email protected] wrote:
do just fine.
nullifies or somehow challenges a previous requirement.
Thanks. This thread has been even more fruitful than I expected. I
truly understand why “should” has been used. Not to say “must” and
others are wrong, of course, but I see how the perspective of
anticipation of code-to-be lends to the use of word “should”. It
occurs to me that “expect” is also a good word form this perspective;
and interestingly we see that term being used in both TDD and BDD.
Something else I noticed. Originally I wanted reuse the word “assert”
–I like the word. So instead of ‘should’ I defined a helper to do:
e.assert == r
Now, with this new perspective, I figure I’d go ahead and use #should.
When I went to convert it however it didn’t quite come out as I
expected, because I had put the expectation first and the actualized
result last. Ie.
expected.should == result
While this is OK, it doesn’t quite translate. It reads much better:
result.should == expected
That’s how we talk about these things.
But then it hits me, trying to make this read well has led to a
potential issue. In Ruby equality is tested by the receiver. If we
make result the receiver then it is the one deciding if it is equal to
the expected. But a robust implementation would have the expected
I realize this is small minutia to the overall issues involved, but I
thought it was an interesting point nonetheless. It would seem, the
way in which we speak and think about things cannot necessarily be
reflected in the way we write our code.