From 0c07bfb039b0fe9f9863e885ee3885e48f3b39d9 Mon Sep 17 00:00:00 2001 From: Teo Ljungberg Date: Wed, 27 Dec 2017 17:20:02 +0100 Subject: [PATCH] Use `BigDecimal()` over `BigDecimal.new` As the latter is deprecated since: ruby/bigdecimal@5337373 --- .../active_model/validate_absence_of_matcher.rb | 2 +- .../active_model/validate_inclusion_of_matcher.rb | 2 +- .../validate_inclusion_of_matcher_spec.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb index 1c33816c0..f663f55e8 100644 --- a/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb @@ -105,7 +105,7 @@ def value else case column_type when :integer, :float then 1 - when :decimal then BigDecimal.new(1, 0) + when :decimal then BigDecimal(1, 0) when :datetime, :time, :timestamp then Time.now when :date then Date.new when :binary then '0' diff --git a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb index 717eecc95..4b96be052 100644 --- a/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb @@ -270,7 +270,7 @@ def validate_inclusion_of(attr) class ValidateInclusionOfMatcher < ValidationMatcher ARBITRARY_OUTSIDE_STRING = 'shoulda-matchers test string' ARBITRARY_OUTSIDE_INTEGER = 123456789 - ARBITRARY_OUTSIDE_DECIMAL = BigDecimal.new('0.123456789') + ARBITRARY_OUTSIDE_DECIMAL = BigDecimal('0.123456789') ARBITRARY_OUTSIDE_DATE = Date.jd(9999999) ARBITRARY_OUTSIDE_DATETIME = DateTime.jd(9999999) ARBITRARY_OUTSIDE_TIME = Time.at(9999999999) diff --git a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb index dfe895e1a..a5efb15e5 100644 --- a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb @@ -107,18 +107,18 @@ def validation_matcher_scenario_args context 'against a decimal attribute' do it_behaves_like 'it supports in_array', possible_values: [1.0, 2.0, 3.0, 4.0, 5.0].map { |number| - BigDecimal.new(number.to_s) + BigDecimal(number.to_s) }, - zero: BigDecimal.new('0.0'), + zero: BigDecimal('0.0'), reserved_outside_value: described_class::ARBITRARY_OUTSIDE_DECIMAL it_behaves_like 'it supports in_range', - possible_values: BigDecimal.new('1.0') .. BigDecimal.new('5.0'), - zero: BigDecimal.new('0.0') + possible_values: BigDecimal('1.0') .. BigDecimal('5.0'), + zero: BigDecimal('0.0') def build_object(options = {}, &block) build_object_with_generic_attribute( - options.merge(column_type: :decimal, value: BigDecimal.new('1.0')), + options.merge(column_type: :decimal, value: BigDecimal('1.0')), &block ) end @@ -130,7 +130,7 @@ def add_outside_value_to(values) def validation_matcher_scenario_args super.deep_merge( column_type: :decimal, - default_value: BigDecimal.new('1.0') + default_value: BigDecimal('1.0') ) end end