Sha256: fe5f7fecced131fbab892349109af7a8a271c65ad45ee21900c584c6b5f52bc2

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
grape-swagger-0.32.1 spec/lib/operation_id_spec.rb
grape-swagger-0.32.0 spec/lib/operation_id_spec.rb
grape-swagger-0.31.1 spec/lib/operation_id_spec.rb
grape-swagger-0.31.0 spec/lib/operation_id_spec.rb
grape-swagger-0.30.1 spec/lib/operation_id_spec.rb
grape-swagger-0.30.0 spec/lib/operation_id_spec.rb
grape-swagger-0.29.0 spec/lib/operation_id_spec.rb
grape-swagger-0.28.0 spec/lib/operation_id_spec.rb
grape-swagger-0.27.3 spec/lib/operation_id_spec.rb
grape-swagger-0.27.2 spec/lib/operation_id_spec.rb
grape-swagger-0.27.1 spec/lib/operation_id_spec.rb
grape-swagger-0.27.0 spec/lib/operation_id_spec.rb