Module: MiniApivore

Defined in:
lib/mini_apivore.rb,
lib/mini_apivore/swagger.rb,
lib/mini_apivore/fragment.rb,
lib/mini_apivore/http_codes.rb,
lib/mini_apivore/validation.rb,
lib/mini_apivore/swagger_checker.rb

Defined Under Namespace

Modules: ClassMethods, Validation Classes: Fragment, Swagger, SwaggerChecker

Constant Summary collapse

SWAGGER_CHECKERS =
{}
NOT_FOUND =
404
NOT_AUTHORIZED =
401
FORBIDDEN =

Access denied

403
UNPROCESSABLE_ENTITY =
422
OK =
200
NO_CONTENT =
204

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_test_ran?Boolean



14
# File 'lib/mini_apivore.rb', line 14

def self.all_test_ran?; runnable_list.empty? end

.included(base) ⇒ Object



30
31
32
33
# File 'lib/mini_apivore.rb', line 30

def self.included(base)
  base.extend ClassMethods
  base.include MiniApivore::Validation
end

.prepare_untested_errorsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mini_apivore.rb', line 16

def self.prepare_untested_errors
  errors = []
  SWAGGER_CHECKERS.each do |cls, chkr|
    chkr.untested_mappings.each do |path, methods|
      methods.each do |method, codes|
        codes.each do |code, _|
          errors << "#{method} #{path} is untested for response code #{code} in test class #{cls.to_s}"
        end
      end
    end
  end
  errors
end

.runnable_listObject

—– Module globals —————–



13
# File 'lib/mini_apivore.rb', line 13

def self.runnable_list; @@runnable_list ||= []  end

Instance Method Details

#final_testObject

—– test for untested routes ———



62
63
64
65
66
67
68
69
70
# File 'lib/mini_apivore.rb', line 62

def final_test
  return unless MiniApivore.all_test_ran?

  @errors = MiniApivore.prepare_untested_errors
  assert( @errors.empty?, @errors.join("\n") )

  # preventing duplicate execution
  MiniApivore.runnable_list << "#{self.class.to_s}::#{__method__}_runned"
end

#teardownObject

—– Minitest callback ———–



56
57
58
59
# File 'lib/mini_apivore.rb', line 56

def teardown
  super
  MiniApivore.runnable_list.delete( "#{self.class.to_s}::#{@NAME}" )
end