Skip to content

Commit 6e12833

Browse files
committed
Renamed ValidatorsCache to ValidatorsRegistry
1 parent 870dffb commit 6e12833

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/grape/validations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ module Validations
55
module_function
66

77
def require_validator(short_name)
8-
ValidatorsCache[short_name]
8+
ValidatorsRegistry[short_name]
99
rescue NameError
1010
raise Grape::Exceptions::UnknownValidator, short_name
1111
end
1212

13-
class ValidatorsCache < Grape::Util::Cache
13+
class ValidatorsRegistry < Grape::Util::Cache
1414
def initialize
1515
super
1616
@cache = Hash.new do |h, name|

spec/grape/validations_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,5 +2026,21 @@ def validate_param!(attr_name, params)
20262026
expect { subject }.to raise_error(Grape::Exceptions::UnknownValidator)
20272027
end
20282028
end
2029+
2030+
context 'when custom' do
2031+
let(:short_name) { :custom }
2032+
let(:custom_validator) do
2033+
Class.new(Grape::Validations::Validators::Base) do
2034+
def validate_param!(_attr_name, _params)
2035+
end
2036+
end
2037+
end
2038+
2039+
before do
2040+
stub_const('Grape::Validations::Validators::CustomValidator', custom_validator)
2041+
end
2042+
2043+
it { is_expected.to be(Grape::Validations::Validators::CustomValidator) }
2044+
end
20292045
end
20302046
end

0 commit comments

Comments
 (0)