Skip to content

Commit 120a76f

Browse files
committed
Fix Proc with arity one in values
1 parent 2f3ec04 commit 120a76f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/grape-swagger/doc_methods/parse_params.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def param_type(value_type)
101101
def parse_enum_or_range_values(values)
102102
case values
103103
when Proc
104-
parse_enum_or_range_values(values.call)
104+
parse_enum_or_range_values(values.call) if values.parameters.empty?
105105
when Range
106106
parse_range_values(values) if values.first.is_a?(Integer)
107107
else

spec/lib/parse_params_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
expect(parsed_range).to eql(enum: %w[a b c])
4848
end
4949
end
50+
51+
describe 'with arity one' do
52+
let(:values) { proc { |v| v < 25 } }
53+
specify do
54+
parsed_range = subject.send(:parse_enum_or_range_values, values)
55+
expect(parsed_range).to be_nil
56+
end
57+
end
5058
end
5159

5260
describe 'values as Array -> enums' do

0 commit comments

Comments
 (0)