Sha256: bb998cd067cbb1b6bded5422a81270cf424d69a79ae1f64045dd1af445871387

Contents?: true

Size: 1.69 KB

Versions: 49

Compression:

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

    class ReeRodaTestSwagger::Cmd
      include ReeActions::DSL

      action :cmd

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

      InvalidErr = ReeErrors::ValidationError.build(: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, 422, :description))
      .to eq("- type: **validation**, code: **invalid**, message: **invalid**")
  }
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ree_lib-1.0.94 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.93 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.92 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.91 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.90 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.89 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.88 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.87 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.86 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.85 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.84 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.83 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.82 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.81 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.80 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.79 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.78 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.77 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.76 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
ree_lib-1.0.75 lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb