Sha256: 91227200d73bd9bd4f052d228c14149cecc2e843cae39e3252cf36de9950d22c

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

package_require("ree_errors/validation_error")

RSpec.describe :build_swagger_from_routes do
  link :add_load_path, from: :ree_i18n
  link :build_swagger_from_routes, from: :ree_roda

  before :all do
    add_load_path(Dir[File.join(__dir__, 'locales/*.yml')])

    Ree.enable_irb_mode

    module ReeRodaTestSwagger
      include Ree::PackageDSL

      package do
        depends_on :ree_actions
        depends_on :ree_dao
        depends_on :ree_errors
      end
    end

    class ReeRodaTestSwagger::Cmd
      include ReeActions::DSL

      action :cmd do
        link :invalid_param_error, from: :ree_errors
      end

      ActionCaster = build_mapper.use(:cast) do
        integer :id
      end

      InvalidErr = invalid_param_error(:invalid, "invalid")

      contract(Any, Any => Any).throws(InvalidErr)
      def call(access, attrs)
        raise InvalidErr if false
      end
    end

    class ReeRodaTestSwagger::TestRoutes
      include ReeRoutes::DSL

      routes :test_routes do
        default_warden_scope :identity
        opts = { from: :ree_roda_test_swagger }

        post "api/actions" do
          summary "Some action"
          action :cmd, **opts
        end
      end
    end

    class TestSwaggerApp < ReeRoda::App
      plugin :ree_routes

      ree_routes ReeRodaTestSwagger::TestRoutes.new

      route do |r|
        r.ree_routes
      end
    end
  end

  after :all do
    Ree.disable_irb_mode
  end

  let(:routes) { TestSwaggerApp.instance_variable_get(:@ree_routes) }

  it {
    swagger = build_swagger_from_routes(routes, "test", "test", "1.0", "https://example.com")

    expect(swagger.dig(:paths, "/api/actions", :post, :responses, 400, :description))
      .to eq("- type: **invalid_param**, code: **invalid**, message: **invalid param**")
  }
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ree_lib-1.0.124 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb