Sha256: 5118dc95c9c177ec5ea1db7d4a8dd29e42508f0825d4261afcc94308cbca4f49

Contents?: true

Size: 582 Bytes

Versions: 11

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

    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

11 entries across 11 versions & 2 rubygems

Version Path
grape-1.6.0 spec/grape/api/recognize_path_spec.rb
grape-1.5.3 spec/grape/api/recognize_path_spec.rb
grape-1.5.2 spec/grape/api/recognize_path_spec.rb
grape-1.5.1 spec/grape/api/recognize_path_spec.rb
grape-1.5.0 spec/grape/api/recognize_path_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/spec/grape/api/recognize_path_spec.rb
grape-1.4.0 spec/grape/api/recognize_path_spec.rb
grape-1.3.3 spec/grape/api/recognize_path_spec.rb
grape-1.3.2 spec/grape/api/recognize_path_spec.rb
grape-1.3.1 spec/grape/api/recognize_path_spec.rb
grape-1.3.0 spec/grape/api/recognize_path_spec.rb