Class: Furnish::SchedulerTest

Inherits:
Test
  • Object
show all
Defined in:
lib/furnish/test.rb

Overview

SchedulerTestCase inherits from Furnish::TestCase and configures a threaded scheduler, but does not attempt to start it. It’s intended to be a primitive for cases where you might create a number of schedulers.

If the scheduler throws an exception for any reason, the test suite will abort.

RunningSchedulerTestCase deals with managing a running scheduler for you.

Direct Known Subclasses

RunningSchedulerTest

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schedObject (readonly)

Furnish::Scheduler object.



67
68
69
# File 'lib/furnish/test.rb', line 67

def sched
  @sched
end

Instance Method Details

#assert_solved(name) ⇒ Object

Assert the named group is solved, as far as the scheduler’s concerned.



88
89
90
# File 'lib/furnish/test.rb', line 88

def assert_solved(name)
  assert_includes(sched.vm.solved, name, "#{name} is solved in the scheduler")
end

#refute_solved(name) ⇒ Object

Refute the named group is solved, as far as the scheduler’s concerned.



96
97
98
# File 'lib/furnish/test.rb', line 96

def refute_solved(name)
  refute_includes(sched.vm.solved, name, "#{name} is solved in the scheduler")
end

#setupObject

:nodoc:



69
70
71
72
73
74
75
76
77
# File 'lib/furnish/test.rb', line 69

def setup # :nodoc:
  super
  if $sched
    @sched = $sched
  end
  @sched ||= Furnish::Scheduler.new
  @monitor = Thread.new { loop { @sched.running?; sleep 1 } }
  @monitor.abort_on_exception = true
end

#teardownObject

:nodoc:



79
80
81
82
# File 'lib/furnish/test.rb', line 79

def teardown # :nodoc:
  @monitor.kill rescue nil
  super
end