Sha256: d5d0f37e7db9d69f5cf241f44d8a53b2f5fd61b97d900dcb26693a989eecd999

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 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

2 entries across 2 versions & 1 rubygems

Version Path
grape-0.7.0 spec/grape/validations/regexp_spec.rb
grape-0.6.1 spec/grape/validations/regexp_spec.rb