Sha256: db9c009dfa178268ad748e43b32c7590191e43f60ecec2e1483589d0ff9eadbd
Contents?: true
Size: 751 Bytes
Versions: 3
Compression:
Stored size: 751 Bytes
Contents
require 'spec_helper' describe Grape::Validations::RegexpValidator do module ValidationsSpec module RegexpValidatorSpec class API < Grape::API default_format :json params do requires :name, regexp: /^[a-z]+$/ end get do end end end end def app ValidationsSpec::RegexpValidatorSpec::API end context 'invalid input' do it 'refuses inapppopriate' do get '/', name: "invalid name" expect(last_response.status).to eq(400) end it 'refuses nil' do get '/', name: nil expect(last_response.status).to eq(400) end end it 'accepts valid input' do get '/', name: "bob" expect(last_response.status).to eq(200) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
grape-security-0.8.0 | spec/grape/validations/regexp_spec.rb |
grape-0.9.0 | spec/grape/validations/regexp_spec.rb |
grape-0.8.0 | spec/grape/validations/regexp_spec.rb |