require 'spec_helper' require 'helpers/ci' require 'helpers/git' RSpec.describe 'CI#build_no' do it 'returns build number' do build_no = ENV['TRAVIS_BUILD_NUMBER'] || ENV['CIRCLE_BUILD_NUM'] || '1' expect(CI.build_no).to eq(build_no) end end RSpec.describe 'Git#clean_tag' do context '1.2.3-rc4' do it 'returns semantic version' do expect(Git.clean_tag('1.2.3-rc4')).to eq('1.2.3') end end context '1.2-rc4' do it 'returns semantic version' do expect(Git.clean_tag('1.2-rc4')).to eq('1.2') end end it '1.2-rc4 returns semantic version' do expect(Git.clean_tag('1.2-rc4')).to eq('1.2') end it '1.2.3 returns semantic version' do expect(Git.clean_tag('1.2.3')).to eq('1.2.3') end it '1.2.3.4 returns semantic version' do expect(Git.clean_tag('1.2.3.4')).to eq('1.2.3') end it '1.2.rc4 returns semantic version' do expect(Git.clean_tag('1.2.rc4')).to eq('1.2') end it '1.2.3.rc4 returns semantic version' do expect(Git.clean_tag('1.2.3.rc4')).to eq('1.2.3') end it '1.rc4 returns semantic version' do expect(Git.clean_tag('1.rc4')).to eq('1') end it '1 returns semantic version' do expect(Git.clean_tag('1')).to eq('1') end end RSpec.describe 'CI#tagged_build?' do it 'v0.0.3.5 returns true' do expect(CI.tagged_build?('v0.0.3.5')).to eq(true) end it 'EMPTY returns false' do expect(CI.tagged_build?('EMPTY')).to eq(false) end end RSpec.describe 'Git#parse_deploy' do it ' returns true, deploy message' do deploy, message = Git.parse_deploy('This is my change . Ref #123. This is my second ') expect(deploy).to eq(true) expect(message).to eq('deploy message') end it ' returns true, deploy message' do deploy, message = Git.parse_deploy('This is my change . Ref #123') expect(deploy).to eq(true) expect(message).to eq('deploy message') end it ' returns true, message' do deploy, message = Git.parse_deploy('This is my change . Ref #123') expect(deploy).to eq(true) expect(message).to eq('') end it 'No brackets returns false, empty message' do deploy, message = Git.parse_deploy('This is my change. deploy. Ref #123') expect(deploy).to eq(false) expect(message).to eq('') end it "Empty string returns false, empty message" do deploy, message = Git.parse_deploy('') expect(deploy).to eq(false) expect(message).to eq('') end it 'Missing closing bracket returns true, deploy message' do deploy, message = Git.parse_deploy('This is my change 1 end end RSpec.describe 'Git#repo' do it 'returns a repo' do expect(Git.repo.length).to be > 1 end end