Sha256: abb4cc297132da77b34c9b939ecd199298efa71b1f4efcfe3f5a5dfda332f6bd

Contents?: true

Size: 804 Bytes

Versions: 6

Compression:

Stored size: 804 Bytes

Contents

require "spec_helper"

describe Chrono::Trigger do
  let(:trigger) do
    described_class.new(source, &block)
  end

  let(:source) do
    "* * * * *"
  end

  let(:block) do
    -> {}
  end

  describe "#once" do
    it "waits till scheduled time and then triggers a given job only once" do
      block.should_receive(:call)
      trigger.should_receive(:sleep)
      trigger.once
    end
  end

  # Stub Trigger#loop behavior to avoid blocking main process.
  describe "#run" do
    before do
      trigger.stub(:loop) do |&block|
        2.times do
          block.call
        end
      end
    end

    it "waits till scheduled time and then triggers a given job periodically" do
      block.should_receive(:call).twice
      trigger.should_receive(:sleep).twice
      trigger.run
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
chrono-0.1.0 spec/chrono/trigger_spec.rb
chrono-0.0.6 spec/chrono/trigger_spec.rb
chrono-0.0.5 spec/chrono/trigger_spec.rb
chrono-0.0.4 spec/chrono/trigger_spec.rb
chrono-0.0.3 spec/chrono/trigger_spec.rb
chrono-0.0.2 spec/chrono/trigger_spec.rb