Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor global DEBUG_ENABLED to module-based configuration #220

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

ny1020
Copy link
Contributor

@ny1020 ny1020 commented Apr 19, 2024

Description

This PR refactors the handling of the DEBUG_ENABLED flag in the RSpec::OpenAPI project. Previously managed as a global variable, this refactor introduces a more encapsulated and controlled approach.

Motivation

The motivation behind this change is to improve code quality by increasing modularity and reducing global state.

Changes

  1. Introduction of Config Class: Created a Config class within the RSpec::OpenAPI module to manage configuration settings, including the DEBUG_ENABLED flag.

  2. Module-based Configuration Access: Shifted the access of the debug configuration to be through RSpec::OpenAPI::Config.debug_enabled, making its use more explicit and restricted to the module's context.

  3. Environment Settings Loader: Added load_environment_settings method to the Config class to initialize configuration based on environment variables. This method is called conditionally when the OPENAPI environment variable is set.

lib/rspec/openapi.rb Fixed Show resolved Hide resolved
Copy link

codecov bot commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 97.14%. Comparing base (4e3b8d2) to head (dfad466).

Files Patch % Lines
lib/rspec/openapi.rb 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
+ Coverage   97.12%   97.14%   +0.02%     
==========================================
  Files          20       20              
  Lines         626      631       +5     
  Branches      143      144       +1     
==========================================
+ Hits          608      613       +5     
  Misses         18       18              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ny1020 ny1020 force-pushed the refactor-debug-configuration branch from aa3c04b to dfad466 Compare April 19, 2024 09:58
@ny1020 ny1020 marked this pull request as draft April 19, 2024 10:47
@ny1020 ny1020 marked this pull request as ready for review April 22, 2024 14:53
@ny1020 ny1020 marked this pull request as draft April 22, 2024 14:56
@ny1020 ny1020 marked this pull request as ready for review April 23, 2024 03:20
Copy link
Owner

@exoego exoego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Confirmed it works for Rails when Hanami not bundled.

@exoego exoego merged commit 9650075 into exoego:master Apr 24, 2024
12 of 13 checks passed
@exoego exoego added this to the vnext milestone Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants