• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 20352926452

17 Dec 2025 02:02PM UTC coverage: 95.426% (-0.9%) from 96.338%
20352926452

push

github

web-flow
Merge pull request #2643 from ruby-grape/replace_try_by_respond_to

Replace all `try` to `respond_to`.

1048 of 1161 branches covered (90.27%)

Branch coverage included in aggregate %.

29 of 29 new or added lines in 14 files covered. (100.0%)

28 existing lines in 7 files now uncovered.

3333 of 3430 relevant lines covered (97.17%)

13955.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.5
/lib/grape/validations/validators/contract_scope_validator.rb
1
# frozen_string_literal: true
2

3
module Grape
11✔
4
  module Validations
11✔
5
    module Validators
11✔
6
      class ContractScopeValidator < Base
11✔
7
        attr_reader :schema
11✔
8

9
        def initialize(_attrs, _options, _required, _scope, opts)
11✔
UNCOV
10
          super
×
UNCOV
11
          @schema = opts.fetch(:schema)
×
12
        end
13

14
        # Validates a given request.
15
        # @param request [Grape::Request] the request currently being handled
16
        # @raise [Grape::Exceptions::ValidationArrayErrors] if validation failed
17
        # @return [void]
18
        def validate(request)
11✔
UNCOV
19
          res = schema.call(request.params)
×
20

UNCOV
21
          if res.success?
×
UNCOV
22
            request.params.deep_merge!(res.to_h)
×
UNCOV
23
            return
×
24
          end
25

UNCOV
26
          raise Grape::Exceptions::ValidationArrayErrors.new(build_errors_from_messages(res.errors.messages))
×
27
        end
28

29
        private
11✔
30

31
        def build_errors_from_messages(messages)
11✔
UNCOV
32
          messages.map do |message|
×
UNCOV
33
            full_name = message.path.first.to_s
×
UNCOV
34
            full_name << "[#{message.path[1..].join('][')}]" if message.path.size > 1
×
UNCOV
35
            Grape::Exceptions::Validation.new(params: [full_name], message: message.text)
×
36
          end
37
        end
38
      end
39
    end
40
  end
41
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc