spec/helpers_spec.rb in overview-0.0.4.17 vs spec/helpers_spec.rb in overview-0.0.5.pre.22

- old
+ new

@@ -1,18 +1,50 @@ 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 @@ -56,41 +88,47 @@ end end RSpec.describe 'Git#parse_deploy' do - - it '<DEPLOY: deploy message> returns true, deploy message' do - deploy, message = Git.parse_deploy('This is my change <DEPLOY: deploy message>. Ref #123. This is my second <deploy>') - expect(deploy).to eq(true) - expect(message).to eq('deploy message') + it '<DEPLOY: deploy message #channel> returns true, deploy message, channel' do + result = Git.parse_deploy('This is my change <DEPLOY: #channel deploy message #channel>. Ref #123. This is my second <deploy>') + expect(result[:match]).to eq(true) + expect(result[:message]).to eq('deploy message') + expect(result[:channel]).to eq('#channel') end + it '<DEPLOY: @jono deploy message> returns true, deploy message' do + result = Git.parse_deploy('This is my change <DEPLOY: @jono deploy message>. Ref #123. This is my second <deploy>') + expect(result[:match]).to eq(true) + expect(result[:message]).to eq('deploy message') + expect(result[:channel]).to eq('@jono') + end it '<deploy:deploy message> returns true, deploy message' do - deploy, message = Git.parse_deploy('This is my change <deploy:deploy message>. Ref #123') - expect(deploy).to eq(true) - expect(message).to eq('deploy message') + result = Git.parse_deploy('This is my change <deploy:deploy message>. Ref #123') + expect(result[:match]).to eq(true) + expect(result[:message]).to eq('deploy message') end - it '<deploy> returns true, message' do - deploy, message = Git.parse_deploy('This is my change <deploy>. Ref #123') - expect(deploy).to eq(true) - expect(message).to eq('') + it '<deploy> returns true, empty message' do + result = Git.parse_deploy('This is my change <deploy>. Ref #123') + expect(result[:match]).to eq(true) + expect(result[: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('') + 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 - deploy, message = Git.parse_deploy('') - expect(deploy).to eq(false) - expect(message).to eq('') + result = Git.parse_deploy('') + expect(result[:match]).to eq(false) + expect(result[:message]).to eq('') end - it 'Missing closing bracket returns true, deploy message' do - deploy, message = Git.parse_deploy('This is my change <DEPLOY: deploy message') - expect(deploy).to eq(false) - expect(message).to eq('') + it 'Missing closing bracket returns false, empty message' do + result = Git.parse_deploy('This is my change <DEPLOY: deploy message') + expect(result[:match]).to eq(false) + expect(result[:message]).to eq('') end end RSpec.describe 'Git#parse_crashlytics' do @@ -187,9 +225,10 @@ it 'returns a repo' do expect(Git.repo.length).to be > 1 end end +