require 'spec_helper' require 'helpers/ci' require 'helpers/git' require 'helpers/string' include Helpers RSpec.describe 'String#increment_version' do it '1.2.3 returns 1.2.4' do expect('1.2.3'.increment_version).to eq('1.2.4') end it '1.2.3.pre returns 1.2.4.pre' do expect('1.2.3.pre'.increment_version).to eq('1.2.4.pre') end it '1.2.3.1 returns 1.2.4.1' do expect('1.2.3.1'.increment_version).to eq('1.2.4.1') end it '1.2 returns 1.3' do expect('1.2'.increment_version).to eq('1.3') end end 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 it '1.2.1.1 returns ruby version' do expect(Git.clean_tag('1.2.1.1', rubygem:true)).to eq('1.2.1.1') end it '1.2.1.pre returns ruby version' do expect(Git.clean_tag('1.2.1.pre', rubygem:true)).to eq('1.2.1.pre') end 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, channel' do result = Git.parse_deploy('This is my change . Ref #123. This is my second ') expect(result[:match]).to eq(true) expect(result[:message]).to eq('deploy message') expect(result[:channel]).to eq('#channel') end it ' returns true, deploy message' do result = Git.parse_deploy('This is my change . Ref #123. This is my second ') expect(result[:match]).to eq(true) expect(result[:message]).to eq('deploy message') expect(result[:channel]).to eq('@jono') end it ' returns true, deploy message' do result = Git.parse_deploy('This is my change . Ref #123') expect(result[:match]).to eq(true) expect(result[:message]).to eq('deploy message') end it ' returns true, empty message' do result = Git.parse_deploy('This is my change . Ref #123') expect(result[:match]).to eq(true) expect(result[:message]).to eq('') end it 'No brackets returns false, empty message' do result = Git.parse_deploy('This is my change. deploy. Ref #123') expect(result[:match]).to eq(false) expect(result[:message]).to eq('') end it "Empty string returns false, empty message" do result = Git.parse_deploy('') expect(result[:match]).to eq(false) expect(result[:message]).to eq('') end it 'Missing closing bracket returns false, empty message' do result = 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