diff --git a/spec/grape/validations/validators/coerce_spec.rb b/spec/grape/validations/validators/coerce_spec.rb index cb2cca5f95..2cfaceea83 100644 --- a/spec/grape/validations/validators/coerce_spec.rb +++ b/spec/grape/validations/validators/coerce_spec.rb @@ -180,6 +180,23 @@ def self.parsed?(value) expect(last_response.body).to eq(integer_class_name) end + it 'String' do + subject.params do + requires :string, coerce: String + end + subject.get '/string' do + params[:string].class + end + + get '/string', string: 45 + expect(last_response.status).to eq(200) + expect(last_response.body).to eq('String') + + get '/string', string: nil + expect(last_response.status).to eq(200) + expect(last_response.body).to eq('NilClass') + end + it 'is a custom type' do subject.params do requires :uri, coerce: SecureURIOnly