From 0a1da88d74725d0da48a7526227e349077977623 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Wed, 13 Sep 2023 10:48:26 +1000 Subject: [PATCH] Adjust specs for OH4.1 QuantityType changes Signed-off-by: Jimmy Tanagra --- spec/openhab/core/types/quantity_type_spec.rb | 3 ++- spec/openhab/dsl_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/openhab/core/types/quantity_type_spec.rb b/spec/openhab/core/types/quantity_type_spec.rb index e1bfa993fd..a2525e3142 100644 --- a/spec/openhab/core/types/quantity_type_spec.rb +++ b/spec/openhab/core/types/quantity_type_spec.rb @@ -11,7 +11,8 @@ # quantity type operand expect(QuantityType.new("50 °F") + QuantityType.new("50 °F")).to eql QuantityType.new("100.0 °F") expect(QuantityType.new("50 °F") - QuantityType.new("25 °F")).to eql QuantityType.new("25.0 °F") - expect((QuantityType.new("100 °F") / QuantityType.new("2 °F")).to_i).to be 50 + # @deprecated OH4.0 result of 50. OH 4.1 will result in 1. see https://github.com/openhab/openhab-core/pull/3792 + expect((QuantityType.new("100 °F") / QuantityType.new("2 °F")).to_i).to be(50).or be(1) expect(QuantityType.new("50 °F") + -QuantityType.new("25 °F")).to eql QuantityType.new("25.0 °F") # numeric operand diff --git a/spec/openhab/dsl_spec.rb b/spec/openhab/dsl_spec.rb index 2b4c92432a..1c3c629a58 100644 --- a/spec/openhab/dsl_spec.rb +++ b/spec/openhab/dsl_spec.rb @@ -256,7 +256,9 @@ expect((c + f).format("%.1f %unit%")).to eq "44.1 °C" expect(f - 2 < 20).to be true expect(2 + c == 25).to be true - expect(2 * c == 46).to be true + # @deprecated OH4.0 result = 46. OH4.1 result = 319.15 °C + # this behavior changed since OH4.1.0.M1 see https://github.com/openhab/openhab-core/pull/3792 + expect(2 * c).to eq(46).or eq(319.15 | "°C") expect((2 * (f + c) / 2) < 45).to be true expect([c, f, 2].min).to be 2 end