Sha256: f5048046d8c6e4daaa478827f6003f8791823652cc060e2b1653e4154904fb0e

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

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

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

  describe 'operation_id_object' do
    describe 'version' do
      describe 'defaults: not given, false' do
        let(:options) { { add_version: false } }

        specify do
          expect(subject.build('/thing(.json)', options)).to eql ['Thing', '/thing']
          expect(subject.build('/thing/foo(.json)', options)).to eql ['Foo', '/thing/foo']
          expect(subject.build('/thing(.:format)', options)).to eql ['Thing', '/thing']
          expect(subject.build('/thing/foo(.:format)', options)).to eql ['Foo', '/thing/foo']
          expect(subject.build('/thing/:id', options)).to eql ['Thing', '/thing/{id}']
          expect(subject.build('/thing/foo/:id', options)).to eql ['Foo', '/thing/foo/{id}']
        end
      end

      describe 'defaults: given, true' do
        let(:options) { { version: 'v1', add_version: true } }

        specify do
          expect(subject.build('/{version}/thing(.json)', options)).to eql ['Thing', '/v1/thing']
          expect(subject.build('/{version}/thing/foo(.json)', options)).to eql ['Foo', '/v1/thing/foo']
          expect(subject.build('/{version}/thing(.:format)', options)).to eql ['Thing', '/v1/thing']
          expect(subject.build('/{version}/thing/foo(.:format)', options)).to eql ['Foo', '/v1/thing/foo']
          expect(subject.build('/{version}/thing/:id', options)).to eql ['Thing', '/v1/thing/{id}']
          expect(subject.build('/{version}/thing/foo/:id', options)).to eql ['Foo', '/v1/thing/foo/{id}']
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-swagger-0.20.3 spec/lib/path_string_spec.rb