public
Description: RSpec-syntax compatible framework for RubySpecs
Homepage: http://rubyspec.org
Clone URL: git://github.com/brixen/mspec.git
Fix ruby_version_is guard to use Integers for performance on 1.9.
Brian Ford (author)
Fri May 23 22:00:07 -0700 2008
commit  f54c60ac9c4ac2c62b3d807d7b5f31666a7414f4
tree    b1203653fe1d9283c8cb246ed02974939e9654f0
parent  5574a73d0ac30fb70198ff165b6be4f8c078a35a
...
14
15
16
17
 
18
19
20
...
23
24
25
26
 
27
28
29
...
14
15
16
 
17
18
19
20
...
23
24
25
 
26
27
28
29
0
@@ -14,7 +14,7 @@ class VersionGuard < SpecGuard
0
 
0
   def to_v(str)
0
     major, minor, tiny, patch = str.split "."
0
-    "%02d%02d%02d%04d" % [major, minor, tiny, patch].map { |x| x.to_i }
0
+    ("1%02d%02d%02d%04d" % [major, minor, tiny, patch].map { |x| x.to_i }).to_i
0
   end
0
 
0
   def ruby_version
0
@@ -23,7 +23,7 @@ class VersionGuard < SpecGuard
0
 
0
   def match?
0
     case @version
0
-    when String
0
+    when Integer
0
       ruby_version >= @version
0
     when Range
0
       @version.include? ruby_version
...
37
38
39
40
 
41
42
43
...
47
48
49
50
 
51
52
53
54
55
56
 
 
 
57
58
59
...
37
38
39
 
40
41
42
43
...
47
48
49
 
50
51
52
53
 
 
 
54
55
56
57
58
59
0
@@ -37,7 +37,7 @@ describe VersionGuard, "#ruby_version" do
0
   end
0
 
0
   it "returns 'RUBY_VERSION.RUBY_PATCHLEVEL'" do
0
-    @guard.ruby_version.should == '0108060114'
0
+    @guard.ruby_version.should == 10108060114
0
   end
0
 end
0
 
0
@@ -47,13 +47,13 @@ describe VersionGuard, "#to_v" do
0
   end
0
 
0
   it "returns a version string containing only digits" do
0
-    @guard.to_v("1.8.6.22").should == "0108060022"
0
+    @guard.to_v("1.8.6.22").should == 10108060022
0
   end
0
 
0
   it "replaces missing version parts with zeros" do
0
-    @guard.to_v("1.8").should == "0108000000"
0
-    @guard.to_v("1.8.6").should == "0108060000"
0
-    @guard.to_v("1.8.7.333").should == "0108070333"
0
+    @guard.to_v("1.8").should == 10108000000
0
+    @guard.to_v("1.8.6").should == 10108060000
0
+    @guard.to_v("1.8.7.333").should == 10108070333
0
   end
0
 end
0
 

Comments