Module: Kensho::RSpec::State

Defined in:
lib/kensho/rspec/state.rb

Constant Summary collapse

THREAD_KEY =
:__kensho_rspec_scratch__
GROUP_STACK_KEY =
:__kensho_rspec_group_stack__

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.formatterObject

Returns the value of attribute formatter.



60
61
62
# File 'lib/kensho/rspec/state.rb', line 60

def formatter
  @formatter
end

Class Method Details

.currentObject



37
38
39
# File 'lib/kensho/rspec/state.rb', line 37

def self.current
  Thread.current[THREAD_KEY]
end

.current=(scratch) ⇒ Object



41
42
43
# File 'lib/kensho/rspec/state.rb', line 41

def self.current=(scratch)
  Thread.current[THREAD_KEY] = scratch
end

.current_groupObject



54
55
56
57
# File 'lib/kensho/rspec/state.rb', line 54

def self.current_group
  stack = Thread.current[GROUP_STACK_KEY]
  stack ? stack.last : nil
end

.pop_groupObject



49
50
51
52
# File 'lib/kensho/rspec/state.rb', line 49

def self.pop_group
  stack = Thread.current[GROUP_STACK_KEY]
  stack&.pop
end

.push_group(group) ⇒ Object



45
46
47
# File 'lib/kensho/rspec/state.rb', line 45

def self.push_group(group)
  (Thread.current[GROUP_STACK_KEY] ||= []) << group
end