BigW Consortium Gitlab

hip_chat_message_spec.rb 1.15 KB
Newer Older
1 2
require 'spec_helper'

3
describe Ci::HipChatMessage do
Dmitriy Zaporozhets committed
4
  subject { Ci::HipChatMessage.new(build) }
5

Kamil Trzcinski committed
6
  let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs) }
7

Kamil Trzcinski committed
8 9
  let(:build) do
    commit.builds.first
10 11
  end

Kamil Trzcinski committed
12 13 14 15 16
  context 'when all matrix builds succeed' do
    it 'returns a successful message' do
      commit.create_builds('master', false, nil)
      commit.builds.update_all(status: "success")
      commit.reload
17

Kamil Trzcinski committed
18 19 20 21
      expect(subject.status_color).to eq 'green'
      expect(subject.notify?).to be_falsey
      expect(subject.to_s).to match(/Commit #\d+/)
      expect(subject.to_s).to match(/Successful in \d+ second\(s\)\./)
22
    end
Kamil Trzcinski committed
23
  end
24

Kamil Trzcinski committed
25 26 27 28 29 30 31 32 33 34 35 36
  context 'when at least one matrix build fails' do
    it 'returns a failure message' do
      commit.create_builds('master', false, nil)
      first_build = commit.builds.first
      second_build = commit.builds.last
      first_build.update(status: "success")
      second_build.update(status: "failed")

      expect(subject.status_color).to eq 'red'
      expect(subject.notify?).to be_truthy
      expect(subject.to_s).to match(/Commit #\d+/)
      expect(subject.to_s).to match(/Failed in \d+ second\(s\)\./)
37 38 39
    end
  end
end