summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/build/port_spec.rb
blob: 1413780dfa65a5f38f569effb15dc7aac286b6e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Ci::Build::Port do
  subject { described_class.new(port) }

  context 'when port is defined as an integer' do
    let(:port) { 80 }

    it 'populates the object' do
      expect(subject.number).to eq 80
      expect(subject.protocol).to eq described_class::DEFAULT_PORT_PROTOCOL
      expect(subject.name).to eq described_class::DEFAULT_PORT_NAME
    end
  end

  context 'when port is defined as hash' do
    let(:port) { { number: 80, protocol: 'https', name: 'port_name' } }

    it 'populates the object' do
      expect(subject.number).to eq 80
      expect(subject.protocol).to eq 'https'
      expect(subject.name).to eq 'port_name'
    end
  end
end