Module: OpenapiFirst::Test::Methods

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

Overview

Methods to use in integration tests

Defined Under Namespace

Modules: DefaultApiMethod

Class Method Summary collapse

Class Method Details

.[](application_under_test = nil, api: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/openapi_first/test/methods.rb', line 15

def self.[](application_under_test = nil, api: nil)
  mod = Module.new do
    def self.included(base)
      base.include OpenapiFirst::Test::Methods::AssertionMethod
    end
  end

  if api
    mod.define_method(:openapi_first_default_api) { api }
  else
    mod.include(DefaultApiMethod)
  end

  if application_under_test
    mod.define_method(:app) { OpenapiFirst::Test.app(application_under_test, api: openapi_first_default_api) }
  end

  mod
end

.included(base) ⇒ Object



10
11
12
13
# File 'lib/openapi_first/test/methods.rb', line 10

def self.included(base)
  base.include(DefaultApiMethod)
  base.include(AssertionMethod)
end