Permalink
Browse files

Add specs for Vim::Flavor::Version

  • Loading branch information...
1 parent a9692c8 commit eb112e9d1ab8ed859fc2a5fbf98662d55f136367 @kana committed Mar 2, 2013
Showing with 66 additions and 0 deletions.
  1. +66 −0 spec/version_spec.rb
View
@@ -0,0 +1,66 @@
+require 'spec_helper'
+
+module Vim
+ module Flavor
+ describe Version do
+ describe '::create' do
+ it 'accept "X.Y.Z" style tags' do
+ expect {
+ Version.create('1')
+ Version.create('1.2')
+ Version.create('1.2.3')
+ }.not_to raise_error
+ end
+
+ it 'accept "vX.Y.Z" style tags' do
+ expect {
+ Version.create('v1')
+ Version.create('v1.2')
+ Version.create('v1.2.3')
+ }.not_to raise_error
+ end
+ end
+
+ describe '::correct?' do
+ it 'accept "X.Y.Z" style tags' do
+ Version.correct?('1').should be_true
+ Version.correct?('1.2').should be_true
+ Version.correct?('1.2.3').should be_true
+ end
+
+ it 'accept "vX.Y.Z" style tags' do
+ Version.correct?('v1').should be_true
+ Version.correct?('v1.2').should be_true
+ Version.correct?('v1.2.3').should be_true
+ end
+ end
+
+ describe '#<=>' do
+ it 'can comapre "X.Y.Z" tags' do
+ Version.create('1.2.3').should be <= Version.create('1.3')
+ Version.create('1.2.3').should be == Version.create('1.2.3')
+ Version.create('1.2.3').should be >= Version.create('1.1')
+ end
+
+ it 'can comapre "vX.Y.Z" tags' do
+ Version.create('v1.2.3').should be <= Version.create('v1.3')
+ Version.create('v1.2.3').should be == Version.create('v1.2.3')
+ Version.create('v1.2.3').should be >= Version.create('v1.1')
+ end
+
+ it 'can comapre "X.Y.Z" tag with "vX.Y.Z" tag' do
+ Version.create('1.2.3').should be <= Version.create('v1.3')
+ Version.create('1.2.3').should be == Version.create('v1.2.3')
+ Version.create('1.2.3').should be >= Version.create('v1.1')
+ end
+ end
+
+ describe '#to_s' do
+ it 'is converted into the original string' do
+ Version.create('1.2.3').to_s.should == '1.2.3'
+ Version.create('v1.2.3').to_s.should == 'v1.2.3'
+ end
+ end
+ end
+ end
+end

0 comments on commit eb112e9

Please sign in to comment.