elsifincorrect_accuracy||value.to_d!=value.to_i# if the user enters a value in exponent notation (eg '4e1') the to_i method does not convert this to the correct value
it"does not add an error if input is an integer"do
it"does not add an error if input is an integer"do
sales_log.income1=30_000
sales_log.income1=30_000
shared_validator.validate_numeric_step(sales_log)
shared_validator.validate_numeric_step(sales_log)
@ -136,6 +142,12 @@ RSpec.describe Validations::SharedValidations do
expect(sales_log.errors[:savings]).toincludeI18n.t("validations.numeric.nearest_ten",field:"Buyer’s total savings (to nearest £10) before any deposit paid")
expect(sales_log.errors[:savings]).toincludeI18n.t("validations.numeric.nearest_ten",field:"Buyer’s total savings (to nearest £10) before any deposit paid")
end
end
it"adds an error if the user attempts to input a number in exponent format"do
sales_log.savings="3e5"
shared_validator.validate_numeric_step(sales_log)
expect(sales_log.errors[:savings]).toincludeI18n.t("validations.numeric.nearest_ten",field:"Buyer’s total savings (to nearest £10) before any deposit paid")
end
it"does not add an error if input is a multiple of ten"do
it"does not add an error if input is a multiple of ten"do
sales_log.savings=30_000
sales_log.savings=30_000
shared_validator.validate_numeric_step(sales_log)
shared_validator.validate_numeric_step(sales_log)
@ -150,6 +162,12 @@ RSpec.describe Validations::SharedValidations do