Skip to content

Commit

Permalink
fix(can_have_stubbed_result): fix stubbed_result when it's called in …
Browse files Browse the repository at this point in the history
…non-test env
  • Loading branch information
Olha-30 committed Dec 19, 2022
1 parent d2990b6 commit e25178e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Concern
# TODO: Mutex for thread-safety when parallel steps will be supported.
#
def stubbed_results
return unless ::RSpec.current_example

cache = Utils::Object.instance_variable_fetch(::RSpec.current_example, :@__convenient_service_stubbed_results__) { Support::Cache.new }

cache.scope(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Middleware < Core::MethodChainMiddleware
# @return [Object] Can be any type.
#
def next(*args, **kwargs, &block)
return chain.next(*args, **kwargs, &block) unless cache

key_with_arguments = cache.keygen(*args, **kwargs, &block)
key_without_arguments = cache.keygen

Expand Down

0 comments on commit e25178e

Please sign in to comment.