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