Sha256: 6c5aa66c183fd17f85c7b0aad41f6cec869d02c500312bd4c3fb523099c8ff1a

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Evrone::CI::Worker::Job do
  let(:message) { create :message, 'PerformJob' }
  let(:job)     { described_class.new message   }

  subject { job }

  context "just created" do
    its(:message)       { should eq message }
  end

  context "create_job_log_message" do
    let(:tm)   { Time.new(2012, 12, 10, 15, 45) }
    let(:data) { 'log' }
    subject { job.create_job_log_message data }

    before do
      mock(Time).now { tm }
    end

    it { should be_an_instance_of(Evrone::CI::Message::JobLog) }
    its(:job_id)   { should eq job.message.job_id }
    its(:build_id) { should eq job.message.id     }
    its(:tm)       { should eq tm.to_i }
    its(:log)      { should eq data }
  end

  context "add_to_output" do
    let(:data)     { 'data' }
    let(:messages) { Evrone::CI::Worker::JobLogsConsumer.messages }
    subject { job.add_to_output(data) ; job }

    its(:output) { should eq data }
    it "should delivery message" do
      expect {
        subject
      }.to change(messages, :size).by(1)
    end
  end

  context "add_command_to_output" do
    let(:data)     { 'data' }
    let(:messages) { Evrone::CI::Worker::JobLogsConsumer.messages }
    subject { job.add_command_to_output(data) ; job }

    its(:output) { should eq "$ #{data}\n" }
    it "should delivery message" do
      expect {
        subject
      }.to change(messages, :size).by(1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre1 spec/lib/worker/job_spec.rb
evrone-ci-worker-0.2.0.pre0 spec/lib/worker/job_spec.rb