Skip to content

Commit

Permalink
test(core): add Config specs
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Oct 30, 2022
1 parent 0369376 commit ba3d5ca
Show file tree
Hide file tree
Showing 4 changed files with 528 additions and 440 deletions.
12 changes: 8 additions & 4 deletions lib/convenient_service/core/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ def middlewares(...)
end

##
# @return [void]
# Commits config when called for the first time.
# Does nothing for the subsequent calls.
#
# @return [Boolean] true if called for the first time, false otherwise (similarly as Kernel#require).
#
# @see https://ruby-doc.org/core-3.1.2/Kernel.html#method-i-require
#
def commit_config!
(@config ||= Entities::Config.new(klass: self)).commit!

ConvenientService.logger.debug { "[Core] Included concerns into `#{self}` | Triggered by `.commit_config!`" }
.tap { ConvenientService.logger.debug { "[Core] Committed config for `#{self}` | Triggered by `.commit_config!`" } }
end

##
Expand Down Expand Up @@ -68,7 +72,7 @@ def method_missing(method, *args, **kwargs, &block)

return super if middlewares(method, scope: :class).defined_without_super_method?

ConvenientService.logger.debug { "[Core] Included concerns into `#{self}` | Triggered by `method_missing` | Method: `.#{method}`" }
ConvenientService.logger.debug { "[Core] Committed config for `#{self}` | Triggered by `method_missing` | Method: `.#{method}`" }

__send__(method, *args, **kwargs, &block)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/convenient_service/core/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def method_missing(method, *args, **kwargs, &block)

return super if middlewares(method, scope: :instance).defined_without_super_method?

ConvenientService.logger.debug { "[Core] Included concerns into `#{self.class}` | Triggered by `method_missing` | Method: `##{method}`" }
ConvenientService.logger.debug { "[Core] Committed config for `#{self.class}` | Triggered by `method_missing` | Method: `##{method}`" }

__send__(method, *args, **kwargs, &block)
end
Expand Down
Loading

0 comments on commit ba3d5ca

Please sign in to comment.