How do i write unit test without writing the validations? Is it possible
to write the unit test or functional test before writing the validation
and controller code?
manjula
--
Posted via http://www.ruby-forum.com/.
>
> Hi,
>
> How do i write unit test without writing the validations? Is it
> possible
> to write the unit test or functional test before writing the
> validation
> and controller code?
You can definitely write a test without having written the controller/
model code. Obviously the test should at that point fail (if not your
test is broken).
People sometimes call this test-first development. It does require
that you think about what your model should be doing before having
actually written it (which in my book is a good thing).
Fred
how do i write the test case for checking the length.
def test_for_ssn_no
contact = Contact.new
contact.ssn_no = '-123f4'
assert !contact.valid?
assert_equal '-123f456e7t', contact.ssn_no, "Pass"
end
This is my test case. I want to check the length of ssn_no should be not
more than 10 digits. How do i write. And the above code is the right
way to write the test case? Please help me out to write a good test
cases.