Sha256: 31e06f81a145938353c2e44f264d27a1f5d0a5ab669320d0c8c49703107577ca
Contents?: true
Size: 1.62 KB
Versions: 19
Compression:
Stored size: 1.62 KB
Contents
require 'spec_helper' describe Evrone::CI::Worker::UpdateJobStatus do let(:exit_code) { 0 } let(:app) { ->(_) { exit_code } } let(:job) { create :job } let(:env) { OpenStruct.new job: job } let(:mid) { described_class.new app } let(:messages) { Evrone::CI::Worker::JobStatusConsumer.messages } subject { mid.call env } it "should delivery 2 messages" do expect { subject }.to change(messages, :size).by(2) end { 0 => 3, 1 => 4, -1 => 5 }.each do |code, status| context "when exit code is #{code}" do let(:exit_code) { code } it { should eq code } context "messages" do before { mid.call env } context "first" do subject { messages.first } it_should_behave_like "UpdateJobStatus message" do its(:status) { should eq 2 } end end context "last" do subject { messages.last } it_should_behave_like "UpdateJobStatus message" do its(:status) { should eq status } end end end end end context "when raise exception" do let(:app) { ->(_) { raise "Ignore Me" } } it { should eq(-1) } context "messages" do before { mid.call env } context "first" do subject { messages.first } it_should_behave_like "UpdateJobStatus message" do its(:status) { should eq 2 } end end context "last" do subject { messages.last } it_should_behave_like "UpdateJobStatus message" do its(:status) { should eq 5 } end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems