Sha256: 4cbdd721a307a0874273cda915d19931aa15fe17d9ee889957c70223c3ce32fe

Contents?: true

Size: 1.41 KB

Versions: 38

Compression:

Stored size: 1.41 KB

Contents

require_relative '../rails_spec_helper'

describe 'rake appmap:swagger' do
  include_context 'Rails app pg database', "spec/fixtures/rails6_users_app" unless use_existing_data?
  include_context 'rails integration test setup'

  def run_spec(spec_name)
    cmd = <<~CMD.gsub "\n", ' '
      docker-compose run --rm -e RAILS_ENV=test -e APPMAP=true
      -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec #{spec_name}
    CMD
    run_cmd cmd, chdir: fixture_dir
  end

  def generate_swagger
    cmd = <<~CMD.gsub "\n", ' '
      docker-compose run --rm -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rake appmap:swagger
    CMD
    run_cmd cmd, chdir: fixture_dir
  end

  unless use_existing_data?
    before(:all) do
      generate_swagger
    end
  end

  # The swagger-building logic is mostly in the JS code. So what we are really testing here
  # is the Rails integration - the rake task and integration with the appmap.yml.
  # And of course the bundling of the JS code by the appmap gem.
  it 'generates openapi_stable.yml' do
    swagger = YAML.load(File.read(File.join(tmpdir, 'swagger', 'openapi_stable.yaml'))).deep_symbolize_keys

    expect(swagger).to match(
      hash_including(
        openapi: /^\d\.\d\.\d$/,
        info: {
          title: 'Usersapp API',
          version: '1.1.0'
        },
        paths: hash_including(
          :'/api/users' => an_instance_of(Hash)
        )
      )
    )
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appmap-0.62.1 spec/swagger/swagger_spec.rb
appmap-0.62.0 spec/swagger/swagger_spec.rb
appmap-0.61.1 spec/swagger/swagger_spec.rb
appmap-0.61.0 spec/swagger/swagger_spec.rb
appmap-0.60.0 spec/swagger/swagger_spec.rb
appmap-0.59.2 spec/swagger/swagger_spec.rb
appmap-0.59.1 spec/swagger/swagger_spec.rb
appmap-0.59.0 spec/swagger/swagger_spec.rb
appmap-0.58.0 spec/swagger/swagger_spec.rb
appmap-0.57.1 spec/swagger/swagger_spec.rb
appmap-0.57.0 spec/swagger/swagger_spec.rb
appmap-0.56.0 spec/swagger/swagger_spec.rb
appmap-0.55.0 spec/swagger/swagger_spec.rb
appmap-0.54.4 spec/swagger/swagger_spec.rb
appmap-0.54.3 spec/swagger/swagger_spec.rb
appmap-0.54.2 spec/swagger/swagger_spec.rb
appmap-0.54.1 spec/swagger/swagger_spec.rb
appmap-0.54.0 spec/swagger/swagger_spec.rb