Sha256: b127ea6fcca9a213a83cfaf22a5fa363dd2b6f27a5840d8dd5b0d538008f073b

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

require "spec_helper"

describe Rector::Worker do
  let(:worker_id) { "zyx987:abc123" }
  subject         { described_class.new(worker_id) }

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

  it "is initialized with a worker ID" do
    subject.id.should == worker_id
  end

  it "knows its job ID" do
    subject.job_id.should == "zyx987"
  end

  it "notifies the backend of workers being created" do
    backend.expects(:add_worker).with(worker_id)
    subject
  end

  describe "#finish" do
    it "notifies the backend" do
      backend.expects(:finish_worker).with(worker_id)
      subject.finish
    end

    it "saves data" do
      subject.data["foo"] = "bar"

      backend.expects(:update_job_data_from_hash).with("foo" => "bar")
      subject.finish
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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