Sha256: 83026e5f88e8e87bbbbbbca62d2cf4a5caaf96a0cb0389efa83bba01a470358e

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

require 'spec_helper'

RSpec.describe Apress::Documentation::SwaggerJsonBuilder, type: :service do
  describe '#call' do
    let(:service) { described_class.new(slug) }
    before do
      klass = Class.new(Apress::Documentation::Swagger::Schema) do
        swagger_path 'api/test' do
          operation :get
        end
      end
      klass.document_slug = slug

      Class.new(Apress::Documentation::Swagger::Schema) do
        swagger_path 'api/test2' do
          operation :get
        end
      end
    end

    context 'when slug is present' do
      let(:slug) { 'test' }

      it 'filters paths' do
        data = service.call[:paths]
        expect(data).to include :"api/test"
        expect(data).not_to include :"api/test2"
      end
    end

    context 'without slug' do
      let(:slug) { nil }

      it 'returns all data' do
        data = service.call[:paths]
        expect(data).to include :"api/test"
        expect(data).to include :"api/test2"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apress-documentation-0.4.0 spec/app/services/swagger_json_builder_spec.rb