> If I use a constant '01/01/07 - 01/01/08' there is no problem, but I need 
> some way to deal with the dates in the parameters.

escape the slashes:   /01\/01\/07/ - 01\/01\/08/

That said, anytime I deal with dates, I usually try to make them
actual date objects, then I can assert interesting things about when
stuff happens.  I made a demo, I hope this helps.

#####################################
require 'parsedate'
require 'test/unit'

class TC_Date < Test::Unit::TestCase
def test_date

#TEST DATA
arr_date = "01/01/07"
dep_date = "01/10/07"

#DATA FOUND IN THE APP
found_arr_date = "01/01/07"
#CHANGE YEAR TO "07" TO PASS TEST 2, CHANGE MONTH TO "10" TO PASS TEST 3
found_dep_date = "01/09/06"

#GET THE RAW ELEMENTS OF THE DATE
arr = ParseDate.parsedate(arr_date)
dep = ParseDate.parsedate(dep_date)
found_arr = ParseDate.parsedate(found_arr_date)
found_dep = ParseDate.parsedate(found_dep_date)

#TURN THE RAW ELEMENTS INTO DATE OBJECTS FOR COMPARISON
arr_obj = Time.local(*arr)
dep_obj = Time.local(*dep)
found_arr_obj = Time.local(*found_arr)
found_dep_obj = Time.local(*found_dep)

#TEST 1:  JUST SHOWING WHAT A PASSING TEST LOOKS LIKE
assert_equal(arr_obj,found_arr_obj)

#TEST 2:  ASSERT THAT WE'RE LEAVING LATER THAN WE'RE ARRIVING
assert(found_dep_obj >= found_arr_obj,"leaving before we arrive!
#{found_dep_obj} is less than #{found_arr_obj}")

#TEST 3:  ASSERT THAT OUR TEST DATE MATCHES THE DATE IN THE APP
assert_equal((dep_obj - arr_obj),(found_dep_obj - found_arr_obj))

end
end
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to