Sha256: c8689c8639b506402959dbdfc5f5d2a2d81076f609ddf07c1284c989d563e5b9

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe MB::JobManager do
  let(:fake_job) do
    Class.new do
      include Celluloid

      attr_reader :id, :type, :state, :status, :status_buffer, :result
      attr_reader :time_start, :time_end

      @id = 1
      @type = 'fake'
      @state = :pending
      @status = ""
      @status_buffer = [""]
      @result = nil
    end
  end

  before(:each) { @fake_job = fake_job.new }

  describe "#add" do
    it "adds a job to the active jobs list" do
      subject.add(@fake_job)

      subject.active.should have(1).item
      subject.active[0].id.should == @fake_job.id
      subject.active[0].should be_a(MB::JobRecord)
    end

    it "monitors the given job" do
      subject.add(@fake_job)

      subject.should be_monitoring(@fake_job)
    end
  end

  describe "#find" do
    it "returns a record of the job" do
      subject.add(@fake_job)

      subject.find(@fake_job.id).should be_a(MB::JobRecord)
    end
  end

  describe "#complete_job" do
    before(:each) do
      subject.add(@fake_job)
      subject.complete_job(@fake_job)
    end

    it "removes the given job from the active job list" do
      subject.active.should have(0).items
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
motherbrain-1.5.0 spec/unit/mb/job_manager_spec.rb
motherbrain-1.4.0 spec/unit/mb/job_manager_spec.rb
motherbrain-1.3.0 spec/unit/mb/job_manager_spec.rb
motherbrain-1.2.1 spec/unit/mb/job_manager_spec.rb
motherbrain-1.2.0 spec/unit/mb/job_manager_spec.rb
motherbrain-1.1.3 spec/unit/mb/job_manager_spec.rb
motherbrain-1.1.2 spec/unit/mb/job_manager_spec.rb
motherbrain-1.1.1 spec/unit/mb/job_manager_spec.rb
motherbrain-1.1.0 spec/unit/mb/job_manager_spec.rb
motherbrain-1.0.0 spec/unit/mb/job_manager_spec.rb
motherbrain-0.14.5 spec/unit/mb/job_manager_spec.rb
motherbrain-0.14.4 spec/unit/mb/job_manager_spec.rb
motherbrain-0.14.3 spec/unit/mb/job_manager_spec.rb
motherbrain-0.14.2 spec/unit/mb/job_manager_spec.rb
motherbrain-0.13.1 spec/unit/mb/job_manager_spec.rb