Богомила обнови решението на 18.11.2016 21:36 (преди над 8 години)
+RSpec.describe 'Version' do
+ describe Version do
+ it 'is greater than' do
+ expect(Version.new('1.3.1') > Version.new('1.2.3')).to be true
+ expect(Version.new('1.3') > Version.new('1.2.3')).to be true
+ end
+ it 'is less than' do
+ expect(Version.new('1.2.2') < Version.new('1.3.1')).to be true
+ expect(Version.new('1.2.3') < Version.new('1.3')).to be true
+ end
+ it 'are equal' do
+ expect(Version.new('1.1.0') == Version.new('1.1')).to be true
+ expect(Version.new('0.1') == Version.new('1')).to be false
+ end
+ it 'less than or equal ' do
+ expect(Version.new('2.0.10') <= Version.new('2.0.11')).to be true
+ expect(Version.new('1.2.2') <= Version.new('1.3.1')).to be true
+ expect(Version.new('1.1.0') <= Version.new('1.1')).to be true
+ expect(Version.new('0.1') <= Version.new('1')).to be false
+ end
+ it 'greater than or equa' do
+ expect(Version.new('1.3.2') >= Version.new('1.2.3')).to be true
+ expect(Version.new('1.3') >= Version.new('1.2.2')).to be true
+ expect(Version.new('1.2.0') >= Version.new('1.2')).to be true
+ expect(Version.new('0.1') >= Version.new('1')).to be false
+ end
+ it 'greater, less or equal' do
+ expect(Version.new('1.3.1') <=> Version.new('1.2.3')).to eq 1
+ expect(Version.new('1.3') <=> Version.new('1.2.3')).to eq 1
+ expect(Version.new('1.1.0') <=> Version.new('1.1')).to eq 0
+ expect(Version.new('1.2.2') <=> Version.new('1.3.1')).to eq - 1
+ expect(Version.new('1.2.3') <=> Version.new('1.3')).to eq - 1
+ end
+ describe '#to_s ' do
+ it ' back to string' do
+ expect(Version.new('1.1.2').to_s).to eq '1.1.2'
+ expect(Version.new('1.1.0').to_s).to eq '1.1'
+ end
+ end
+ describe '#components' do
+ it 'version components' do
+ expect(Version.new('1.3.5').components).to eq [1, 3, 5]
+ expect(Version.new('1.3.0').components).to eq [1, 3]
+ end
+ end
+ end
+end
+