Sha256: 94ecd2485104bc75f9139a54aa9fe6fae58c18d1b592bce9db02dc6495e872ba

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

module JstdRunner
  describe Monitorable do
    let(:object) {
      obj = Object.new

      class << obj
        attr_accessor :restarting, :running
        include Monitorable

        def running?
          @running
        end
      end

      obj
    }

    before { EM.should_receive(:add_periodic_timer).and_yield }
    after { JstdRunner.shutting_down = false }

    it "yields if self is not running" do
      did_yield = false

      object.running = false
      object.monitor(1) { did_yield = true }

      did_yield.should be_true
    end

    it "does not yield when self is running" do
      did_yield = false

      object.running = true
      object.monitor(1) { did_yield = true }

      did_yield.should be_false
    end

    it "does not check when we're shutting down" do
      JstdRunner.shutting_down = true
      object.should_not_receive :running?

      object.monitor(1) {}
    end

    it "does not check when self is restarting" do
      object.restarting = true
      object.should_not_receive :running?

      object.monitor(1) {}
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jstd-runner-0.0.9 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.8 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.7 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.6 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.5 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.4 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.3 spec/jstd-runner/monitorable_spec.rb
jstd-runner-0.0.2 spec/jstd-runner/monitorable_spec.rb