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

ruby-grape / grape / 26758489730

01 Jun 2026 01:39PM UTC coverage: 96.638% (-0.2%) from 96.797%
26758489730

Pull #2755

github

ericproulx
Inline mustermann-grape into Grape::Router::MustermannPattern

mustermann-grape is a ~40-line Mustermann::AST::Pattern subclass that exists
only for Grape's path syntax, and it had already grown Grape-specific: the
Integer constraint reads Grape's own `params` option. Maintaining it as a
separate gem meant a two-step release for every syntax tweak (cut a
mustermann-grape release, then bump Grape's pin) plus its own CI/versioning.

Move the grammar into Grape as Grape::Router::MustermannPattern (attribution to
the original authors preserved), depend on `mustermann` directly, and
instantiate it directly from Grape::Router::Pattern as Grape always did. The
`mustermann` core dependency is unchanged; the graph collapses from
grape -> mustermann-grape -> mustermann to grape -> mustermann.

The class is no longer registered as a Mustermann `type: :grape` (Grape never
used the registry). Apps that called `Mustermann.new(_, type: :grape)` relying
on Grape pulling in mustermann-grape transitively should depend on it directly;
see UPGRADING.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pull Request #2755: Inline mustermann-grape into Grape::Router::MustermannPattern

1110 of 1207 branches covered (91.96%)

Branch coverage included in aggregate %.

20 of 25 new or added lines in 3 files covered. (80.0%)

2 existing lines in 2 files now uncovered.

3547 of 3612 relevant lines covered (98.2%)

23178.04 hits per line

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

96.15
/lib/grape/exceptions/validation_errors.rb
1
# frozen_string_literal: true
2

3
module Grape
30✔
4
  module Exceptions
30✔
5
    class ValidationErrors < Base
30✔
6
      include Enumerable
30✔
7

8
      attr_reader :errors
30✔
9

10
      def initialize(exceptions: [], headers: {})
30✔
11
        @errors = exceptions.flat_map(&:errors).group_by(&:params)
8,553✔
12
        super(message: full_messages.join(', '), status: 400, headers:)
8,553✔
13
      end
14

15
      def each
30✔
16
        errors.each_pair do |attribute, errors|
8,697✔
17
          errors.each do |error|
10,619✔
18
            yield attribute, error
11,267✔
19
          end
20
        end
21
      end
22

23
      def as_json(**_opts)
30✔
24
        errors.map do |k, v|
48✔
25
          {
26
            params: k,
48✔
27
            messages: v.map(&:to_s)
28
          }
29
        end
30
      end
31

32
      def to_json(*_opts)
30✔
UNCOV
33
        as_json.to_json
×
34
      end
35

36
      def full_messages
30✔
37
        messages = map do |attributes, error|
8,601✔
38
          translate(
11,171✔
39
            :format,
40
            scope: 'grape.errors',
41
            default: '%<attributes>s %<message>s',
42
            attributes: translate_attributes(attributes),
43
            message: error.message
44
          )
45
        end
46
        messages.uniq!
8,601✔
47
        messages
8,601✔
48
      end
49

50
      private
30✔
51

52
      def translate_attributes(keys)
30✔
53
        keys.map do |key|
11,171✔
54
          translate(key, scope: 'grape.errors.attributes', default: key.to_s)
12,995✔
55
        end.join(', ')
56
      end
57
    end
58
  end
59
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