From 80fdfbf8099d8e802b9faaef2eda1ffdb787d1ce Mon Sep 17 00:00:00 2001 From: eregon Date: Wed, 27 Jun 2018 11:37:19 +0000 Subject: Update to ruby/mspec@7074b56 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/mspec/spec/guards/feature_spec.rb | 40 +++++++++++++++++++++++++++++++ spec/mspec/spec/matchers/be_close_spec.rb | 10 ++++---- 2 files changed, 46 insertions(+), 4 deletions(-) (limited to 'spec/mspec/spec') diff --git a/spec/mspec/spec/guards/feature_spec.rb b/spec/mspec/spec/guards/feature_spec.rb index d14e5f8e67..8761cb2fbb 100644 --- a/spec/mspec/spec/guards/feature_spec.rb +++ b/spec/mspec/spec/guards/feature_spec.rb @@ -78,3 +78,43 @@ describe Object, "#with_feature" do ScratchPad.recorded.should be_nil end end + +describe Object, "#without_feature" do + before :each do + ScratchPad.clear + + @guard = FeatureGuard.new :encoding + FeatureGuard.stub(:new).and_return(@guard) + end + + it "sets the name of the guard to :without_feature" do + without_feature(:encoding) { } + @guard.name.should == :without_feature + end + + it "calls #unregister even when an exception is raised in the guard block" do + @guard.should_receive(:match?).and_return(false) + @guard.should_receive(:unregister) + lambda do + without_feature { raise Exception } + end.should raise_error(Exception) + end +end + +describe Object, "#without_feature" do + before :each do + ScratchPad.clear + end + + it "does not yield if the feature is enabled" do + MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true) + without_feature(:encoding) { ScratchPad.record :yield } + ScratchPad.recorded.should be_nil + end + + it "yields if the feature is disabled" do + MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false) + without_feature(:encoding) { ScratchPad.record :yield } + ScratchPad.recorded.should == :yield + end +end diff --git a/spec/mspec/spec/matchers/be_close_spec.rb b/spec/mspec/spec/matchers/be_close_spec.rb index 9b6e56e6d5..6edff98e4a 100644 --- a/spec/mspec/spec/matchers/be_close_spec.rb +++ b/spec/mspec/spec/matchers/be_close_spec.rb @@ -16,12 +16,14 @@ describe BeCloseMatcher do BeCloseMatcher.new(5.0, 0.5).matches?(4.51).should == true end - it "does not match when actual == (expected + tolerance)" do - BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == false + it "matches when actual == (expected + tolerance)" do + BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == true + BeCloseMatcher.new(3, 2).matches?(5).should == true end - it "does not match when actual == (expected - tolerance)" do - BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == false + it "matches when actual == (expected - tolerance)" do + BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == true + BeCloseMatcher.new(3, 2).matches?(1).should == true end it "does not match when actual < (expected - tolerance)" do -- cgit v1.2.3