G
gwtmp01
The rSpec tutorial (http://rspec.rubyforge.org/tutorials/stack_03.html)
shows a new spec as:
context "A stack with one item" do
specify "should return top when you send it 'top'" do
end
end
This empty context and empty spec 'passes', i.e. there are no failures
to report.
I don't pretend to be a TDD or BDD guru at all but in TDD
documentation I've
often seen the suggestion that a newly written test (i.e., a test for
a feature or behavior that hasn't been implemented yet) should fail.
You then implement the feature and know you have done so when the
test passes.
Two questions for any BDD or rSpec gurus:
1) Why does the tutorial suggest a two step process of
writing an empty spec, testing, and then going back and adding
expectations,
and finally testing again? Perhaps this is just because it is a
tutorial?
2) Why aren't specifications with no expectations flagged as
'failures' by
the rSpec test runner 'spec'?
I've already been burned by the second situation where I put code in the
specification but didn't actually call one of the expectation
methods. I
thought my implementation was matching the spec but in fact my spec had
no expectations. It was impossible for the implementation to not meet
the spec.
Gary Wright
shows a new spec as:
context "A stack with one item" do
specify "should return top when you send it 'top'" do
end
end
This empty context and empty spec 'passes', i.e. there are no failures
to report.
I don't pretend to be a TDD or BDD guru at all but in TDD
documentation I've
often seen the suggestion that a newly written test (i.e., a test for
a feature or behavior that hasn't been implemented yet) should fail.
You then implement the feature and know you have done so when the
test passes.
Two questions for any BDD or rSpec gurus:
1) Why does the tutorial suggest a two step process of
writing an empty spec, testing, and then going back and adding
expectations,
and finally testing again? Perhaps this is just because it is a
tutorial?
2) Why aren't specifications with no expectations flagged as
'failures' by
the rSpec test runner 'spec'?
I've already been burned by the second situation where I put code in the
specification but didn't actually call one of the expectation
methods. I
thought my implementation was matching the spec but in fact my spec had
no expectations. It was impossible for the implementation to not meet
the spec.
Gary Wright