lib/stove/validator.rb in stove-2.0.0 vs lib/stove/validator.rb in stove-3.0.0

- old
+ new

@@ -1,10 +1,11 @@ module Stove class Validator - include Mixin::Insideable include Logify + include Mixin::Insideable + # # The class that created this validator. # # @return [~Class] # @@ -46,19 +47,19 @@ # # @param [Cookbook] # the cookbook to run this validation against # def run(cookbook, options = {}) - log.info("Running validations for #{klass.id}.#{id}") + log.info("Running validations for `#{klass.id}.#{id}'") inside(cookbook) do instance = klass.new(cookbook, options) unless result = instance.instance_eval(&block) log.debug("Validation failed, result: #{result.inspect}") - raise Error::ValidationFailed.new(klass.id, id, - path: Dir.pwd, - result: result, - ) + + # Convert the class and id to their magical equivalents + error = Error.const_get("#{Util.camelize(klass.id)}#{Util.camelize(id)}ValidationFailed") + raise error.new(path: Dir.pwd, result: result) end end log.debug("Validation #{id} passed!") end