diff options
Diffstat (limited to 'spec/mspec/spec/guards/feature_spec.rb')
-rw-r--r-- | spec/mspec/spec/guards/feature_spec.rb | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/spec/mspec/spec/guards/feature_spec.rb b/spec/mspec/spec/guards/feature_spec.rb index 8761cb2fbb..fcb8997591 100644 --- a/spec/mspec/spec/guards/feature_spec.rb +++ b/spec/mspec/spec/guards/feature_spec.rb @@ -1,120 +1,120 @@ require 'spec_helper' require 'mspec/guards' -describe FeatureGuard, ".enabled?" do +RSpec.describe FeatureGuard, ".enabled?" do it "returns true if the feature is enabled" do - MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true) - FeatureGuard.enabled?(:encoding).should be_true + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(true) + expect(FeatureGuard.enabled?(:encoding)).to be_truthy end it "returns false if the feature is not enabled" do - MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false) - FeatureGuard.enabled?(:encoding).should be_false + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(false) + expect(FeatureGuard.enabled?(:encoding)).to be_falsey end it "returns true if all the features are enabled" do - MSpec.should_receive(:feature_enabled?).with(:one).and_return(true) - MSpec.should_receive(:feature_enabled?).with(:two).and_return(true) - FeatureGuard.enabled?(:one, :two).should be_true + expect(MSpec).to receive(:feature_enabled?).with(:one).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:two).and_return(true) + expect(FeatureGuard.enabled?(:one, :two)).to be_truthy end it "returns false if any of the features are not enabled" do - MSpec.should_receive(:feature_enabled?).with(:one).and_return(true) - MSpec.should_receive(:feature_enabled?).with(:two).and_return(false) - FeatureGuard.enabled?(:one, :two).should be_false + expect(MSpec).to receive(:feature_enabled?).with(:one).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:two).and_return(false) + expect(FeatureGuard.enabled?(:one, :two)).to be_falsey end end -describe Object, "#with_feature" do +RSpec.describe Object, "#with_feature" do before :each do ScratchPad.clear @guard = FeatureGuard.new :encoding - FeatureGuard.stub(:new).and_return(@guard) + allow(FeatureGuard).to receive(:new).and_return(@guard) end it "sets the name of the guard to :with_feature" do with_feature(:encoding) { } - @guard.name.should == :with_feature + expect(@guard.name).to eq(:with_feature) 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 with_feature { raise Exception } - end.should raise_error(Exception) + end.to raise_error(Exception) end end -describe Object, "#with_feature" do +RSpec.describe Object, "#with_feature" do before :each do ScratchPad.clear end it "yields if the feature is enabled" do - MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(true) with_feature(:encoding) { ScratchPad.record :yield } - ScratchPad.recorded.should == :yield + expect(ScratchPad.recorded).to eq(:yield) end it "yields if all the features are enabled" do - MSpec.should_receive(:feature_enabled?).with(:one).and_return(true) - MSpec.should_receive(:feature_enabled?).with(:two).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:one).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:two).and_return(true) with_feature(:one, :two) { ScratchPad.record :yield } - ScratchPad.recorded.should == :yield + expect(ScratchPad.recorded).to eq(:yield) end it "does not yield if the feature is not enabled" do - MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false) + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(false) with_feature(:encoding) { ScratchPad.record :yield } - ScratchPad.recorded.should be_nil + expect(ScratchPad.recorded).to be_nil end it "does not yield if any of the features are not enabled" do - MSpec.should_receive(:feature_enabled?).with(:one).and_return(true) - MSpec.should_receive(:feature_enabled?).with(:two).and_return(false) + expect(MSpec).to receive(:feature_enabled?).with(:one).and_return(true) + expect(MSpec).to receive(:feature_enabled?).with(:two).and_return(false) with_feature(:one, :two) { ScratchPad.record :yield } - ScratchPad.recorded.should be_nil + expect(ScratchPad.recorded).to be_nil end end -describe Object, "#without_feature" do +RSpec.describe Object, "#without_feature" do before :each do ScratchPad.clear @guard = FeatureGuard.new :encoding - FeatureGuard.stub(:new).and_return(@guard) + allow(FeatureGuard).to receive(:new).and_return(@guard) end it "sets the name of the guard to :without_feature" do without_feature(:encoding) { } - @guard.name.should == :without_feature + expect(@guard.name).to eq(: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 + expect(@guard).to receive(:match?).and_return(false) + expect(@guard).to receive(:unregister) + expect do without_feature { raise Exception } - end.should raise_error(Exception) + end.to raise_error(Exception) end end -describe Object, "#without_feature" do +RSpec.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) + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(true) without_feature(:encoding) { ScratchPad.record :yield } - ScratchPad.recorded.should be_nil + expect(ScratchPad.recorded).to be_nil end it "yields if the feature is disabled" do - MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false) + expect(MSpec).to receive(:feature_enabled?).with(:encoding).and_return(false) without_feature(:encoding) { ScratchPad.record :yield } - ScratchPad.recorded.should == :yield + expect(ScratchPad.recorded).to eq(:yield) end end |