diff --git a/lib/oauth2/version.rb b/lib/oauth2/version.rb index 2efb2a36..9dba3aa2 100644 --- a/lib/oauth2/version.rb +++ b/lib/oauth2/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module OAuth2 module Version VERSION = to_s @@ -22,12 +24,12 @@ def minor # # @return [Integer] def patch - 6 + 7 end # The pre-release version, if any # - # @return [Integer, NilClass] + # @return [String, NilClass] def pre nil end @@ -55,7 +57,9 @@ def to_a # # @return [String] def to_s - to_a.join('.') + v = [major, minor, patch].compact.join('.') + v += "-#{pre}" if pre + v end end end diff --git a/spec/oauth2/version_spec.rb b/spec/oauth2/version_spec.rb index 3e395eac..854f1bc0 100644 --- a/spec/oauth2/version_spec.rb +++ b/spec/oauth2/version_spec.rb @@ -1,5 +1,23 @@ -describe OAuth2::Version do - it 'VERSION a sting' do - expect(OAuth2::Version::VERSION).to be_a(String) +# frozen_string_literal: true + +RSpec.describe OAuth2::Version do + it 'has a version number' do + expect(described_class).not_to be nil + end + + it 'can be a string' do + expect(described_class.to_s).to be_a(String) + end + + it 'allows Constant access' do + expect(described_class::VERSION).to be_a(String) + end + + it 'is greater than 0.1.0' do + expect(Gem::Version.new(described_class) > Gem::Version.new('0.1.0')).to be(true) + end + + it 'is not a pre-release' do + expect(Gem::Version.new(described_class).prerelease?).to be(false) end end