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.



70
71
72
# File 'lib/kensho/rspec/state.rb', line 70

def formatter
  @formatter
end

Class Method Details

.currentObject



47
48
49
# File 'lib/kensho/rspec/state.rb', line 47

def self.current
  Thread.current[THREAD_KEY]
end

.current=(scratch) ⇒ Object



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

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

.current_groupObject



64
65
66
67
# File 'lib/kensho/rspec/state.rb', line 64

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

.pop_groupObject



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

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

.push_group(group) ⇒ Object



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

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