Skip to content

Commit

Permalink
Prepare to release v0.9.0 (#1466)
Browse files Browse the repository at this point in the history
* Prepare to release v0.9.0
* Use dev flag to indicate dev/release versions
  • Loading branch information
nitinmohan87 committed Mar 14, 2020
1 parent 6b5c6f2 commit 3cb985f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,3 +21,4 @@ coverage
.ruby-version
.tool-versions
NOTES
*.swp
18 changes: 12 additions & 6 deletions lib/errbit/version.rb
Expand Up @@ -2,12 +2,18 @@

module Errbit
class Version
def initialize(ver, dev = false)
@version = ver
@dev = dev
end

def full_version
[
'0.9.0',
'dev',
source_version
].compact.join('-')
full = [@version]
if @dev
full << "dev"
full << source_version
end
full.compact.join('-')
end

def source_version
Expand All @@ -16,5 +22,5 @@ def source_version
end
end

VERSION = Version.new.full_version
VERSION = Version.new('0.9.0').full_version
end
35 changes: 28 additions & 7 deletions spec/lib/errbit/version_spec.rb
@@ -1,13 +1,34 @@
describe Errbit::VERSION do
subject { Errbit::Version.new.full_version }
let(:version) { '0.0.0' }

it 'handles a missing commit sha' do
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { nil }
expect(subject).to end_with('dev')
context "release version" do
subject { Errbit::Version.new(version).full_version }

it 'generates a release version' do
expect(subject).to eq(version)
end

it 'does not use a commit sha' do
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
expect(subject).to eq(version)
end
end

it 'shortens a present commit sha' do
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
expect(subject).to end_with('dev-abcd1234')
context "dev version" do
subject { Errbit::Version.new(version, true).full_version }

it 'generates a dev version' do
expect(subject).to end_with('dev')
end

it 'handles a missing commit sha' do
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { nil }
expect(subject).to end_with('dev')
end

it 'shortens a present commit sha' do
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
expect(subject).to end_with('dev-abcd1234')
end
end
end

0 comments on commit 3cb985f

Please sign in to comment.