Class: Jade::Tasks::TestRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/jade/tasks/rspec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestRegistry

Returns a new instance of TestRegistry.



12
13
14
15
16
17
# File 'lib/jade/tasks/rspec.rb', line 12

def initialize
  @persistent = {}
  @queues     = Hash.new { |h, k| h[k] = [] }
  @calls      = Hash.new { |h, k| h[k] = [] }
  @strict     = false
end

Instance Attribute Details

#strictObject

Returns the value of attribute strict.



10
11
12
# File 'lib/jade/tasks/rspec.rb', line 10

def strict
  @strict
end

Instance Method Details

#calls_to(task_def) ⇒ Object



36
37
38
# File 'lib/jade/tasks/rspec.rb', line 36

def calls_to(task_def)
  @calls[task_def]
end

#dispatch(task_def, args) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/jade/tasks/rspec.rb', line 27

def dispatch(task_def, args)
  @calls[task_def] << args

  pick_answer(task_def)
    .then { it || fail(Unbound.new(task_def, args, @strict)) }
    .then { resolve(it, args) }
    .tap { |value| fail ReturnedTask.new(task_def) if value.is_a?(Jade::Task) }
end

#queue_next(task_def, answer) ⇒ Object



19
20
21
# File 'lib/jade/tasks/rspec.rb', line 19

def queue_next(task_def, answer)
  @queues[task_def] << answer
end

#set_persistent(task_def, answer) ⇒ Object



23
24
25
# File 'lib/jade/tasks/rspec.rb', line 23

def set_persistent(task_def, answer)
  @persistent[task_def] = answer
end