Class: OpenapiFirst::Test::Setup
- Inherits:
-
Object
- Object
- OpenapiFirst::Test::Setup
- Defined in:
- lib/openapi_first/test.rb
Overview
Helper class to setup tests
Instance Attribute Summary collapse
-
#minimum_coverage ⇒ Object
Returns the value of attribute minimum_coverage.
Instance Method Summary collapse
-
#handle_exit ⇒ Object
This called at_exit.
-
#initialize {|_self| ... } ⇒ Setup
constructor
A new instance of Setup.
- #register ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Setup
Returns a new instance of Setup.
17 18 19 20 |
# File 'lib/openapi_first/test.rb', line 17 def initialize @minimum_coverage = 0 yield self end |
Instance Attribute Details
#minimum_coverage ⇒ Object
Returns the value of attribute minimum_coverage.
26 27 28 |
# File 'lib/openapi_first/test.rb', line 26 def minimum_coverage @minimum_coverage end |
Instance Method Details
#handle_exit ⇒ Object
This called at_exit
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openapi_first/test.rb', line 29 def handle_exit coverage = Coverage.result.coverage # :nocov: puts 'API Coverage did not detect any API requests for the registered API descriptions' if coverage.zero? Test.report_coverage if coverage.positive? return unless minimum_coverage > coverage puts "API Coverage fails with exit 2, because API coverage of #{coverage}%" \ "is below minimum of #{minimum_coverage}%!" exit 2 # :nocov: end |