Sha256: c4bad95e466a31ec367be8894f05ecbc380b2b337702a28221976c1a4ab8f736

Contents?: true

Size: 768 Bytes

Versions: 4

Compression:

Stored size: 768 Bytes

Contents

require "spec_helper"
require "timeout"

describe Rector::Job do
  let(:backend) { stub_everything("backend") }
  before do
    Rector.stubs(:backend_for).returns(backend)
  end

  it "constructs workers" do
    worker = subject.workers.create
    worker.should be_a(Rector::Worker)
  end

  it "waits for workers to complete" do
    backend.expects(:workers_working?).at_least_once.returns(true).then.returns(false)
    subject.stubs(:sleep)

    Timeout.timeout(2) do
      subject.join
    end
  end

  it "loads data from the backend" do
    backend.stubs(:read_job_data_to_hash).returns("foo" => "bar")
    subject.data.should == { "foo" => "bar" }
  end

  it "delegates to the backend for cleanup" do
    backend.expects(:cleanup)
    subject.cleanup
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rector-0.0.4 spec/lib/job_spec.rb
rector-0.0.3 spec/lib/job_spec.rb
rector-0.0.2 spec/lib/job_spec.rb
rector-0.0.1 spec/lib/job_spec.rb