From 0d35ac037a081f31bf628c8f16c49030f8e0fa1f Mon Sep 17 00:00:00 2001 From: Doug Fales Date: Sat, 27 Feb 2010 16:52:21 -0700 Subject: [PATCH] Fixing some tests since git does not believe in empty directories. --- .gitignore | 1 + lib/gpx/gpx.rb | 2 +- tests/output_test.rb | 31 ++++++++++++++++++------------- tests/track_file_test.rb | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1f4afb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tests/output/* diff --git a/lib/gpx/gpx.rb b/lib/gpx/gpx.rb index 41184cd..c00d98f 100644 --- a/lib/gpx/gpx.rb +++ b/lib/gpx/gpx.rb @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ module GPX - VERSION = "0.5" + VERSION = "0.6" # A common base class which provides a useful initializer method to many # class in the GPX library. diff --git a/tests/output_test.rb b/tests/output_test.rb index 02cb290..7d15c2d 100644 --- a/tests/output_test.rb +++ b/tests/output_test.rb @@ -1,10 +1,15 @@ require 'test/unit' +require 'fileutils' require File.dirname(__FILE__) + '/../lib/gpx' class OutputTest < Test::Unit::TestCase include GPX + def setup + FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "output")) + end + def test_new_gpx_file_from_scratch gpx_file = GPXFile.new @@ -25,24 +30,24 @@ class OutputTest < Test::Unit::TestCase track_point_data.each do |trk_pt_hash| segment.points << TrackPoint.new(trk_pt_hash) - end + end track.segments << segment gpx_file.tracks << track waypoint_data = [ {:lat => 39.997298, :lon => -105.292674, :name => 'GRG-CA', :sym => 'Waypoint', :elevation => 1766.535}, - {:lat => 33.330190, :lon => -111.946110, :name => 'GRMPHX', :sym => 'Waypoint', :elevation => 361.0981, + {:lat => 33.330190, :lon => -111.946110, :name => 'GRMPHX', :sym => 'Waypoint', :elevation => 361.0981, :cmt => "Hey here's a comment.", :desc => "Somewhere in my backyard.", :fix => '3d', :sat => "8", :hdop => "50.5", :vdop => "6.8", :pdop => "7.6"}, - {:lat => 25.061783, :lon => 121.640267, :name => 'GRMTWN', :sym => 'Waypoint', :elevation => 38.09766}, - {:lat => 39.999840, :lon => -105.214696, :name => 'SBDR', :sym => 'Waypoint', :elevation => 1612.965}, - {:lat => 39.989739, :lon => -105.295285, :name => 'TO', :sym => 'Waypoint', :elevation => 2163.556}, - {:lat => 40.035301, :lon => -105.254443, :name => 'VICS', :sym => 'Waypoint', :elevation => 1535.34} - ] + {:lat => 25.061783, :lon => 121.640267, :name => 'GRMTWN', :sym => 'Waypoint', :elevation => 38.09766}, + {:lat => 39.999840, :lon => -105.214696, :name => 'SBDR', :sym => 'Waypoint', :elevation => 1612.965}, + {:lat => 39.989739, :lon => -105.295285, :name => 'TO', :sym => 'Waypoint', :elevation => 2163.556}, + {:lat => 40.035301, :lon => -105.254443, :name => 'VICS', :sym => 'Waypoint', :elevation => 1535.34} + ] waypoint_data.each do |wpt_hash| gpx_file.waypoints << Waypoint.new(wpt_hash) - end + end route_point_data = [ {:lat => 40.035467, :lon =>-105.254366, :time => Time.parse("2005-12-31T22:02:29Z"), :elevation => 1735.798}, @@ -52,7 +57,7 @@ class OutputTest < Test::Unit::TestCase route = Route.new() route_point_data.each do |rte_pt_hash| route.points << Point.new(rte_pt_hash) - end + end gpx_file.routes << route @@ -73,19 +78,19 @@ class OutputTest < Test::Unit::TestCase trk_pt_hash.each do |key, value| assert_equal(value, written_segment.points[index].send(key)) end - end + end # Make sure the one route has the attributes we initialized it with assert_equal(1, written_gpx_file.routes.size) - written_route = written_gpx_file.routes[0] + written_route = written_gpx_file.routes[0] assert_equal(route_point_data.size, written_route.points.size) route_point_data.each_with_index do |rte_pt_hash, index| rte_pt_hash.each do |key, value| assert_equal(value, written_route.points[index].send(key)) end - end + end # Make sure the waypoints have all of the attributes we initialized them with written_waypoints = written_gpx_file.waypoints @@ -93,7 +98,7 @@ class OutputTest < Test::Unit::TestCase waypoint_data.each_with_index do |wpt_hash, index| wpt_hash.each do |key, value| assert_equal(value, written_waypoints[index].send(key.to_s), key) - end + end end expected_value = sprintf(THE_WORKS, gpx_file.time.xmlschema) diff --git a/tests/track_file_test.rb b/tests/track_file_test.rb index aa6f72f..1e8068d 100644 --- a/tests/track_file_test.rb +++ b/tests/track_file_test.rb @@ -69,7 +69,7 @@ class TrackFileTest < Test::Unit::TestCase end def test_write - @other_track_file.write("myoutput.gpx") + @other_track_file.write("tests/output/myoutput.gpx") end end