spec/grape/api/custom_validations_spec.rb in grape-0.16.2 vs spec/grape/api/custom_validations_spec.rb in grape-0.17.0

- old
+ new

@@ -6,11 +6,11 @@ module CustomValidationsSpec class DefaultLength < Grape::Validations::Base def validate_param!(attr_name, params) @option = params[:max].to_i if params.key?(:max) return if params[attr_name].length <= @option - fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be at the most #{@option} characters long" + raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be at the most #{@option} characters long" end end end end subject do @@ -85,11 +85,11 @@ context 'using a custom validator with message_key' do before do module CustomValidationsSpec class WithMessageKey < Grape::Validations::PresenceValidator def validate_param!(attr_name, _params) - fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: :presence + raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: :presence end end end end subject do @@ -124,10 +124,10 @@ return unless request.params.key? @attrs.first # check if admin flag is set to true return unless @option # check if user is admin or not # as an example get a token from request and check if it's admin or not - fail Grape::Exceptions::Validation, params: @attrs, message: 'Can not set Admin only field.' unless request.headers['X-Access-Token'] == 'admin' + raise Grape::Exceptions::Validation, params: @attrs, message: 'Can not set Admin only field.' unless request.headers['X-Access-Token'] == 'admin' end end end end subject do