Sha256: 72f6d778be04de760e55937df3c7457d507616e5f9f48857c4e45859bda2acf2

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveStubbedResult
        module Concern
          include Support::Concern

          class_methods do
            ##
            # @return [ConvenientService::Support::Cache]
            #
            # @internal
            #   `::RSpec.current_example` docs:
            #   - https://www.rubydoc.info/github/rspec/rspec-core/RSpec.current_example
            #   - https://github.com/rspec/rspec-core/blob/v3.12.0/lib/rspec/core.rb#L122
            #   - https://relishapp.com/rspec/rspec-core/docs/metadata/current-example
            #
            #   TODO: Mutex for thread-safety when parallel steps will be supported.
            #
            def stubbed_results
              cache = Utils::Object.instance_variable_fetch(::RSpec.current_example, :@__convenient_service_stubbed_results__) { Support::Cache.new }

              cache.scope(self)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convenient_service-0.3.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb