Sha256: 9d129e19599a213ebfc63e04260d55231fd92777c588010d2250b1524e05e43f

Contents?: true

Size: 641 Bytes

Versions: 3

Compression:

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
grape-0.2.3 spec/grape/validations/regexp_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/grape-0.2.2/spec/grape/validations/regexp_spec.rb
grape-0.2.2 spec/grape/validations/regexp_spec.rb