Sha256: c488bcafd95bcecd262b12fd3b624da26b39e339e75925269641f89df134c75e

Contents?: true

Size: 1.74 KB

Versions: 17

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: false

require 'spec_helper'

describe GrapeSwagger::DocMethods::OperationId do
  subject { described_class }

  specify { expect(subject).to eql GrapeSwagger::DocMethods::OperationId }
  specify { expect(subject).to respond_to :build }

  describe 'build' do
    let(:route) { Grape::Router::Route.new(method, '/path', requirements: {}) }

    describe 'GET' do
      let(:method) { 'GET' }
      specify { expect(subject.build(route)).to eql 'get' }
    end
    describe 'get' do
      let(:method) { 'get' }
      specify { expect(subject.build(route)).to eql 'get' }
    end
    describe ':get' do
      let(:method) { :get }
      specify { expect(subject.build(route)).to eql 'get' }
    end

    describe 'path given' do
      let(:method) { 'GET' }
      it 'GET with path foo' do
        expect(subject.build(route, 'foo')).to eql 'getFoo'
      end
      it 'GET with path /foo' do
        expect(subject.build(route, '/foo')).to eql 'getFoo'
      end
      it 'GET with path bar/foo' do
        expect(subject.build(route, 'bar/foo')).to eql 'getBarFoo'
      end
      it 'GET with path bar/foo{id}' do
        expect(subject.build(route, 'bar/foo{id}')).to eql 'getBarFooId'
      end
      it 'GET with path /bar_foo{id}' do
        expect(subject.build(route, '/bar_foo{id}')).to eql 'getBarFooId'
      end
      it 'GET with path /bar-foo{id}' do
        expect(subject.build(route, '/bar-foo{id}')).to eql 'getBarFooId'
      end
      it 'GET with path /simple_test/bar-foo{id}' do
        expect(subject.build(route, '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId'
      end
      it 'GET path with optional format' do
        expect(subject.build(route, 'foo(.{format})')).to eql 'getFoo(.Format)'
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
grape-swagger-1.6.1 spec/lib/operation_id_spec.rb
grape-swagger-1.6.0 spec/lib/operation_id_spec.rb
gitlab-grape-swagger-1.5.0 spec/lib/operation_id_spec.rb
grape-swagger-1.5.0 spec/lib/operation_id_spec.rb
grape-swagger-1.4.2 spec/lib/operation_id_spec.rb
grape-swagger-1.4.1 spec/lib/operation_id_spec.rb
grape-swagger-1.4.0 spec/lib/operation_id_spec.rb
grape-swagger-1.3.1 spec/lib/operation_id_spec.rb
grape-swagger-1.3.0 spec/lib/operation_id_spec.rb
grape-swagger-1.2.1 spec/lib/operation_id_spec.rb
grape-swagger-1.2.0 spec/lib/operation_id_spec.rb
grape-swagger-1.1.0 spec/lib/operation_id_spec.rb
grape-swagger-1.0.0 spec/lib/operation_id_spec.rb
grape-swagger-0.34.2 spec/lib/operation_id_spec.rb
grape-swagger-0.34.1 spec/lib/operation_id_spec.rb
grape-swagger-0.34.0 spec/lib/operation_id_spec.rb
grape-swagger-0.33.0 spec/lib/operation_id_spec.rb