From 4c208254573c3428d82bd8744860bd86e1c78acb Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 18:38:23 +0200 Subject: applies new string literal convention in activemodel/test The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default. --- .../validations/numericality_validation_test.rb | 78 +++++++++++----------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'activemodel/test/cases/validations/numericality_validation_test.rb') diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index 74a048537d..742a9fc679 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -1,10 +1,10 @@ -require 'cases/helper' +require "cases/helper" -require 'models/topic' -require 'models/person' +require "models/topic" +require "models/person" -require 'bigdecimal' -require 'active_support/core_ext/big_decimal' +require "bigdecimal" +require "active_support/core_ext/big_decimal" class NumericalityValidationTest < ActiveModel::TestCase @@ -68,119 +68,119 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_greater_than Topic.validates_numericality_of :approved, greater_than: 10 - invalid!([-10, 10], 'must be greater than 10') + invalid!([-10, 10], "must be greater than 10") valid!([11]) end def test_validates_numericality_with_greater_than_using_differing_numeric_types - Topic.validates_numericality_of :approved, greater_than: BigDecimal.new('97.18') + Topic.validates_numericality_of :approved, greater_than: BigDecimal.new("97.18") - invalid!([-97.18, BigDecimal.new('97.18'), BigDecimal('-97.18')], 'must be greater than 97.18') - valid!([97.18, 98, BigDecimal.new('98')]) # Notice the 97.18 as a float is greater than 97.18 as a BigDecimal due to floating point precision + invalid!([-97.18, BigDecimal.new("97.18"), BigDecimal("-97.18")], "must be greater than 97.18") + valid!([97.18, 98, BigDecimal.new("98")]) # Notice the 97.18 as a float is greater than 97.18 as a BigDecimal due to floating point precision end def test_validates_numericality_with_greater_than_using_string_value Topic.validates_numericality_of :approved, greater_than: 10 - invalid!(['-10', '9', '9.9', '10'], 'must be greater than 10') - valid!(['10.1', '11']) + invalid!(["-10", "9", "9.9", "10"], "must be greater than 10") + valid!(["10.1", "11"]) end def test_validates_numericality_with_greater_than_or_equal Topic.validates_numericality_of :approved, greater_than_or_equal_to: 10 - invalid!([-9, 9], 'must be greater than or equal to 10') + invalid!([-9, 9], "must be greater than or equal to 10") valid!([10]) end def test_validates_numericality_with_greater_than_or_equal_using_differing_numeric_types - Topic.validates_numericality_of :approved, greater_than_or_equal_to: BigDecimal.new('97.18') + Topic.validates_numericality_of :approved, greater_than_or_equal_to: BigDecimal.new("97.18") - invalid!([-97.18, 97.17, 97, BigDecimal.new('97.17'), BigDecimal.new('-97.18')], 'must be greater than or equal to 97.18') - valid!([97.18, 98, BigDecimal.new('97.19')]) + invalid!([-97.18, 97.17, 97, BigDecimal.new("97.17"), BigDecimal.new("-97.18")], "must be greater than or equal to 97.18") + valid!([97.18, 98, BigDecimal.new("97.19")]) end def test_validates_numericality_with_greater_than_or_equal_using_string_value Topic.validates_numericality_of :approved, greater_than_or_equal_to: 10 - invalid!(['-10', '9', '9.9'], 'must be greater than or equal to 10') - valid!(['10', '10.1', '11']) + invalid!(["-10", "9", "9.9"], "must be greater than or equal to 10") + valid!(["10", "10.1", "11"]) end def test_validates_numericality_with_equal_to Topic.validates_numericality_of :approved, equal_to: 10 - invalid!([-10, 11] + INFINITY, 'must be equal to 10') + invalid!([-10, 11] + INFINITY, "must be equal to 10") valid!([10]) end def test_validates_numericality_with_equal_to_using_differing_numeric_types - Topic.validates_numericality_of :approved, equal_to: BigDecimal.new('97.18') + Topic.validates_numericality_of :approved, equal_to: BigDecimal.new("97.18") - invalid!([-97.18, 97.18], 'must be equal to 97.18') - valid!([BigDecimal.new('97.18')]) + invalid!([-97.18, 97.18], "must be equal to 97.18") + valid!([BigDecimal.new("97.18")]) end def test_validates_numericality_with_equal_to_using_string_value Topic.validates_numericality_of :approved, equal_to: 10 - invalid!(['-10', '9', '9.9', '10.1', '11'], 'must be equal to 10') - valid!(['10']) + invalid!(["-10", "9", "9.9", "10.1", "11"], "must be equal to 10") + valid!(["10"]) end def test_validates_numericality_with_less_than Topic.validates_numericality_of :approved, less_than: 10 - invalid!([10], 'must be less than 10') + invalid!([10], "must be less than 10") valid!([-9, 9]) end def test_validates_numericality_with_less_than_using_differing_numeric_types - Topic.validates_numericality_of :approved, less_than: BigDecimal.new('97.18') + Topic.validates_numericality_of :approved, less_than: BigDecimal.new("97.18") - invalid!([97.18, BigDecimal.new('97.18')], 'must be less than 97.18') - valid!([-97.0, 97.0, -97, 97, BigDecimal.new('-97'), BigDecimal.new('97')]) + invalid!([97.18, BigDecimal.new("97.18")], "must be less than 97.18") + valid!([-97.0, 97.0, -97, 97, BigDecimal.new("-97"), BigDecimal.new("97")]) end def test_validates_numericality_with_less_than_using_string_value Topic.validates_numericality_of :approved, less_than: 10 - invalid!(['10', '10.1', '11'], 'must be less than 10') - valid!(['-10', '9', '9.9']) + invalid!(["10", "10.1", "11"], "must be less than 10") + valid!(["-10", "9", "9.9"]) end def test_validates_numericality_with_less_than_or_equal_to Topic.validates_numericality_of :approved, less_than_or_equal_to: 10 - invalid!([11], 'must be less than or equal to 10') + invalid!([11], "must be less than or equal to 10") valid!([-10, 10]) end def test_validates_numericality_with_less_than_or_equal_to_using_differing_numeric_types - Topic.validates_numericality_of :approved, less_than_or_equal_to: BigDecimal.new('97.18') + Topic.validates_numericality_of :approved, less_than_or_equal_to: BigDecimal.new("97.18") - invalid!([97.18, 98], 'must be less than or equal to 97.18') - valid!([-97.18, BigDecimal.new('-97.18'), BigDecimal.new('97.18')]) + invalid!([97.18, 98], "must be less than or equal to 97.18") + valid!([-97.18, BigDecimal.new("-97.18"), BigDecimal.new("97.18")]) end def test_validates_numericality_with_less_than_or_equal_using_string_value Topic.validates_numericality_of :approved, less_than_or_equal_to: 10 - invalid!(['10.1', '11'], 'must be less than or equal to 10') - valid!(['-10', '9', '9.9', '10']) + invalid!(["10.1", "11"], "must be less than or equal to 10") + valid!(["-10", "9", "9.9", "10"]) end def test_validates_numericality_with_odd Topic.validates_numericality_of :approved, odd: true - invalid!([-2, 2], 'must be odd') + invalid!([-2, 2], "must be odd") valid!([-1, 1]) end def test_validates_numericality_with_even Topic.validates_numericality_of :approved, even: true - invalid!([-1, 1], 'must be even') + invalid!([-1, 1], "must be even") valid!([-2, 2]) end @@ -201,8 +201,8 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_other_than_using_string_value Topic.validates_numericality_of :approved, other_than: 0 - invalid!(['0', '0.0']) - valid!(['-1', '1.1', '42']) + invalid!(["0", "0.0"]) + valid!(["-1", "1.1", "42"]) end def test_validates_numericality_with_proc -- cgit v1.2.3