Sha256: 7f759668c0d1df2ed6a7d474c6ec30b4d851a53049723a3bd267c57199953e92

Contents?: true

Size: 551 Bytes

Versions: 20

Compression:

Stored size: 551 Bytes

Contents

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

20 entries across 20 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/spec/grape/api/recognize_path_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/spec/grape/api/recognize_path_spec.rb
grape-1.2.5 spec/grape/api/recognize_path_spec.rb
grape-1.2.4 spec/grape/api/recognize_path_spec.rb
grape-1.2.3 spec/grape/api/recognize_path_spec.rb
grape-1.2.2 spec/grape/api/recognize_path_spec.rb
grape-1.2.1 spec/grape/api/recognize_path_spec.rb
grape-1.2.0 spec/grape/api/recognize_path_spec.rb
grape-1.1.0 spec/grape/api/recognize_path_spec.rb
grape-1.0.3 spec/grape/api/recognize_path_spec.rb
grape-1.0.2 spec/grape/api/recognize_path_spec.rb
grape-1.0.1 spec/grape/api/recognize_path_spec.rb
grape-1.0.0 spec/grape/api/recognize_path_spec.rb
grape-0.19.2 spec/grape/api/recognize_path_spec.rb
grape-0.19.1 spec/grape/api/recognize_path_spec.rb
grape-0.19.0 spec/grape/api/recognize_path_spec.rb
grape-0.18.0 spec/grape/api/recognize_path_spec.rb
grape-0.17.0 spec/grape/api/recognize_path_spec.rb
grape-0.16.2 spec/grape/api/recognize_path_spec.rb
grape-0.16.1 spec/grape/api/recognize_path_spec.rb