Sha256: afd70a2bb2e1ade953fae2238df917e83a86857690ef38a984e1312706ca310f

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 KB

Contents

module Screengem
  #
  # Ensures that the memory/recollections that an actor uses are effectively global (using the actor name).
  #
  # This is required to use Cucumber ParameterTypes because the block arguments are cloned before they are
  # provided to the step definitions. This is intentional by the cucumber team to prevent leaking state
  # between step definitions. See https://github.com/cucumber/cucumber-ruby/issues/1275.
  #
  # The cloning of the actor means that is is effectively treated like a value object, and there will be
  # many instances of the same actor instantiated in the execution of a single test.
  #
  class ActorMemory
    include ::Singleton

    def recollections(actor)
      @recollections ||= ActiveSupport::HashWithIndifferentAccess.new
      @recollections[actor.name] ||= ActiveSupport::HashWithIndifferentAccess.new
    end

    #
    # Use this method to clear actor memory to avoid actor memory persisting across scenarios.
    #
    def clear
      @recollections = ActiveSupport::HashWithIndifferentAccess.new
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
screengem-0.21.2 lib/screengem/actor_memory.rb
screengem-0.21.1 lib/screengem/actor_memory.rb
screengem-0.21.0 lib/screengem/actor_memory.rb
screengem-0.20.1 lib/screengem/actor_memory.rb
screengem-0.20.0 lib/screengem/actor_memory.rb
screengem-0.19.0 lib/screengem/actor_memory.rb
screengem-0.18.1 lib/screengem/actor_memory.rb
screengem-0.18.0 lib/screengem/actor_memory.rb
screengem-0.17.0 lib/screengem/actor_memory.rb
screengem-0.16.0 lib/screengem/actor_memory.rb
screengem-0.15.0 lib/screengem/actor_memory.rb
screengem-0.14.0 lib/screengem/actor_memory.rb
screengem-0.13.0 lib/screengem/actor_memory.rb
screengem-0.12.0 lib/screengem/actor_memory.rb
screengem-0.11.0 lib/screengem/actor_memory.rb
screengem-0.10.1 lib/screengem/actor_memory.rb
screengem-0.10.0 lib/screengem/actor_memory.rb
screengem-0.9.1 lib/screengem/actor_memory.rb
screengem-0.9.0 lib/screengem/actor_memory.rb