diff --git a/lib/tram/policy/dsl.rb b/lib/tram/policy/dsl.rb index 70c05dc..68a266f 100644 --- a/lib/tram/policy/dsl.rb +++ b/lib/tram/policy/dsl.rb @@ -9,7 +9,7 @@ module DSL # @return [self] # def validate(name = nil, **opts, &block) - local_validators << Validator.new(name, block, opts) + local_validators << Validator.new(name, block, **opts) self end diff --git a/lib/tram/policy/error.rb b/lib/tram/policy/error.rb index cedd598..540079f 100644 --- a/lib/tram/policy/error.rb +++ b/lib/tram/policy/error.rb @@ -41,7 +41,7 @@ def item # @return [String] # def message - key.is_a?(Symbol) ? I18n.t(*item) : key.to_s + key.is_a?(Symbol) ? I18n.t(key, **tags) : key.to_s end # Fetches an option diff --git a/lib/tram/policy/errors.rb b/lib/tram/policy/errors.rb index 27e9649..12bb3bb 100644 --- a/lib/tram/policy/errors.rb +++ b/lib/tram/policy/errors.rb @@ -47,7 +47,7 @@ def each # def filter(key = nil, **tags) list = each_with_object(Set.new) do |error, obj| - obj << error if error.contain?(key, tags) + obj << error if error.contain?(key, **tags) end self.class.new(scope: scope, errors: list) end @@ -95,7 +95,7 @@ def merge(other, **options) other.each do |err| key, opts = err.item opts = yield(opts) if block_given? - add key, opts.merge(options) + add key, **opts.merge(options) end self diff --git a/lib/tram/policy/rspec.rb b/lib/tram/policy/rspec.rb index 184c2aa..414dae5 100644 --- a/lib/tram/policy/rspec.rb +++ b/lib/tram/policy/rspec.rb @@ -6,7 +6,7 @@ def locales end def check(policy, tags) - @errors ||= policy.errors.filter(tags).map do |error| + @errors ||= policy.errors.filter(**tags).map do |error| { item: error.item }.tap do |obj| locales.each { |l| obj[l] = I18n.with_locale(l) { error.message } } end diff --git a/spec/tram/policy/error_spec.rb b/spec/tram/policy/error_spec.rb index 56f5085..e9a2b98 100644 --- a/spec/tram/policy/error_spec.rb +++ b/spec/tram/policy/error_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Tram::Policy::Error do - subject(:error) { described_class.new :bad, options } + subject(:error) { described_class.new :bad, **options } let(:scope) { %w[tram-policy] } let(:options) { { level: "warning", scope: scope } }