Sha256: 31d49060764f5d813fc5ecfbfba8bb17cc82e2363bd43ec6203f950a25d734b8

Contents?: true

Size: 641 Bytes

Versions: 2

Compression:

Stored size: 641 Bytes

Contents

require 'spec_helper'

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

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

      params do
        requires :name, maximum_length: 3
      end

      get do
      end
    end
  end

  def app
    MaximumLengthSpec::API
  end

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

  it 'accepts valid input' do
    get '/', name: 'hi'
    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/maximum_length_spec.rb
gris-0.6.7 spec/grape_extensions/maximum_length_spec.rb