Sha256: e3a1d87e5f46b2576ef73aeefede1101bbe25e599a263b9b71a6811646f7683a

Contents?: true

Size: 629 Bytes

Versions: 10

Compression:

Stored size: 629 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
  
  it 'refuses invalid input' do
    get '/', :name => "invalid name"
    last_response.status.should == 400
  end
  
  it 'accepts valid input' do
    get '/', :name => "bob"
    last_response.status.should == 200
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
grape-0.6.0 spec/grape/validations/regexp_spec.rb
grape-0.5.0 spec/grape/validations/regexp_spec.rb
grape-0.4.1 spec/grape/validations/regexp_spec.rb
grape-0.4.0 spec/grape/validations/regexp_spec.rb
grape-0.3.2 spec/grape/validations/regexp_spec.rb
grape-0.3.1 spec/grape/validations/regexp_spec.rb
grape-0.3.0 spec/grape/validations/regexp_spec.rb
grape-0.2.6 spec/grape/validations/regexp_spec.rb
grape-0.2.5 spec/grape/validations/regexp_spec.rb
grape-0.2.4 spec/grape/validations/regexp_spec.rb