Module: OpenapiRuby::Generator::AutorunSuppressor
- Defined in:
- lib/openapi_ruby/generator/autorun_suppressor.rb
Overview
Schema generation loads the consumer's spec/test files purely to collect
their path / api_path declarations. Loading them must not also run
them.
Both frameworks install an at_exit hook that runs the suite as a side
effect of being required, and a consumer's helper almost always pulls one
in transitively — rails/test_help requires
active_support/testing/autorun, which calls Minitest.autorun; RSpec
does the same via rspec/autorun. Without this, rake openapi_ruby:generate
runs the entire suite and fails whenever any unrelated test fails.
Installed by the generated script before any consumer file is required, so the hook is never registered in the first place.
Defined Under Namespace
Modules: MinitestSilencer
Class Method Summary collapse
Class Method Details
.install! ⇒ Object
21 22 23 24 |
# File 'lib/openapi_ruby/generator/autorun_suppressor.rb', line 21 def install! suppress_minitest! suppress_rspec! end |
.suppress_minitest! ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/openapi_ruby/generator/autorun_suppressor.rb', line 26 def suppress_minitest! require "minitest" ::Minitest.singleton_class.prepend(MinitestSilencer) rescue LoadError # Minitest isn't in the bundle — nothing to suppress. end |
.suppress_rspec! ⇒ Object
34 35 36 37 38 |
# File 'lib/openapi_ruby/generator/autorun_suppressor.rb', line 34 def suppress_rspec! return unless defined?(::RSpec::Core::Runner) ::RSpec::Core::Runner.disable_autorun! end |