summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/guards/version_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/spec/guards/version_spec.rb')
-rw-r--r--spec/mspec/spec/guards/version_spec.rb92
1 files changed, 46 insertions, 46 deletions
diff --git a/spec/mspec/spec/guards/version_spec.rb b/spec/mspec/spec/guards/version_spec.rb
index b0025efcfb..5a5f4ddc3b 100644
--- a/spec/mspec/spec/guards/version_spec.rb
+++ b/spec/mspec/spec/guards/version_spec.rb
@@ -11,102 +11,102 @@ require 'mspec/guards'
# is as typically understood: a..b means v >= a and v <= b;
# a...b means v >= a and v < b.
-describe VersionGuard, "#match?" do
+RSpec.describe VersionGuard, "#match?" do
before :each do
hide_deprecation_warnings
@current = '1.8.6'
end
it "returns true when the argument is equal to RUBY_VERSION" do
- VersionGuard.new(@current, '1.8.6').match?.should == true
+ expect(VersionGuard.new(@current, '1.8.6').match?).to eq(true)
end
it "returns true when the argument is less than RUBY_VERSION" do
- VersionGuard.new(@current, '1.8').match?.should == true
- VersionGuard.new(@current, '1.8.5').match?.should == true
+ expect(VersionGuard.new(@current, '1.8').match?).to eq(true)
+ expect(VersionGuard.new(@current, '1.8.5').match?).to eq(true)
end
it "returns false when the argument is greater than RUBY_VERSION" do
- VersionGuard.new(@current, '1.8.7').match?.should == false
- VersionGuard.new(@current, '1.9.2').match?.should == false
+ expect(VersionGuard.new(@current, '1.8.7').match?).to eq(false)
+ expect(VersionGuard.new(@current, '1.9.2').match?).to eq(false)
end
it "returns true when the argument range includes RUBY_VERSION" do
- VersionGuard.new(@current, '1.8.5'..'1.8.7').match?.should == true
- VersionGuard.new(@current, '1.8'..'1.9').match?.should == true
- VersionGuard.new(@current, '1.8'...'1.9').match?.should == true
- VersionGuard.new(@current, '1.8'..'1.8.6').match?.should == true
- VersionGuard.new(@current, '1.8.5'..'1.8.6').match?.should == true
- VersionGuard.new(@current, ''...'1.8.7').match?.should == true
+ expect(VersionGuard.new(@current, '1.8.5'..'1.8.7').match?).to eq(true)
+ expect(VersionGuard.new(@current, '1.8'..'1.9').match?).to eq(true)
+ expect(VersionGuard.new(@current, '1.8'...'1.9').match?).to eq(true)
+ expect(VersionGuard.new(@current, '1.8'..'1.8.6').match?).to eq(true)
+ expect(VersionGuard.new(@current, '1.8.5'..'1.8.6').match?).to eq(true)
+ expect(VersionGuard.new(@current, ''...'1.8.7').match?).to eq(true)
end
it "returns false when the argument range does not include RUBY_VERSION" do
- VersionGuard.new(@current, '1.8.7'..'1.8.9').match?.should == false
- VersionGuard.new(@current, '1.8.4'..'1.8.5').match?.should == false
- VersionGuard.new(@current, '1.8.4'...'1.8.6').match?.should == false
- VersionGuard.new(@current, '1.8.5'...'1.8.6').match?.should == false
- VersionGuard.new(@current, ''...'1.8.6').match?.should == false
+ expect(VersionGuard.new(@current, '1.8.7'..'1.8.9').match?).to eq(false)
+ expect(VersionGuard.new(@current, '1.8.4'..'1.8.5').match?).to eq(false)
+ expect(VersionGuard.new(@current, '1.8.4'...'1.8.6').match?).to eq(false)
+ expect(VersionGuard.new(@current, '1.8.5'...'1.8.6').match?).to eq(false)
+ expect(VersionGuard.new(@current, ''...'1.8.6').match?).to eq(false)
end
end
-describe Object, "#ruby_version_is" do
+RSpec.describe Object, "#ruby_version_is" do
before :each do
@guard = VersionGuard.new '1.2.3', 'x.x.x'
- VersionGuard.stub(:new).and_return(@guard)
+ allow(VersionGuard).to receive(:new).and_return(@guard)
ScratchPad.clear
end
it "yields when #match? returns true" do
- @guard.stub(:match?).and_return(true)
+ allow(@guard).to receive(:match?).and_return(true)
ruby_version_is('x.x.x') { ScratchPad.record :yield }
- ScratchPad.recorded.should == :yield
+ expect(ScratchPad.recorded).to eq(:yield)
end
it "does not yield when #match? returns false" do
- @guard.stub(:match?).and_return(false)
+ allow(@guard).to receive(:match?).and_return(false)
ruby_version_is('x.x.x') { ScratchPad.record :yield }
- ScratchPad.recorded.should_not == :yield
+ expect(ScratchPad.recorded).not_to eq(:yield)
end
it "returns what #match? returns when no block is given" do
- @guard.stub(:match?).and_return(true)
- ruby_version_is('x.x.x').should == true
- @guard.stub(:match?).and_return(false)
- ruby_version_is('x.x.x').should == false
+ allow(@guard).to receive(:match?).and_return(true)
+ expect(ruby_version_is('x.x.x')).to eq(true)
+ allow(@guard).to receive(:match?).and_return(false)
+ expect(ruby_version_is('x.x.x')).to eq(false)
end
it "sets the name of the guard to :ruby_version_is" do
ruby_version_is("") { }
- @guard.name.should == :ruby_version_is
+ expect(@guard.name).to eq(:ruby_version_is)
end
it "calls #unregister even when an exception is raised in the guard block" do
- @guard.should_receive(:match?).and_return(true)
- @guard.should_receive(:unregister)
- lambda do
+ expect(@guard).to receive(:match?).and_return(true)
+ expect(@guard).to receive(:unregister)
+ expect do
ruby_version_is("") { raise Exception }
- end.should raise_error(Exception)
+ end.to raise_error(Exception)
end
end
-describe Object, "#version_is" do
+RSpec.describe Object, "#version_is" do
before :each do
hide_deprecation_warnings
end
it "returns the expected values" do
- version_is('1.2.3', '1.2.2').should == true
- version_is('1.2.3', '1.2.3').should == true
- version_is('1.2.3', '1.2.4').should == false
-
- version_is('1.2.3', '1').should == true
- version_is('1.2.3', '1.0').should == true
- version_is('1.2.3', '2').should == false
- version_is('1.2.3', '2.0').should == false
-
- version_is('1.2.3', '1.2.2'..'1.2.4').should == true
- version_is('1.2.3', '1.2.2'..'1.2.3').should == true
- version_is('1.2.3', '1.2.2'...'1.2.3').should == false
- version_is('1.2.3', '1.2.3'..'1.2.4').should == true
+ expect(version_is('1.2.3', '1.2.2')).to eq(true)
+ expect(version_is('1.2.3', '1.2.3')).to eq(true)
+ expect(version_is('1.2.3', '1.2.4')).to eq(false)
+
+ expect(version_is('1.2.3', '1')).to eq(true)
+ expect(version_is('1.2.3', '1.0')).to eq(true)
+ expect(version_is('1.2.3', '2')).to eq(false)
+ expect(version_is('1.2.3', '2.0')).to eq(false)
+
+ expect(version_is('1.2.3', '1.2.2'..'1.2.4')).to eq(true)
+ expect(version_is('1.2.3', '1.2.2'..'1.2.3')).to eq(true)
+ expect(version_is('1.2.3', '1.2.2'...'1.2.3')).to eq(false)
+ expect(version_is('1.2.3', '1.2.3'..'1.2.4')).to eq(true)
end
end