Hi –
On 3/17/07, MichaelLatta [email protected] wrote:
I would add to that:
- If you do not test it, you do not know if it works. Yes there are
tests of Rails itself, but not of your use of Rails.
Yes – that’s what I mean about not testing validates_format_of
itself, but testing what you want your application to do, and if what
you want it to do involves calling validates_format_of, then the test
will fail if v_f_of is broken.
- The comment I have seen and come to believe is that if it is not
tested then it is not guaranteed to work. The tests define what
“work” is.
That still leaves the question: at what point can we consider x to
have been tested?
On a small project the programmer may know all the requirements and
remember them at all times, and always get it right.
But, even on a 2 man project it helps to build tests for what you
expect the software to do.
I think testing is good even if you’re working alone on a project. But
that’s for another discussion
The application tests will only test the cases that matter to the
applicaiton, while the Rails tests test all the cases the framwork
supports. But, you never know if the Rails tests cover the one case
you care about.
I think you can usually assume it doesn’t. But it’s still a question
of what point you hand off the responsibility to the framework – or
the language. I don’t have any code that specifically tests
String#capitalize, even though I use it and Rails uses it, because I
assume that there are tests in place that test it, in both the Ruby
and the Rails test suites. But if I have a method called title_case,
or something, I’ll test that, and if it fails then I can investigate
where it went wrong.
All of this relates, also, to the use of tests as an anchor for
refactoring. The fact that my title_case method uses capitalize is
incidental, just as it’s incidental that I prevent people from having
too-short passwords by using validates_size_of. There are other ways
to do these things, so it’s really a matter of testing for
functionality (I’ll let someone else be the one to introduce the word
‘behavior’ into the thread rather than implementation.
David
–
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)