aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorTeddy Wing2018-04-05 15:37:42 +0200
committerTeddy Wing2018-04-05 15:37:42 +0200
commitbfb194c5294c583dbf0bc0bef78b67d64a3a4f4c (patch)
tree5ce7cc6ad0f3e21c3d72cc03934bbe1ac0dbe70e /spec/lib
parented5133f444f2dd5940d1408b0ca988e01c582ef0 (diff)
downloadchouette-core-bfb194c5294c583dbf0bc0bef78b67d64a3a4f4c.tar.bz2
RouteWayCostUnitConverter: Snap values between 0–1 to 16404-way-costs--snap-distance-and-time-to-1-when-between-0-a
We use integer values for distance (kilometres) and time (minutes). If the values aren't very big, like bus stops inside a city for example, the integer conversion will put distance and time at `0`, which isn't correct. To continue to use our chosen measurement units while still displaying something that makes sense to users, snap any values >0 and <=1 to `1`. Refs #6404
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/route_way_cost_unit_converter_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/route_way_cost_unit_converter_spec.rb b/spec/lib/route_way_cost_unit_converter_spec.rb
index 3c5e51710..aa25d57d2 100644
--- a/spec/lib/route_way_cost_unit_converter_spec.rb
+++ b/spec/lib/route_way_cost_unit_converter_spec.rb
@@ -35,4 +35,32 @@ RSpec.describe RouteWayCostUnitConverter do
})
end
end
+
+ describe ".meters_to_kilometers" do
+ it "converts meters to integer kilometres" do
+ expect(
+ RouteWayCostUnitConverter.meters_to_kilometers(6350)
+ ).to eq(6)
+ end
+
+ it "snaps values between 0 and 1 to 1" do
+ expect(
+ RouteWayCostUnitConverter.meters_to_kilometers(50)
+ ).to eq(1)
+ end
+ end
+
+ describe ".seconds_to_minutes" do
+ it "converts seconds to minutes" do
+ expect(
+ RouteWayCostUnitConverter.seconds_to_minutes(300)
+ ).to eq(5)
+ end
+
+ it "snaps values between 0 and 1 to 1" do
+ expect(
+ RouteWayCostUnitConverter.seconds_to_minutes(3)
+ ).to eq(1)
+ end
+ end
end