Sha256: 06ebfd10cc3f7c71173f07f863b645129209298a22282f158364ac23d8a7e037

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 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
              return Support::Cache.new unless Support::Gems::RSpec.current_example

              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

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.10.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.9.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.8.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.7.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.6.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.5.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.4.0 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb
convenient_service-0.3.1 lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb