require 'spec_helper' require 'helpers/ci' require 'helpers/git' require 'helpers/string' require 'helpers/sprintly' require 'helpers/cache' require 'pp' 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#parse_commit_message' do it 'returns a populated hash' do hash = Git.parse_commit_message("Fixes #1, #2 ") expect(hash[:deploy][:match]).to eq(true) pp hash[:sprintly] expect(hash[:sprintly].first).to eq(1) expect(hash[:sprintly].last).to eq(2) end end RSpec.describe 'Sprintly#retrieveSprintlyItem' do it 'returns hackpad item' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(1) expect(item.specs.count).to eq(1) end end RSpec.describe 'Sprintly#retrieveSprintlyItem' do it 'returns sprintly item with id' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(1) expect(item.id).to eq(1) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.allHackpads' do it 'returns single hackpad item' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(2) expect(item.specs.count).to eq(0) expect(item.all_specs.count).to eq(1) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.allHackpads' do it 'returns multiple hackpad items' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(4) expect(item.specs.count).to eq(1) expect(item.all_specs.count).to eq(2) end end RSpec.describe 'sprintly_item supports Dropbox notes' do it 'returns single dropbox note item' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(5) expect(item.specs.count).to eq(1) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.inspect' do it 'returns beautiful description' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(4) expect(item.inspect).to eq("") end end RSpec.describe 'Sprintly#retrieveSprintlyItem.all_items' do it 'returns single item' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(1) expect(item.all_items.count).to eq(1) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.all_items' do it 'returns mutliple items' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(4) expect(item.all_items.count).to eq(2) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.isStory?' do it 'returns story' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(1) expect(item.is_story?).to eq(true) end end RSpec.describe 'Sprintly#retrieveSprintlyItem.isStory?' do it 'returns subtask' do cache = Cache.new sprintly = Sprintly.new(30420,"jono+overview+test@overllc.com", "kPnNLnM8pjkYeS9sMvrQPhj6JkC4mcNL", cache) item = sprintly.sprintly_item(2) expect(item.is_story?).to eq(false) end end RSpec.describe 'SprintlyEmbeddedURL#new' do it 'returns SprintlyEmbeddedURL' do url = SprintlyEmbeddedURL.new("https://hackpad.com/Hackpad-FAQ-tq56fI63mz3") expect(url.to_s).to eq("") end end