From 6ac5c6d42a4e08a0b24049f3105587b66f3dffe9 Mon Sep 17 00:00:00 2001 From: Thomas Ritter Date: Mon, 22 Jul 2019 19:37:24 +0200 Subject: [PATCH] Trip exercise, initial slightly changed version --- .ruby-version | 1 + trip_exercise.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .ruby-version create mode 100644 trip_exercise.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..ec1cf33 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.6.3 diff --git a/trip_exercise.rb b/trip_exercise.rb new file mode 100644 index 0000000..4c04b48 --- /dev/null +++ b/trip_exercise.rb @@ -0,0 +1,50 @@ +require "minitest/autorun" + +################################################################################ +# Tests + +class TravelTest < Minitest::Test + def self.test_order + :sorted + end + + def test_location + skip # Remove this 'skip' instruction if you want to run the test + + paris = Location.new("Paris", "French", "Euro") + + assert_equal "Paris", paris.name + assert_equal "French", paris.language + assert_equal "Euro", paris.currency + end + + def test_trip_to_paris + skip # Remove this 'skip' instruction if you want to run the test + + zurich = Location.new("Zurich", "Swiss-German", "Swiss francs") + paris = Location.new("Paris", "French", "Euro") + trip = Trip.new(zurich) + trip.add_stop(paris) + + assert_equal ["Zurich", "Paris", "Zurich"], trip.itinerary + assert_equal ["Euro"], trip.foreign_currencies + end + + def test_longer_trip + skip # Remove this 'skip' instruction if you want to run the test + + trip = Trip.new(Location.new("Zurich", "Swiss-German", "Swiss francs")) + trip.add_stop(Location.new("Milan", "Italian", "Euro")) + trip.add_stop(Location.new("Zagreb", "Croatian", "Kuna")) + trip.add_stop(Location.new("Budapest", "Hungarian", "Forint")) + trip.add_stop(Location.new("Vienna", "German", "Euro")) + + assert_equal ["Zurich", "Milan", "Zagreb", "Budapest", "Vienna", "Zurich"], trip.itinerary + assert_equal ["Euro", "Kuna", "Forint"], trip.foreign_currencies + end +end + +################################################################################ +# Code under test + +# TODO: Implement the code that makes the tests pass here!