From f04a89b3af581c8956add61e4a05edc0ae9405f5 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 12 Mar 2018 12:41:28 +0100 Subject: Move `lib/tom_tom.rb` to `lib/tom_tom/batch.rb` Separate the functionality a little better by moving the `/batch` endpoint code into a new class. The goal here is also to lay the foundation for being able to call `TomTom.batch()` instead of `TomTom.new.batch()`. Refs #6095 --- spec/lib/tom_tom/batch_spec.rb | 25 +++++++++++++++++++++++++ spec/lib/tom_tom_spec.rb | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 spec/lib/tom_tom/batch_spec.rb delete mode 100644 spec/lib/tom_tom_spec.rb (limited to 'spec') diff --git a/spec/lib/tom_tom/batch_spec.rb b/spec/lib/tom_tom/batch_spec.rb new file mode 100644 index 000000000..5aff970eb --- /dev/null +++ b/spec/lib/tom_tom/batch_spec.rb @@ -0,0 +1,25 @@ +RSpec.describe TomTom::Batch do + let(:tomtom) { TomTom::Batch.new } + + describe "#convert_way_costs_for_batch" do + it "turns WayCost points into a collection of colon-separated strings" do + way_costs = [ + WayCost.new( + departure: Geokit::LatLng.new(2, 48), + arrival: Geokit::LatLng.new(3, 46) + ), + WayCost.new( + departure: Geokit::LatLng.new(-71, 42), + arrival: Geokit::LatLng.new(-71.5, 42.9) + ) + ] + + expect( + tomtom.convert_way_costs_for_batch(way_costs) + ).to eq([ + '2,48:3,46', + '-71,42:-71.5,42.9' + ]) + end + end +end diff --git a/spec/lib/tom_tom_spec.rb b/spec/lib/tom_tom_spec.rb deleted file mode 100644 index 57f22d26a..000000000 --- a/spec/lib/tom_tom_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -RSpec.describe TomTom do - let(:tomtom) { TomTom.new } - - describe "#convert_way_costs_for_batch" do - it "turns WayCost points into a collection of colon-separated strings" do - way_costs = [ - WayCost.new( - departure: Geokit::LatLng.new(2, 48), - arrival: Geokit::LatLng.new(3, 46) - ), - WayCost.new( - departure: Geokit::LatLng.new(-71, 42), - arrival: Geokit::LatLng.new(-71.5, 42.9) - ) - ] - - expect( - tomtom.convert_way_costs_for_batch(way_costs) - ).to eq([ - '2,48:3,46', - '-71,42:-71.5,42.9' - ]) - end - end -end -- cgit v1.2.3