Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
pzupan committed Mar 21, 2019
1 parent fa11e9e commit 900061f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/semver_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def self.call(tag)

tag
.to_s
.strip # strip off any leading or trailing /t or /n or spaces
.sub(/\Av/i, '') # strip off any leading 'v'
.strip
.strip # strip any spaces after removing "v"
# stripping hypends and underscores substantially changes the version string
#.gsub(/[-_]/, '.') # convert hyphens and underscores to dots
end
Expand Down
11 changes: 6 additions & 5 deletions spec/lib/semver_normalizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@

it 'strips off any leading "v" character' do
expect(subject.call("v790")).to eq '790'
expect(subject.call("V097")).to eq '097'
expect(subject.call("V097.1.0")).to eq '097.1.0'
expect(subject.call("V 097.1.0")).to eq '097.1.0'
end

it 'strips any leading and trailing whitespace' do
expect(subject.call("\t\nv790 ")).to eq '790'
expect(subject.call("\t\nv790.1.0 ")).to eq '790.1.0'
end

it 'replaces pseudo dots with dots' do
expect(subject.call("v7-0_9.0")).to eq '7.0.9.0'
expect(subject.call("V0.9-7_1")).to eq '0.9.7.1'
it 'does not replace underscore or hypen' do
expect(subject.call("v7.1.0-pre")).to eq '7.1.0-pre'
expect(subject.call("V0.9.1-7_1")).to eq '0.9.1-7_1'
end
end
end

0 comments on commit 900061f

Please sign in to comment.