Sha256: 9470e84c52bc2ebe9a2d260b3f8ac3d036c6acbc2cdf9b062db1b5d69436b5cf

Contents?: true

Size: 642 Bytes

Versions: 2

Compression:

Stored size: 642 Bytes

Contents

require 'spec_helper'

describe Gris::MinimumLength do
  include Rack::Test::Methods

  module MinimumLengthSpec
    class API < Grape::API
      default_format :json

      params do
        requires :name, minimum_length: 3
      end

      get do
      end
    end
  end

  def app
    MinimumLengthSpec::API
  end

  it 'raises an error for invalid inputs' do
    get '/', name: 'hi'
    expect(last_response.status).to eq(400)
    expect(last_response.body).to eq('{"error":"name must be at least 3 characters long"}')
  end

  it 'accepts valid input' do
    get '/', name: 'hello'
    expect(last_response.status).to eq(200)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gris-0.6.8 spec/grape_extensions/minimum_length_spec.rb
gris-0.6.7 spec/grape_extensions/minimum_length_spec.rb