|
14 | 14 | describe VersionGuard, "#match?" do
|
15 | 15 | before :each do
|
16 | 16 | hide_deprecation_warnings
|
17 |
| - stub_const "VersionGuard::FULL_RUBY_VERSION", SpecVersion.new('1.8.6') |
| 17 | + @current = '1.8.6' |
18 | 18 | end
|
19 | 19 |
|
20 | 20 | it "returns true when the argument is equal to RUBY_VERSION" do
|
21 |
| - VersionGuard.new('1.8.6').match?.should == true |
| 21 | + VersionGuard.new(@current, '1.8.6').match?.should == true |
22 | 22 | end
|
23 | 23 |
|
24 | 24 | it "returns true when the argument is less than RUBY_VERSION" do
|
25 |
| - VersionGuard.new('1.8').match?.should == true |
26 |
| - VersionGuard.new('1.8.5').match?.should == true |
| 25 | + VersionGuard.new(@current, '1.8').match?.should == true |
| 26 | + VersionGuard.new(@current, '1.8.5').match?.should == true |
27 | 27 | end
|
28 | 28 |
|
29 | 29 | it "returns false when the argument is greater than RUBY_VERSION" do
|
30 |
| - VersionGuard.new('1.8.7').match?.should == false |
31 |
| - VersionGuard.new('1.9.2').match?.should == false |
| 30 | + VersionGuard.new(@current, '1.8.7').match?.should == false |
| 31 | + VersionGuard.new(@current, '1.9.2').match?.should == false |
32 | 32 | end
|
33 | 33 |
|
34 | 34 | it "returns true when the argument range includes RUBY_VERSION" do
|
35 |
| - VersionGuard.new('1.8.5'..'1.8.7').match?.should == true |
36 |
| - VersionGuard.new('1.8'..'1.9').match?.should == true |
37 |
| - VersionGuard.new('1.8'...'1.9').match?.should == true |
38 |
| - VersionGuard.new('1.8'..'1.8.6').match?.should == true |
39 |
| - VersionGuard.new('1.8.5'..'1.8.6').match?.should == true |
40 |
| - VersionGuard.new(''...'1.8.7').match?.should == true |
| 35 | + VersionGuard.new(@current, '1.8.5'..'1.8.7').match?.should == true |
| 36 | + VersionGuard.new(@current, '1.8'..'1.9').match?.should == true |
| 37 | + VersionGuard.new(@current, '1.8'...'1.9').match?.should == true |
| 38 | + VersionGuard.new(@current, '1.8'..'1.8.6').match?.should == true |
| 39 | + VersionGuard.new(@current, '1.8.5'..'1.8.6').match?.should == true |
| 40 | + VersionGuard.new(@current, ''...'1.8.7').match?.should == true |
41 | 41 | end
|
42 | 42 |
|
43 | 43 | it "returns false when the argument range does not include RUBY_VERSION" do
|
44 |
| - VersionGuard.new('1.8.7'..'1.8.9').match?.should == false |
45 |
| - VersionGuard.new('1.8.4'..'1.8.5').match?.should == false |
46 |
| - VersionGuard.new('1.8.4'...'1.8.6').match?.should == false |
47 |
| - VersionGuard.new('1.8.5'...'1.8.6').match?.should == false |
48 |
| - VersionGuard.new(''...'1.8.6').match?.should == false |
| 44 | + VersionGuard.new(@current, '1.8.7'..'1.8.9').match?.should == false |
| 45 | + VersionGuard.new(@current, '1.8.4'..'1.8.5').match?.should == false |
| 46 | + VersionGuard.new(@current, '1.8.4'...'1.8.6').match?.should == false |
| 47 | + VersionGuard.new(@current, '1.8.5'...'1.8.6').match?.should == false |
| 48 | + VersionGuard.new(@current, ''...'1.8.6').match?.should == false |
49 | 49 | end
|
50 | 50 | end
|
51 | 51 |
|
52 | 52 | describe Object, "#ruby_version_is" do
|
53 | 53 | before :each do
|
54 |
| - @guard = VersionGuard.new 'x.x.x' |
| 54 | + @guard = VersionGuard.new '1.2.3', 'x.x.x' |
55 | 55 | VersionGuard.stub(:new).and_return(@guard)
|
56 | 56 | ScratchPad.clear
|
57 | 57 | end
|
|
88 | 88 | end.should raise_error(Exception)
|
89 | 89 | end
|
90 | 90 | end
|
| 91 | + |
| 92 | +describe Object, "#version_is" do |
| 93 | + before :each do |
| 94 | + hide_deprecation_warnings |
| 95 | + end |
| 96 | + |
| 97 | + it "returns the expected values" do |
| 98 | + version_is('1.2.3', '1.2.2').should == true |
| 99 | + version_is('1.2.3', '1.2.3').should == true |
| 100 | + version_is('1.2.3', '1.2.4').should == false |
| 101 | + |
| 102 | + version_is('1.2.3', '1').should == true |
| 103 | + version_is('1.2.3', '1.0').should == true |
| 104 | + version_is('1.2.3', '2').should == false |
| 105 | + version_is('1.2.3', '2.0').should == false |
| 106 | + |
| 107 | + version_is('1.2.3', '1.2.2'..'1.2.4').should == true |
| 108 | + version_is('1.2.3', '1.2.2'..'1.2.3').should == true |
| 109 | + version_is('1.2.3', '1.2.2'...'1.2.3').should == false |
| 110 | + version_is('1.2.3', '1.2.3'..'1.2.4').should == true |
| 111 | + end |
| 112 | +end |
0 commit comments