Class: OpenapiFirst::Test::Configuration
- Inherits:
-
Object
- Object
- OpenapiFirst::Test::Configuration
- Defined in:
- lib/openapi_first/test/configuration.rb
Overview
Helper class to setup tests
Instance Attribute Summary collapse
-
#coverage_formatter ⇒ Object
Returns the value of attribute coverage_formatter.
-
#coverage_formatter_options ⇒ Object
Returns the value of attribute coverage_formatter_options.
-
#ignore_unknown_requests ⇒ Object
Returns the value of attribute ignore_unknown_requests.
-
#ignore_unknown_response_status ⇒ Object
(also: #ignore_unknown_response_status?)
Returns the value of attribute ignore_unknown_response_status.
-
#ignored_unknown_status ⇒ Object
Returns the value of attribute ignored_unknown_status.
-
#minimum_coverage ⇒ Object
Returns the value of attribute minimum_coverage.
-
#report_coverage ⇒ Object
Returns the value of attribute report_coverage.
-
#response_raise_error ⇒ Object
Returns the value of attribute response_raise_error.
Instance Method Summary collapse
- #ignore_response?(validated_response) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#observe(app, api: :default) ⇒ Object
Observe a rack app.
-
#register(oad, as: :default) ⇒ Object
Register OADs, but don’t load them just yet.
- #skip_coverage(&block) ⇒ Object
- #skip_response_coverage(&block) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/openapi_first/test/configuration.rb', line 7 def initialize @minimum_coverage = 100 @coverage_formatter = Coverage::TerminalFormatter @coverage_formatter_options = {} @skip_response_coverage = nil @skip_coverage = nil @response_raise_error = true @ignored_unknown_status = Set.new([401, 404, 500]) @ignore_unknown_response_status = false @report_coverage = true @ignore_unknown_requests = false end |
Instance Attribute Details
#coverage_formatter ⇒ Object
Returns the value of attribute coverage_formatter.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def coverage_formatter @coverage_formatter end |
#coverage_formatter_options ⇒ Object
Returns the value of attribute coverage_formatter_options.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def @coverage_formatter_options end |
#ignore_unknown_requests ⇒ Object
Returns the value of attribute ignore_unknown_requests.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def ignore_unknown_requests @ignore_unknown_requests end |
#ignore_unknown_response_status ⇒ Object Also known as: ignore_unknown_response_status?
Returns the value of attribute ignore_unknown_response_status.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def ignore_unknown_response_status @ignore_unknown_response_status end |
#ignored_unknown_status ⇒ Object
Returns the value of attribute ignored_unknown_status.
34 35 36 |
# File 'lib/openapi_first/test/configuration.rb', line 34 def ignored_unknown_status @ignored_unknown_status end |
#minimum_coverage ⇒ Object
Returns the value of attribute minimum_coverage.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def minimum_coverage @minimum_coverage end |
#report_coverage ⇒ Object
Returns the value of attribute report_coverage.
34 35 36 |
# File 'lib/openapi_first/test/configuration.rb', line 34 def report_coverage @report_coverage end |
#response_raise_error ⇒ Object
Returns the value of attribute response_raise_error.
32 33 34 |
# File 'lib/openapi_first/test/configuration.rb', line 32 def response_raise_error @response_raise_error end |
Instance Method Details
#ignore_response?(validated_response) ⇒ Boolean
67 68 69 70 71 72 73 |
# File 'lib/openapi_first/test/configuration.rb', line 67 def ignore_response?(validated_response) return false if validated_response.known? return true if ignored_unknown_status.include?(validated_response.status) ignore_unknown_response_status? && validated_response.error.type == :response_status_not_found end |
#observe(app, api: :default) ⇒ Object
Observe a rack app
28 29 30 |
# File 'lib/openapi_first/test/configuration.rb', line 28 def observe(app, api: :default) Observe.observe(app, api:) end |
#register(oad, as: :default) ⇒ Object
Register OADs, but don’t load them just yet
23 24 25 |
# File 'lib/openapi_first/test/configuration.rb', line 23 def register(oad, as: :default) Test.register(oad, as:) end |
#skip_coverage(&block) ⇒ Object
59 60 61 62 63 |
# File 'lib/openapi_first/test/configuration.rb', line 59 def skip_coverage(&block) return @skip_coverage unless block_given? @skip_coverage = block end |
#skip_response_coverage(&block) ⇒ Object
53 54 55 56 57 |
# File 'lib/openapi_first/test/configuration.rb', line 53 def skip_response_coverage(&block) return @skip_response_coverage unless block_given? @skip_response_coverage = block end |