Sha256: 256006d538a56db8bf115a2acd850585de208dcb0f46e3cb5ed52fa9a79b8966

Contents?: true

Size: 564 Bytes

Versions: 3

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

describe Grape::API do
  describe '.recognize_path' do
    subject { Class.new(described_class) }

    it 'fetches endpoint by given path' do
      subject.get('/foo/:id') {}
      subject.get('/bar/:id') {}
      subject.get('/baz/:id') {}

      actual = subject.recognize_path('/bar/1234').routes[0].origin
      expect(actual).to eq('/bar/:id')
    end

    it 'returns nil if given path does not match with registered routes' do
      subject.get {}
      expect(subject.recognize_path('/bar/1234')).to be_nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-1.8.0 spec/grape/api/recognize_path_spec.rb
grape-1.7.1 spec/grape/api/recognize_path_spec.rb
grape-1.7.0 spec/grape/api/recognize_path_spec.rb