File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ def json(value)
37
37
def translate_message ( msg )
38
38
# remove suffix
39
39
msg . gsub! ( / in schema .*$/ , '' )
40
+ # lowercase first letter (eg. 'The' becomes 'the')
41
+ msg . gsub! ( /^./ ) { |m | m . downcase }
42
+ # prefix with 'is invalid'
43
+ msg . gsub! ( /^(.*)$/ , 'is invalid (\1)' )
40
44
end
41
45
42
46
def check_validity!
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def initialize(json_data)
52
52
{ }
53
53
) . to (
54
54
{
55
- json_data : [ "The property '#/' did not contain a required property of 'soup'" ]
55
+ json_data : [ "is invalid (the property '#/' did not contain a required property of 'soup') " ]
56
56
}
57
57
)
58
58
end
@@ -90,7 +90,7 @@ def initialize(json_data)
90
90
{ }
91
91
) . to (
92
92
{
93
- json_data : [ "The property '#/menu' was not of a minimum string length of 200" ]
93
+ json_data : [ "is invalid (the property '#/menu' was not of a minimum string length of 200) " ]
94
94
}
95
95
)
96
96
end
@@ -150,7 +150,7 @@ def initialize(json_data)
150
150
151
151
it 'translates json-schema messages to slightly more readable ones' do
152
152
msg = "The property '#/menu' was not of a minimum string length of 200 in schema 40148e2f-45d6-51b7-972a-179bd9de61d6#"
153
- expect ( subject . translate_message ( msg ) ) . to eq ( "The property '#/menu' was not of a minimum string length of 200" )
153
+ expect ( subject . translate_message ( msg ) ) . to eq ( "is invalid (the property '#/menu' was not of a minimum string length of 200) " )
154
154
end
155
155
end
156
156
You can’t perform that action at this time.
0 commit comments