Module: OpenapiFirst::Test

Defined in:
lib/openapi_first/test.rb,
lib/openapi_first/test/methods.rb

Overview

Test integration

Defined Under Namespace

Modules: Methods Classes: NotRegisteredError

Constant Summary collapse

DEFINITIONS =

rubocop:disable Style/MutableConstant

{}

Class Method Summary collapse

Class Method Details

.[](api) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/openapi_first/test.rb', line 18

def self.[](api)
  definitions.fetch(api) do
    option = api == :default ? '' : ", as: #{api.inspect}"
    raise(NotRegisteredError,
          "API description '#{api.inspect}' not found." \
          "Please call OpenapiFirst::Test.register('myopenapi.yaml'#{option}) " \
          'once before calling assert_api_conform.')
  end
end

.definitionsObject



12
# File 'lib/openapi_first/test.rb', line 12

def self.definitions = DEFINITIONS

.register(path, as: :default) ⇒ Object



14
15
16
# File 'lib/openapi_first/test.rb', line 14

def self.register(path, as: :default)
  definitions[as] = OpenapiFirst.load(path)
end