diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index d688fca9..0ab50d49 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -4,7 +4,6 @@ require "date" require "liquid" module Jekyll - # rubocop:disable Metrics/ModuleLength module Filters # Convert a Markdown string into HTML output. # @@ -269,12 +268,7 @@ module Jekyll def to_integer(input) return 1 if input == true return 0 if input == false - begin - input.to_i - rescue - raise ArgumentError, - "Object '#{input.inspect}' could not be converted into an integer." - end + input.to_i end # Sort an array of objects diff --git a/test/test_filters.rb b/test/test_filters.rb index c8d4a68b..bb979524 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -645,8 +645,13 @@ class TestFilters < JekyllUnitTest context "to_integer filter" do should "raise Exception when input is not integer or string" do - err_msg = "Object '[1, 2]' could not be converted into an integer." - err = assert_raises ArgumentError do + err_msg = <<-EOS.strip! +undefined method `to_i' for [1, 2]:Array +Did you mean? to_s + to_a + to_h +EOS + err = assert_raises NoMethodError do @filter.to_integer([1, 2]) end assert_equal err_msg, err.message