summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/utils
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:38 +0100
committerBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:38 +0100
commit44736a6b7a2b3475db2d05187f33e3c1a7b4b4e5 (patch)
tree4cb679a8742121782a50e72e01160d19f479f9a6 /spec/mspec/spec/utils
parent31ae931e166825450dcc16d470553e67281951a2 (diff)
Update to ruby/mspec@d1adf59
Diffstat (limited to 'spec/mspec/spec/utils')
-rw-r--r--spec/mspec/spec/utils/deprecate_spec.rb10
-rw-r--r--spec/mspec/spec/utils/name_map_spec.rb78
-rw-r--r--spec/mspec/spec/utils/options_spec.rb476
-rw-r--r--spec/mspec/spec/utils/script_spec.rb252
-rw-r--r--spec/mspec/spec/utils/version_spec.rb30
5 files changed, 422 insertions, 424 deletions
diff --git a/spec/mspec/spec/utils/deprecate_spec.rb b/spec/mspec/spec/utils/deprecate_spec.rb
index 7fa60df26a..73eaf7d04e 100644
--- a/spec/mspec/spec/utils/deprecate_spec.rb
+++ b/spec/mspec/spec/utils/deprecate_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
require 'mspec/utils/deprecate'
-describe MSpec, "#deprecate" do
+RSpec.describe MSpec, "#deprecate" do
it "warns when using a deprecated method" do
warning = nil
- $stderr.stub(:puts) { |str| warning = str }
+ allow($stderr).to receive(:puts) { |str| warning = str }
MSpec.deprecate(:some_method, :other_method)
- warning.should start_with(<<-EOS.chomp)
+ expect(warning).to start_with(<<-EOS.chomp)
some_method is deprecated, use other_method instead.
from
EOS
- warning.should include(__FILE__)
- warning.should include('8')
+ expect(warning).to include(__FILE__)
+ expect(warning).to include('8')
end
end
diff --git a/spec/mspec/spec/utils/name_map_spec.rb b/spec/mspec/spec/utils/name_map_spec.rb
index d5d2cca84a..a18a481500 100644
--- a/spec/mspec/spec/utils/name_map_spec.rb
+++ b/spec/mspec/spec/utils/name_map_spec.rb
@@ -25,46 +25,46 @@ module NameMapSpecs
def n; end
end
-describe NameMap, "#exception?" do
+RSpec.describe NameMap, "#exception?" do
before :each do
@map = NameMap.new
end
it "returns true if the constant is Errno" do
- @map.exception?("Errno").should == true
+ expect(@map.exception?("Errno")).to eq(true)
end
it "returns true if the constant is a kind of Exception" do
- @map.exception?("Errno::EBADF").should == true
- @map.exception?("LoadError").should == true
- @map.exception?("SystemExit").should == true
+ expect(@map.exception?("Errno::EBADF")).to eq(true)
+ expect(@map.exception?("LoadError")).to eq(true)
+ expect(@map.exception?("SystemExit")).to eq(true)
end
it "returns false if the constant is not a kind of Exception" do
- @map.exception?("NameMapSpecs::Error").should == false
- @map.exception?("NameMapSpecs").should == false
+ expect(@map.exception?("NameMapSpecs::Error")).to eq(false)
+ expect(@map.exception?("NameMapSpecs")).to eq(false)
end
it "returns false if the constant does not exist" do
- @map.exception?("Nonexistent").should == false
+ expect(@map.exception?("Nonexistent")).to eq(false)
end
end
-describe NameMap, "#class_or_module" do
+RSpec.describe NameMap, "#class_or_module" do
before :each do
@map = NameMap.new true
end
it "returns the constant specified by the string" do
- @map.class_or_module("NameMapSpecs").should == NameMapSpecs
+ expect(@map.class_or_module("NameMapSpecs")).to eq(NameMapSpecs)
end
it "returns the constant specified by the 'A::B' string" do
- @map.class_or_module("NameMapSpecs::A").should == NameMapSpecs::A
+ expect(@map.class_or_module("NameMapSpecs::A")).to eq(NameMapSpecs::A)
end
it "returns nil if the constant is not a class or module" do
- @map.class_or_module("Float::MAX").should == nil
+ expect(@map.class_or_module("Float::MAX")).to eq(nil)
end
it "returns nil if the constant is in the set of excluded constants" do
@@ -75,101 +75,101 @@ describe NameMap, "#class_or_module" do
]
excluded.each do |const|
- @map.class_or_module(const).should == nil
+ expect(@map.class_or_module(const)).to eq(nil)
end
end
it "returns nil if the constant does not exist" do
- @map.class_or_module("Heaven").should == nil
- @map.class_or_module("Hell").should == nil
- @map.class_or_module("Bush::Brain").should == nil
+ expect(@map.class_or_module("Heaven")).to eq(nil)
+ expect(@map.class_or_module("Hell")).to eq(nil)
+ expect(@map.class_or_module("Bush::Brain")).to eq(nil)
end
end
-describe NameMap, "#dir_name" do
+RSpec.describe NameMap, "#dir_name" do
before :each do
@map = NameMap.new
end
it "returns a directory name from the base name and constant" do
- @map.dir_name("NameMapSpecs", 'spec/core').should == 'spec/core/namemapspecs'
+ expect(@map.dir_name("NameMapSpecs", 'spec/core')).to eq('spec/core/namemapspecs')
end
it "returns a directory name from the components in the constants name" do
- @map.dir_name("NameMapSpecs::A", 'spec').should == 'spec/namemapspecs/a'
- @map.dir_name("NameMapSpecs::A::B", 'spec').should == 'spec/namemapspecs/a/b'
+ expect(@map.dir_name("NameMapSpecs::A", 'spec')).to eq('spec/namemapspecs/a')
+ expect(@map.dir_name("NameMapSpecs::A::B", 'spec')).to eq('spec/namemapspecs/a/b')
end
it "returns a directory name without 'class' for constants like TrueClass" do
- @map.dir_name("TrueClass", 'spec').should == 'spec/true'
- @map.dir_name("FalseClass", 'spec').should == 'spec/false'
+ expect(@map.dir_name("TrueClass", 'spec')).to eq('spec/true')
+ expect(@map.dir_name("FalseClass", 'spec')).to eq('spec/false')
end
it "returns 'exception' for the directory name of any Exception subclass" do
- @map.dir_name("SystemExit", 'spec').should == 'spec/exception'
- @map.dir_name("Errno::EBADF", 'spec').should == 'spec/exception'
+ expect(@map.dir_name("SystemExit", 'spec')).to eq('spec/exception')
+ expect(@map.dir_name("Errno::EBADF", 'spec')).to eq('spec/exception')
end
it "returns 'class' for Class" do
- @map.dir_name("Class", 'spec').should == 'spec/class'
+ expect(@map.dir_name("Class", 'spec')).to eq('spec/class')
end
end
# These specs do not cover all the mappings, but only describe how the
# name is derived when the hash item maps to a single value, a hash with
# a specific item, or a hash with a :default item.
-describe NameMap, "#file_name" do
+RSpec.describe NameMap, "#file_name" do
before :each do
@map = NameMap.new
end
it "returns the name of the spec file based on the constant and method" do
- @map.file_name("[]=", "Array").should == "element_set_spec.rb"
+ expect(@map.file_name("[]=", "Array")).to eq("element_set_spec.rb")
end
it "returns the name of the spec file based on the special entry for the method" do
- @map.file_name("~", "Regexp").should == "match_spec.rb"
- @map.file_name("~", "Integer").should == "complement_spec.rb"
+ expect(@map.file_name("~", "Regexp")).to eq("match_spec.rb")
+ expect(@map.file_name("~", "Integer")).to eq("complement_spec.rb")
end
it "returns the name of the spec file based on the default entry for the method" do
- @map.file_name("<<", "NameMapSpecs").should == "append_spec.rb"
+ expect(@map.file_name("<<", "NameMapSpecs")).to eq("append_spec.rb")
end
it "uses the last component of the constant to look up the method name" do
- @map.file_name("^", "NameMapSpecs::Integer").should == "bit_xor_spec.rb"
+ expect(@map.file_name("^", "NameMapSpecs::Integer")).to eq("bit_xor_spec.rb")
end
end
-describe NameMap, "#namespace" do
+RSpec.describe NameMap, "#namespace" do
before :each do
@map = NameMap.new
end
it "prepends the module to the constant name" do
- @map.namespace("SubModule", Integer).should == "SubModule::Integer"
+ expect(@map.namespace("SubModule", Integer)).to eq("SubModule::Integer")
end
it "does not prepend Object, Class, or Module to the constant name" do
- @map.namespace("Object", String).should == "String"
- @map.namespace("Module", Integer).should == "Integer"
- @map.namespace("Class", Float).should == "Float"
+ expect(@map.namespace("Object", String)).to eq("String")
+ expect(@map.namespace("Module", Integer)).to eq("Integer")
+ expect(@map.namespace("Class", Float)).to eq("Float")
end
end
-describe NameMap, "#map" do
+RSpec.describe NameMap, "#map" do
before :each do
@map = NameMap.new
end
it "flattens an object hierarchy into a single Hash" do
- @map.map({}, [NameMapSpecs]).should == {
+ expect(@map.map({}, [NameMapSpecs])).to eq({
"NameMapSpecs." => ["n"],
"NameMapSpecs#" => ["n"],
"NameMapSpecs::A." => ["a"],
"NameMapSpecs::A#" => ["a", "c"],
"NameMapSpecs::A::B#" => ["b"],
"NameMapSpecs::Fixnum#" => ["f"]
- }
+ })
end
end
diff --git a/spec/mspec/spec/utils/options_spec.rb b/spec/mspec/spec/utils/options_spec.rb
index f3a7046526..2e3925f579 100644
--- a/spec/mspec/spec/utils/options_spec.rb
+++ b/spec/mspec/spec/utils/options_spec.rb
@@ -5,155 +5,155 @@ require 'mspec/guards/guard'
require 'mspec/runner/mspec'
require 'mspec/runner/formatters'
-describe MSpecOption, ".new" do
+RSpec.describe MSpecOption, ".new" do
before :each do
@opt = MSpecOption.new("-a", "--bdc", "ARG", "desc", :block)
end
it "sets the short attribute" do
- @opt.short.should == "-a"
+ expect(@opt.short).to eq("-a")
end
it "sets the long attribute" do
- @opt.long.should == "--bdc"
+ expect(@opt.long).to eq("--bdc")
end
it "sets the arg attribute" do
- @opt.arg.should == "ARG"
+ expect(@opt.arg).to eq("ARG")
end
it "sets the description attribute" do
- @opt.description.should == "desc"
+ expect(@opt.description).to eq("desc")
end
it "sets the block attribute" do
- @opt.block.should == :block
+ expect(@opt.block).to eq(:block)
end
end
-describe MSpecOption, "#arg?" do
+RSpec.describe MSpecOption, "#arg?" do
it "returns true if arg attribute is not nil" do
- MSpecOption.new(nil, nil, "ARG", nil, nil).arg?.should be_true
+ expect(MSpecOption.new(nil, nil, "ARG", nil, nil).arg?).to be_truthy
end
it "returns false if arg attribute is nil" do
- MSpecOption.new(nil, nil, nil, nil, nil).arg?.should be_false
+ expect(MSpecOption.new(nil, nil, nil, nil, nil).arg?).to be_falsey
end
end
-describe MSpecOption, "#match?" do
+RSpec.describe MSpecOption, "#match?" do
before :each do
@opt = MSpecOption.new("-a", "--bdc", "ARG", "desc", :block)
end
it "returns true if the argument matches the short option" do
- @opt.match?("-a").should be_true
+ expect(@opt.match?("-a")).to be_truthy
end
it "returns true if the argument matches the long option" do
- @opt.match?("--bdc").should be_true
+ expect(@opt.match?("--bdc")).to be_truthy
end
it "returns false if the argument matches neither the short nor long option" do
- @opt.match?("-b").should be_false
- @opt.match?("-abdc").should be_false
+ expect(@opt.match?("-b")).to be_falsey
+ expect(@opt.match?("-abdc")).to be_falsey
end
end
-describe MSpecOptions, ".new" do
+RSpec.describe MSpecOptions, ".new" do
before :each do
@opt = MSpecOptions.new("cmd", 20, :config)
end
it "sets the banner attribute" do
- @opt.banner.should == "cmd"
+ expect(@opt.banner).to eq("cmd")
end
it "sets the config attribute" do
- @opt.config.should == :config
+ expect(@opt.config).to eq(:config)
end
it "sets the width attribute" do
- @opt.width.should == 20
+ expect(@opt.width).to eq(20)
end
it "sets the default width attribute" do
- MSpecOptions.new.width.should == 30
+ expect(MSpecOptions.new.width).to eq(30)
end
end
-describe MSpecOptions, "#on" do
+RSpec.describe MSpecOptions, "#on" do
before :each do
@opt = MSpecOptions.new
end
it "adds a short option" do
- @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, nil, "desc", nil)
@opt.on("-a", "desc")
end
it "adds a short option taking an argument" do
- @opt.should_receive(:add).with("-a", nil, "ARG", "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, "ARG", "desc", nil)
@opt.on("-a", "ARG", "desc")
end
it "adds a long option" do
- @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, nil, "desc", nil)
@opt.on("-a", "desc")
end
it "adds a long option taking an argument" do
- @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, nil, "desc", nil)
@opt.on("-a", "desc")
end
it "adds a short and long option" do
- @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, nil, "desc", nil)
@opt.on("-a", "desc")
end
it "adds a short and long option taking an argument" do
- @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
+ expect(@opt).to receive(:add).with("-a", nil, nil, "desc", nil)
@opt.on("-a", "desc")
end
it "raises MSpecOptions::OptionError if pass less than 2 arguments" do
- lambda { @opt.on }.should raise_error(MSpecOptions::OptionError)
- lambda { @opt.on "" }.should raise_error(MSpecOptions::OptionError)
+ expect { @opt.on }.to raise_error(MSpecOptions::OptionError)
+ expect { @opt.on "" }.to raise_error(MSpecOptions::OptionError)
end
end
-describe MSpecOptions, "#add" do
+RSpec.describe MSpecOptions, "#add" do
before :each do
@opt = MSpecOptions.new "cmd", 20
@prc = lambda { }
end
it "adds documentation for an option" do
- @opt.should_receive(:doc).with(" -t, --typo ARG Correct typo ARG")
+ expect(@opt).to receive(:doc).with(" -t, --typo ARG Correct typo ARG")
@opt.add("-t", "--typo", "ARG", "Correct typo ARG", @prc)
end
it "leaves spaces in the documentation for a missing short option" do
- @opt.should_receive(:doc).with(" --typo ARG Correct typo ARG")
+ expect(@opt).to receive(:doc).with(" --typo ARG Correct typo ARG")
@opt.add(nil, "--typo", "ARG", "Correct typo ARG", @prc)
end
it "handles a short option with argument but no long argument" do
- @opt.should_receive(:doc).with(" -t ARG Correct typo ARG")
+ expect(@opt).to receive(:doc).with(" -t ARG Correct typo ARG")
@opt.add("-t", nil, "ARG", "Correct typo ARG", @prc)
end
it "registers an option" do
option = MSpecOption.new "-t", "--typo", "ARG", "Correct typo ARG", @prc
- MSpecOption.should_receive(:new).with(
+ expect(MSpecOption).to receive(:new).with(
"-t", "--typo", "ARG", "Correct typo ARG", @prc).and_return(option)
@opt.add("-t", "--typo", "ARG", "Correct typo ARG", @prc)
- @opt.options.should == [option]
+ expect(@opt.options).to eq([option])
end
end
-describe MSpecOptions, "#match?" do
+RSpec.describe MSpecOptions, "#match?" do
before :each do
@opt = MSpecOptions.new
end
@@ -161,15 +161,15 @@ describe MSpecOptions, "#match?" do
it "returns the MSpecOption instance matching the argument" do
@opt.on "-a", "--abdc", "desc"
option = @opt.match? "-a"
- @opt.match?("--abdc").should be(option)
- option.should be_kind_of(MSpecOption)
- option.short.should == "-a"
- option.long.should == "--abdc"
- option.description.should == "desc"
+ expect(@opt.match?("--abdc")).to be(option)
+ expect(option).to be_kind_of(MSpecOption)
+ expect(option.short).to eq("-a")
+ expect(option.long).to eq("--abdc")
+ expect(option.description).to eq("desc")
end
end
-describe MSpecOptions, "#process" do
+RSpec.describe MSpecOptions, "#process" do
before :each do
@opt = MSpecOptions.new
ScratchPad.clear
@@ -178,62 +178,62 @@ describe MSpecOptions, "#process" do
it "calls the on_extra block if the argument does not match any option" do
@opt.on_extra { ScratchPad.record :extra }
@opt.process ["-a"], "-a", "-a", nil
- ScratchPad.recorded.should == :extra
+ expect(ScratchPad.recorded).to eq(:extra)
end
it "returns the matching option" do
@opt.on "-a", "ARG", "desc"
option = @opt.process [], "-a", "-a", "ARG"
- option.should be_kind_of(MSpecOption)
- option.short.should == "-a"
- option.arg.should == "ARG"
- option.description.should == "desc"
+ expect(option).to be_kind_of(MSpecOption)
+ expect(option.short).to eq("-a")
+ expect(option.arg).to eq("ARG")
+ expect(option.description).to eq("desc")
end
it "raises an MSpecOptions::ParseError if arg is nil and there are no more entries in argv" do
@opt.on "-a", "ARG", "desc"
- lambda { @opt.process [], "-a", "-a", nil }.should raise_error(MSpecOptions::ParseError)
+ expect { @opt.process [], "-a", "-a", nil }.to raise_error(MSpecOptions::ParseError)
end
it "fetches the argument for the option from argv if arg is nil" do
@opt.on("-a", "ARG", "desc") { |o| ScratchPad.record o }
@opt.process ["ARG"], "-a", "-a", nil
- ScratchPad.recorded.should == "ARG"
+ expect(ScratchPad.recorded).to eq("ARG")
end
it "calls the option's block" do
@opt.on("-a", "ARG", "desc") { ScratchPad.record :option }
@opt.process [], "-a", "-a", "ARG"
- ScratchPad.recorded.should == :option
+ expect(ScratchPad.recorded).to eq(:option)
end
it "does not call the option's block if it is nil" do
@opt.on "-a", "ARG", "desc"
- lambda { @opt.process [], "-a", "-a", "ARG" }.should_not raise_error
+ expect { @opt.process [], "-a", "-a", "ARG" }.not_to raise_error
end
end
-describe MSpecOptions, "#split" do
+RSpec.describe MSpecOptions, "#split" do
before :each do
@opt = MSpecOptions.new
end
it "breaks a string at the nth character" do
opt, arg, rest = @opt.split "-bdc", 2
- opt.should == "-b"
- arg.should == "dc"
- rest.should == "dc"
+ expect(opt).to eq("-b")
+ expect(arg).to eq("dc")
+ expect(rest).to eq("dc")
end
it "returns nil for arg if there are no characters left" do
opt, arg, rest = @opt.split "-b", 2
- opt.should == "-b"
- arg.should == nil
- rest.should == ""
+ expect(opt).to eq("-b")
+ expect(arg).to eq(nil)
+ expect(rest).to eq("")
end
end
-describe MSpecOptions, "#parse" do
+RSpec.describe MSpecOptions, "#parse" do
before :each do
@opt = MSpecOptions.new
@prc = lambda { ScratchPad.record :parsed }
@@ -244,43 +244,43 @@ describe MSpecOptions, "#parse" do
it "parses a short option" do
@opt.on "-a", "desc", &@prc
@opt.parse ["-a"]
- ScratchPad.recorded.should == :parsed
+ expect(ScratchPad.recorded).to eq(:parsed)
end
it "parse a long option" do
@opt.on "--abdc", "desc", &@prc
@opt.parse ["--abdc"]
- ScratchPad.recorded.should == :parsed
+ expect(ScratchPad.recorded).to eq(:parsed)
end
it "parses a short option group" do
@opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-a", "ARG"]
- ScratchPad.recorded.should == [:parsed, "ARG"]
+ expect(ScratchPad.recorded).to eq([:parsed, "ARG"])
end
it "parses a short option with an argument" do
@opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-a", "ARG"]
- ScratchPad.recorded.should == [:parsed, "ARG"]
+ expect(ScratchPad.recorded).to eq([:parsed, "ARG"])
end
it "parses a short option with connected argument" do
@opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-aARG"]
- ScratchPad.recorded.should == [:parsed, "ARG"]
+ expect(ScratchPad.recorded).to eq([:parsed, "ARG"])
end
it "parses a long option with an argument" do
@opt.on "--abdc", "ARG", "desc", &@arg_prc
@opt.parse ["--abdc", "ARG"]
- ScratchPad.recorded.should == [:parsed, "ARG"]
+ expect(ScratchPad.recorded).to eq([:parsed, "ARG"])
end
it "parses a long option with an '=' argument" do
@opt.on "--abdc", "ARG", "desc", &@arg_prc
@opt.parse ["--abdc=ARG"]
- ScratchPad.recorded.should == [:parsed, "ARG"]
+ expect(ScratchPad.recorded).to eq([:parsed, "ARG"])
end
it "parses a short option group with the final option taking an argument" do
@@ -288,7 +288,7 @@ describe MSpecOptions, "#parse" do
@opt.on("-a", "desc") { |o| ScratchPad << :a }
@opt.on("-b", "ARG", "desc") { |o| ScratchPad << [:b, o] }
@opt.parse ["-ab", "ARG"]
- ScratchPad.recorded.should == [:a, [:b, "ARG"]]
+ expect(ScratchPad.recorded).to eq([:a, [:b, "ARG"]])
end
it "parses a short option group with a connected argument" do
@@ -297,12 +297,12 @@ describe MSpecOptions, "#parse" do
@opt.on("-b", "ARG", "desc") { |o| ScratchPad << [:b, o] }
@opt.on("-c", "desc") { |o| ScratchPad << :c }
@opt.parse ["-acbARG"]
- ScratchPad.recorded.should == [:a, :c, [:b, "ARG"]]
+ expect(ScratchPad.recorded).to eq([:a, :c, [:b, "ARG"]])
end
it "returns the unprocessed entries" do
@opt.on "-a", "ARG", "desc", &@arg_prc
- @opt.parse(["abdc", "-a", "ilny"]).should == ["abdc"]
+ expect(@opt.parse(["abdc", "-a", "ilny"])).to eq(["abdc"])
end
it "calls the on_extra handler with unrecognized options" do
@@ -310,59 +310,59 @@ describe MSpecOptions, "#parse" do
@opt.on_extra { |o| ScratchPad << o }
@opt.on "-a", "desc"
@opt.parse ["-a", "-b"]
- ScratchPad.recorded.should == ["-b"]
+ expect(ScratchPad.recorded).to eq(["-b"])
end
it "does not attempt to call the block if it is nil" do
@opt.on "-a", "ARG", "desc"
- @opt.parse(["-a", "ARG"]).should == []
+ expect(@opt.parse(["-a", "ARG"])).to eq([])
end
it "raises MSpecOptions::ParseError if passed an unrecognized option" do
- @opt.should_receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
- @opt.stub(:puts)
- @opt.stub(:exit)
+ expect(@opt).to receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
+ allow(@opt).to receive(:puts)
+ allow(@opt).to receive(:exit)
@opt.parse "-u"
end
end
-describe MSpecOptions, "#banner=" do
+RSpec.describe MSpecOptions, "#banner=" do
before :each do
@opt = MSpecOptions.new
end
it "sets the banner attribute" do
- @opt.banner.should == ""
+ expect(@opt.banner).to eq("")
@opt.banner = "banner"
- @opt.banner.should == "banner"
+ expect(@opt.banner).to eq("banner")
end
end
-describe MSpecOptions, "#width=" do
+RSpec.describe MSpecOptions, "#width=" do
before :each do
@opt = MSpecOptions.new
end
it "sets the width attribute" do
- @opt.width.should == 30
+ expect(@opt.width).to eq(30)
@opt.width = 20
- @opt.width.should == 20
+ expect(@opt.width).to eq(20)
end
end
-describe MSpecOptions, "#config=" do
+RSpec.describe MSpecOptions, "#config=" do
before :each do
@opt = MSpecOptions.new
end
it "sets the config attribute" do
- @opt.config.should be_nil
+ expect(@opt.config).to be_nil
@opt.config = :config
- @opt.config.should == :config
+ expect(@opt.config).to eq(:config)
end
end
-describe MSpecOptions, "#doc" do
+RSpec.describe MSpecOptions, "#doc" do
before :each do
@opt = MSpecOptions.new "command"
end
@@ -370,7 +370,7 @@ describe MSpecOptions, "#doc" do
it "adds text to be displayed with #to_s" do
@opt.doc "Some message"
@opt.doc "Another message"
- @opt.to_s.should == <<-EOD
+ expect(@opt.to_s).to eq <<-EOD
command
Some message
@@ -379,15 +379,15 @@ EOD
end
end
-describe MSpecOptions, "#version" do
+RSpec.describe MSpecOptions, "#version" do
before :each do
@opt = MSpecOptions.new
ScratchPad.clear
end
it "installs a basic -v, --version option" do
- @opt.should_receive(:puts)
- @opt.should_receive(:exit)
+ expect(@opt).to receive(:puts)
+ expect(@opt).to receive(:exit)
@opt.version "1.0.0"
@opt.parse "-v"
end
@@ -395,19 +395,19 @@ describe MSpecOptions, "#version" do
it "accepts a block instead of using the default block" do
@opt.version("1.0.0") { |o| ScratchPad.record :version }
@opt.parse "-v"
- ScratchPad.recorded.should == :version
+ expect(ScratchPad.recorded).to eq(:version)
end
end
-describe MSpecOptions, "#help" do
+RSpec.describe MSpecOptions, "#help" do
before :each do
@opt = MSpecOptions.new
ScratchPad.clear
end
it "installs a basic -h, --help option" do
- @opt.should_receive(:puts)
- @opt.should_receive(:exit).with(1)
+ expect(@opt).to receive(:puts)
+ expect(@opt).to receive(:exit).with(1)
@opt.help
@opt.parse "-h"
end
@@ -415,11 +415,11 @@ describe MSpecOptions, "#help" do
it "accepts a block instead of using the default block" do
@opt.help { |o| ScratchPad.record :help }
@opt.parse "-h"
- ScratchPad.recorded.should == :help
+ expect(ScratchPad.recorded).to eq(:help)
end
end
-describe MSpecOptions, "#on_extra" do
+RSpec.describe MSpecOptions, "#on_extra" do
before :each do
@opt = MSpecOptions.new
ScratchPad.clear
@@ -428,18 +428,18 @@ describe MSpecOptions, "#on_extra" do
it "registers a block to be called when an option is not recognized" do
@opt.on_extra { ScratchPad.record :extra }
@opt.parse "-g"
- ScratchPad.recorded.should == :extra
+ expect(ScratchPad.recorded).to eq(:extra)
end
end
-describe MSpecOptions, "#to_s" do
+RSpec.describe MSpecOptions, "#to_s" do
before :each do
@opt = MSpecOptions.new "command"
end
it "returns the banner and descriptive strings for all registered options" do
@opt.on "-t", "--this ARG", "Adds this ARG to the list"
- @opt.to_s.should == <<-EOD
+ expect(@opt.to_s).to eq <<-EOD
command
-t, --this ARG Adds this ARG to the list
@@ -447,13 +447,13 @@ EOD
end
end
-describe "The -B, --config FILE option" do
+RSpec.describe "The -B, --config FILE option" do
before :each do
@options, @config = new_option
end
it "is enabled with #configure { }" do
- @options.should_receive(:on).with("-B", "--config", "FILE",
+ expect(@options).to receive(:on).with("-B", "--config", "FILE",
an_instance_of(String))
@options.configure {}
end
@@ -464,38 +464,38 @@ describe "The -B, --config FILE option" do
@options.configure { |x| ScratchPad.record x }
@options.parse [opt, "file"]
- ScratchPad.recorded.should == "file"
+ expect(ScratchPad.recorded).to eq("file")
end
end
end
-describe "The -C, --chdir DIR option" do
+RSpec.describe "The -C, --chdir DIR option" do
before :each do
@options, @config = new_option
@options.chdir
end
it "is enabled with #chdir" do
- @options.should_receive(:on).with("-C", "--chdir", "DIR",
+ expect(@options).to receive(:on).with("-C", "--chdir", "DIR",
an_instance_of(String))
@options.chdir
end
it "changes the working directory to DIR" do
- Dir.should_receive(:chdir).with("dir").twice
+ expect(Dir).to receive(:chdir).with("dir").twice
["-C", "--chdir"].each do |opt|
@options.parse [opt, "dir"]
end
end
end
-describe "The --prefix STR option" do
+RSpec.describe "The --prefix STR option" do
before :each do
@options, @config = new_option
end
it "is enabled with #prefix" do
- @options.should_receive(:on).with("--prefix", "STR",
+ expect(@options).to receive(:on).with("--prefix", "STR",
an_instance_of(String))
@options.prefix
end
@@ -503,19 +503,19 @@ describe "The --prefix STR option" do
it "sets the prefix config value" do
@options.prefix
@options.parse ["--prefix", "some/dir"]
- @config[:prefix].should == "some/dir"
+ expect(@config[:prefix]).to eq("some/dir")
end
end
-describe "The -t, --target TARGET option" do
+RSpec.describe "The -t, --target TARGET option" do
before :each do
@options, @config = new_option
@options.targets
end
it "is enabled with #targets" do
- @options.stub(:on)
- @options.should_receive(:on).with("-t", "--target", "TARGET",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-t", "--target", "TARGET",
an_instance_of(String))
@options.targets
end
@@ -525,7 +525,7 @@ describe "The -t, --target TARGET option" do
["r", "ruby"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "ruby"
+ expect(@config[:target]).to eq("ruby")
end
end
end
@@ -535,7 +535,7 @@ describe "The -t, --target TARGET option" do
["j", "jruby"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "jruby"
+ expect(@config[:target]).to eq("jruby")
end
end
end
@@ -545,7 +545,7 @@ describe "The -t, --target TARGET option" do
["x", "rubinius"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "./bin/rbx"
+ expect(@config[:target]).to eq("./bin/rbx")
end
end
end
@@ -555,7 +555,7 @@ describe "The -t, --target TARGET option" do
["X", "rbx"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "rbx"
+ expect(@config[:target]).to eq("rbx")
end
end
end
@@ -565,7 +565,7 @@ describe "The -t, --target TARGET option" do
["m", "maglev"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "maglev-ruby"
+ expect(@config[:target]).to eq("maglev-ruby")
end
end
end
@@ -575,7 +575,7 @@ describe "The -t, --target TARGET option" do
["t", "topaz"].each do |t|
@config[:target] = nil
@options.parse [opt, t]
- @config[:target].should == "topaz"
+ expect(@config[:target]).to eq("topaz")
end
end
end
@@ -584,20 +584,20 @@ describe "The -t, --target TARGET option" do
["-t", "--target"].each do |opt|
@config[:target] = nil
@options.parse [opt, "whateva"]
- @config[:target].should == "whateva"
+ expect(@config[:target]).to eq("whateva")
end
end
end
-describe "The -T, --target-opt OPT option" do
+RSpec.describe "The -T, --target-opt OPT option" do
before :each do
@options, @config = new_option
@options.targets
end
it "is enabled with #targets" do
- @options.stub(:on)
- @options.should_receive(:on).with("-T", "--target-opt", "OPT",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-T", "--target-opt", "OPT",
an_instance_of(String))
@options.targets
end
@@ -606,20 +606,20 @@ describe "The -T, --target-opt OPT option" do
["-T", "--target-opt"].each do |opt|
@config[:flags].delete "--whateva"
@options.parse [opt, "--whateva"]
- @config[:flags].should include("--whateva")
+ expect(@config[:flags]).to include("--whateva")
end
end
end
-describe "The -I, --include DIR option" do
+RSpec.describe "The -I, --include DIR option" do
before :each do
@options, @config = new_option
@options.targets
end
it "is enabled with #targets" do
- @options.stub(:on)
- @options.should_receive(:on).with("-I", "--include", "DIR",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-I", "--include", "DIR",
an_instance_of(String))
@options.targets
end
@@ -628,20 +628,20 @@ describe "The -I, --include DIR option" do
["-I", "--include"].each do |opt|
@config[:loadpath].delete "-Ipackage"
@options.parse [opt, "package"]
- @config[:loadpath].should include("-Ipackage")
+ expect(@config[:loadpath]).to include("-Ipackage")
end
end
end
-describe "The -r, --require LIBRARY option" do
+RSpec.describe "The -r, --require LIBRARY option" do
before :each do
@options, @config = new_option
@options.targets
end
it "is enabled with #targets" do
- @options.stub(:on)
- @options.should_receive(:on).with("-r", "--require", "LIBRARY",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-r", "--require", "LIBRARY",
an_instance_of(String))
@options.targets
end
@@ -650,20 +650,20 @@ describe "The -r, --require LIBRARY option" do
["-r", "--require"].each do |opt|
@config[:requires].delete "-rlibrick"
@options.parse [opt, "librick"]
- @config[:requires].should include("-rlibrick")
+ expect(@config[:requires]).to include("-rlibrick")
end
end
end
-describe "The -f, --format FORMAT option" do
+RSpec.describe "The -f, --format FORMAT option" do
before :each do
@options, @config = new_option
@options.formatters
end
it "is enabled with #formatters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-f", "--format", "FORMAT",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-f", "--format", "FORMAT",
an_instance_of(String))
@options.formatters
end
@@ -673,7 +673,7 @@ describe "The -f, --format FORMAT option" do
["s", "specdoc"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == SpecdocFormatter
+ expect(@config[:formatter]).to eq(SpecdocFormatter)
end
end
end
@@ -683,7 +683,7 @@ describe "The -f, --format FORMAT option" do
["h", "html"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == HtmlFormatter
+ expect(@config[:formatter]).to eq(HtmlFormatter)
end
end
end
@@ -693,7 +693,7 @@ describe "The -f, --format FORMAT option" do
["d", "dot", "dotted"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == DottedFormatter
+ expect(@config[:formatter]).to eq(DottedFormatter)
end
end
end
@@ -703,7 +703,7 @@ describe "The -f, --format FORMAT option" do
["b", "describe"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == DescribeFormatter
+ expect(@config[:formatter]).to eq(DescribeFormatter)
end
end
end
@@ -713,7 +713,7 @@ describe "The -f, --format FORMAT option" do
["f", "file"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == FileFormatter
+ expect(@config[:formatter]).to eq(FileFormatter)
end
end
end
@@ -723,7 +723,7 @@ describe "The -f, --format FORMAT option" do
["u", "unit", "unitdiff"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == UnitdiffFormatter
+ expect(@config[:formatter]).to eq(UnitdiffFormatter)
end
end
end
@@ -733,7 +733,7 @@ describe "The -f, --format FORMAT option" do
["m", "summary"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == SummaryFormatter
+ expect(@config[:formatter]).to eq(SummaryFormatter)
end
end
end
@@ -743,7 +743,7 @@ describe "The -f, --format FORMAT option" do
["a", "*", "spin"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == SpinnerFormatter
+ expect(@config[:formatter]).to eq(SpinnerFormatter)
end
end
end
@@ -753,7 +753,7 @@ describe "The -f, --format FORMAT option" do
["t", "method"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == MethodFormatter
+ expect(@config[:formatter]).to eq(MethodFormatter)
end
end
end
@@ -763,7 +763,7 @@ describe "The -f, --format FORMAT option" do
["y", "yaml"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == YamlFormatter
+ expect(@config[:formatter]).to eq(YamlFormatter)
end
end
end
@@ -773,21 +773,21 @@ describe "The -f, --format FORMAT option" do
["j", "junit"].each do |f|
@config[:formatter] = nil
@options.parse [opt, f]
- @config[:formatter].should == JUnitFormatter
+ expect(@config[:formatter]).to eq(JUnitFormatter)
end
end
end
end
-describe "The -o, --output FILE option" do
+RSpec.describe "The -o, --output FILE option" do
before :each do
@options, @config = new_option
@options.formatters
end
it "is enabled with #formatters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-o", "--output", "FILE",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-o", "--output", "FILE",
an_instance_of(String))
@options.formatters
end
@@ -796,20 +796,20 @@ describe "The -o, --output FILE option" do
["-o", "--output"].each do |opt|
@config[:output] = nil
@options.parse [opt, "some/file"]
- @config[:output].should == "some/file"
+ expect(@config[:output]).to eq("some/file")
end
end
end
-describe "The -e, --example STR" do
+RSpec.describe "The -e, --example STR" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-e", "--example", "STR",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-e", "--example", "STR",
an_instance_of(String))
@options.filters
end
@@ -818,20 +818,20 @@ describe "The -e, --example STR" do
["-e", "--example"].each do |opt|
@config[:includes] = []
@options.parse [opt, "this spec"]
- @config[:includes].should include("this spec")
+ expect(@config[:includes]).to include("this spec")
end
end
end
-describe "The -E, --exclude STR" do
+RSpec.describe "The -E, --exclude STR" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-E", "--exclude", "STR",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-E", "--exclude", "STR",
an_instance_of(String))
@options.filters
end
@@ -840,20 +840,20 @@ describe "The -E, --exclude STR" do
["-E", "--exclude"].each do |opt|
@config[:excludes] = []
@options.parse [opt, "this spec"]
- @config[:excludes].should include("this spec")
+ expect(@config[:excludes]).to include("this spec")
end
end
end
-describe "The -p, --pattern PATTERN" do
+RSpec.describe "The -p, --pattern PATTERN" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-p", "--pattern", "PATTERN",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-p", "--pattern", "PATTERN",
an_instance_of(String))
@options.filters
end
@@ -862,20 +862,20 @@ describe "The -p, --pattern PATTERN" do
["-p", "--pattern"].each do |opt|
@config[:patterns] = []
@options.parse [opt, "this spec"]
- @config[:patterns].should include(/this spec/)
+ expect(@config[:patterns]).to include(/this spec/)
end
end
end
-describe "The -P, --excl-pattern PATTERN" do
+RSpec.describe "The -P, --excl-pattern PATTERN" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-P", "--excl-pattern", "PATTERN",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-P", "--excl-pattern", "PATTERN",
an_instance_of(String))
@options.filters
end
@@ -884,20 +884,20 @@ describe "The -P, --excl-pattern PATTERN" do
["-P", "--excl-pattern"].each do |opt|
@config[:xpatterns] = []
@options.parse [opt, "this spec"]
- @config[:xpatterns].should include(/this spec/)
+ expect(@config[:xpatterns]).to include(/this spec/)
end
end
end
-describe "The -g, --tag TAG" do
+RSpec.describe "The -g, --tag TAG" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-g", "--tag", "TAG",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-g", "--tag", "TAG",
an_instance_of(String))
@options.filters
end
@@ -906,20 +906,20 @@ describe "The -g, --tag TAG" do
["-g", "--tag"].each do |opt|
@config[:tags] = []
@options.parse [opt, "this spec"]
- @config[:tags].should include("this spec")
+ expect(@config[:tags]).to include("this spec")
end
end
end
-describe "The -G, --excl-tag TAG" do
+RSpec.describe "The -G, --excl-tag TAG" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-G", "--excl-tag", "TAG",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-G", "--excl-tag", "TAG",
an_instance_of(String))
@options.filters
end
@@ -928,20 +928,20 @@ describe "The -G, --excl-tag TAG" do
["-G", "--excl-tag"].each do |opt|
@config[:xtags] = []
@options.parse [opt, "this spec"]
- @config[:xtags].should include("this spec")
+ expect(@config[:xtags]).to include("this spec")
end
end
end
-describe "The -w, --profile FILE option" do
+RSpec.describe "The -w, --profile FILE option" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-w", "--profile", "FILE",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-w", "--profile", "FILE",
an_instance_of(String))
@options.filters
end
@@ -950,20 +950,20 @@ describe "The -w, --profile FILE option" do
["-w", "--profile"].each do |opt|
@config[:profiles] = []
@options.parse [opt, "spec/profiles/rails.yaml"]
- @config[:profiles].should include("spec/profiles/rails.yaml")
+ expect(@config[:profiles]).to include("spec/profiles/rails.yaml")
end
end
end
-describe "The -W, --excl-profile FILE option" do
+RSpec.describe "The -W, --excl-profile FILE option" do
before :each do
@options, @config = new_option
@options.filters
end
it "is enabled with #filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-W", "--excl-profile", "FILE",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-W", "--excl-profile", "FILE",
an_instance_of(String))
@options.filters
end
@@ -972,93 +972,93 @@ describe "The -W, --excl-profile FILE option" do
["-W", "--excl-profile"].each do |opt|
@config[:xprofiles] = []
@options.parse [opt, "spec/profiles/rails.yaml"]
- @config[:xprofiles].should include("spec/profiles/rails.yaml")
+ expect(@config[:xprofiles]).to include("spec/profiles/rails.yaml")
end
end
end
-describe "The -Z, --dry-run option" do
+RSpec.describe "The -Z, --dry-run option" do
before :each do
@options, @config = new_option
@options.pretend
end
it "is enabled with #pretend" do
- @options.should_receive(:on).with("-Z", "--dry-run", an_instance_of(String))
+ expect(@options).to receive(:on).with("-Z", "--dry-run", an_instance_of(String))
@options.pretend
end
it "registers the MSpec pretend mode" do
- MSpec.should_receive(:register_mode).with(:pretend).twice
+ expect(MSpec).to receive(:register_mode).with(:pretend).twice
["-Z", "--dry-run"].each do |opt|
@options.parse opt
end
end
end
-describe "The --unguarded option" do
+RSpec.describe "The --unguarded option" do
before :each do
@options, @config = new_option
@options.unguarded
end
it "is enabled with #unguarded" do
- @options.stub(:on)
- @options.should_receive(:on).with("--unguarded", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("--unguarded", an_instance_of(String))
@options.unguarded
end
it "registers the MSpec unguarded mode" do
- MSpec.should_receive(:register_mode).with(:unguarded)
+ expect(MSpec).to receive(:register_mode).with(:unguarded)
@options.parse "--unguarded"
end
end
-describe "The --no-ruby_guard option" do
+RSpec.describe "The --no-ruby_guard option" do
before :each do
@options, @config = new_option
@options.unguarded
end
it "is enabled with #unguarded" do
- @options.stub(:on)
- @options.should_receive(:on).with("--no-ruby_bug", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("--no-ruby_bug", an_instance_of(String))
@options.unguarded
end
it "registers the MSpec no_ruby_bug mode" do
- MSpec.should_receive(:register_mode).with(:no_ruby_bug)
+ expect(MSpec).to receive(:register_mode).with(:no_ruby_bug)
@options.parse "--no-ruby_bug"
end
end
-describe "The -H, --random option" do
+RSpec.describe "The -H, --random option" do
before :each do
@options, @config = new_option
@options.randomize
end
it "is enabled with #randomize" do
- @options.should_receive(:on).with("-H", "--random", an_instance_of(String))
+ expect(@options).to receive(:on).with("-H", "--random", an_instance_of(String))
@options.randomize
end
it "registers the MSpec randomize mode" do
- MSpec.should_receive(:randomize=).twice
+ expect(MSpec).to receive(:randomize=).twice
["-H", "--random"].each do |opt|
@options.parse opt
end
end
end
-describe "The -R, --repeat option" do
+RSpec.describe "The -R, --repeat option" do
before :each do
@options, @config = new_option
@options.repeat
end
it "is enabled with #repeat" do
- @options.should_receive(:on).with("-R", "--repeat", "NUMBER", an_instance_of(String))
+ expect(@options).to receive(:on).with("-R", "--repeat", "NUMBER", an_instance_of(String))
@options.repeat
end
@@ -1070,117 +1070,115 @@ describe "The -R, --repeat option" do
MSpec.repeat do
repeat_count += 1
end
- repeat_count.should == 10
+ expect(repeat_count).to eq(10)
end
end
end
-describe "The -V, --verbose option" do
+RSpec.describe "The -V, --verbose option" do
before :each do
@options, @config = new_option
@options.verbose
end
it "is enabled with #verbose" do
- @options.stub(:on)
- @options.should_receive(:on).with("-V", "--verbose", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-V", "--verbose", an_instance_of(String))
@options.verbose
end
it "registers a verbose output object with MSpec" do
- MSpec.should_receive(:register).with(:start, anything()).twice
- MSpec.should_receive(:register).with(:load, anything()).twice
+ expect(MSpec).to receive(:register).with(:start, anything()).twice
+ expect(MSpec).to receive(:register).with(:load, anything()).twice
["-V", "--verbose"].each do |opt|
@options.parse opt
end
end
end
-describe "The -m, --marker MARKER option" do
+RSpec.describe "The -m, --marker MARKER option" do
before :each do
@options, @config = new_option
@options.verbose
end
it "is enabled with #verbose" do
- @options.stub(:on)
- @options.should_receive(:on).with("-m", "--marker", "MARKER",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-m", "--marker", "MARKER",
an_instance_of(String))
@options.verbose
end
it "registers a marker output object with MSpec" do
- MSpec.should_receive(:register).with(:load, anything()).twice
+ expect(MSpec).to receive(:register).with(:load, anything()).twice
["-m", "--marker"].each do |opt|
@options.parse [opt, ","]
end
end
end
-describe "The --int-spec option" do
+RSpec.describe "The --int-spec option" do
before :each do
@options, @config = new_option
@options.interrupt
end
it "is enabled with #interrupt" do
- @options.should_receive(:on).with("--int-spec", an_instance_of(String))
+ expect(@options).to receive(:on).with("--int-spec", an_instance_of(String))
@options.interrupt
end
it "sets the abort config option to false to only abort the running spec with ^C" do
@config[:abort] = true
@options.parse "--int-spec"
- @config[:abort].should == false
+ expect(@config[:abort]).to eq(false)
end
end
-describe "The -Y, --verify option" do
+RSpec.describe "The -Y, --verify option" do
before :each do
@options, @config = new_option
@options.verify
end
it "is enabled with #interrupt" do
- @options.stub(:on)
- @options.should_receive(:on).with("-Y", "--verify", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-Y", "--verify", an_instance_of(String))
@options.verify
end
it "sets the MSpec mode to :verify" do
- MSpec.should_receive(:register_mode).with(:verify).twice
+ expect(MSpec).to receive(:register_mode).with(:verify).twice
["-Y", "--verify"].each do |m|
@options.parse m
end
end
end
-describe "The -O, --report option" do
+RSpec.describe "The -O, --report option" do
before :each do
@options, @config = new_option
@options.verify
end
it "is enabled with #interrupt" do
- @options.stub(:on)
- @options.should_receive(:on).with("-O", "--report", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-O", "--report", an_instance_of(String))
@options.verify
end
it "sets the MSpec mode to :report" do
- MSpec.should_receive(:register_mode).with(:report).twice
+ expect(MSpec).to receive(:register_mode).with(:report).twice
["-O", "--report"].each do |m|
@options.parse m
end
end
end
-describe "The --report-on GUARD option" do
- before :all do
- MSpec.stub(:register_mode)
- end
-
+RSpec.describe "The --report-on GUARD option" do
before :each do
+ allow(MSpec).to receive(:register_mode)
+
@options, @config = new_option
@options.verify
@@ -1192,37 +1190,37 @@ describe "The --report-on GUARD option" do
end
it "is enabled with #interrupt" do
- @options.stub(:on)
- @options.should_receive(:on).with("--report-on", "GUARD", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("--report-on", "GUARD", an_instance_of(String))
@options.verify
end
it "sets the MSpec mode to :report_on" do
- MSpec.should_receive(:register_mode).with(:report_on)
+ expect(MSpec).to receive(:register_mode).with(:report_on)
@options.parse ["--report-on", "ruby_bug"]
end
it "converts the guard name to a symbol" do
name = double("ruby_bug")
- name.should_receive(:to_sym)
+ expect(name).to receive(:to_sym)
@options.parse ["--report-on", name]
end
it "saves the name of the guard" do
@options.parse ["--report-on", "ruby_bug"]
- SpecGuard.guards.should == [:ruby_bug]
+ expect(SpecGuard.guards).to eq([:ruby_bug])
end
end
-describe "The -K, --action-tag TAG option" do
+RSpec.describe "The -K, --action-tag TAG option" do
before :each do
@options, @config = new_option
@options.action_filters
end
it "is enabled with #action_filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-K", "--action-tag", "TAG",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-K", "--action-tag", "TAG",
an_instance_of(String))
@options.action_filters
end
@@ -1231,20 +1229,20 @@ describe "The -K, --action-tag TAG option" do
["-K", "--action-tag"].each do |opt|
@config[:atags] = []
@options.parse [opt, "action-tag"]
- @config[:atags].should include("action-tag")
+ expect(@config[:atags]).to include("action-tag")
end
end
end
-describe "The -S, --action-string STR option" do
+RSpec.describe "The -S, --action-string STR option" do
before :each do
@options, @config = new_option
@options.action_filters
end
it "is enabled with #action_filters" do
- @options.stub(:on)
- @options.should_receive(:on).with("-S", "--action-string", "STR",
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-S", "--action-string", "STR",
an_instance_of(String))
@options.action_filters
end
@@ -1253,12 +1251,12 @@ describe "The -S, --action-string STR option" do
["-S", "--action-string"].each do |opt|
@config[:astrings] = []
@options.parse [opt, "action-str"]
- @config[:astrings].should include("action-str")
+ expect(@config[:astrings]).to include("action-str")
end
end
end
-describe "The -d, --debug option" do
+RSpec.describe "The -d, --debug option" do
before :each do
@options, @config = new_option
@options.debug
@@ -1269,22 +1267,22 @@ describe "The -d, --debug option" do
end
it "is enabled with #debug" do
- @options.stub(:on)
- @options.should_receive(:on).with("-d", "--debug", an_instance_of(String))
+ allow(@options).to receive(:on)
+ expect(@options).to receive(:on).with("-d", "--debug", an_instance_of(String))
@options.debug
end
it "sets $MSPEC_DEBUG to true" do
["-d", "--debug"].each do |opt|
- $MSPEC_DEBUG.should_not be_true
+ expect($MSPEC_DEBUG).not_to be_truthy
@options.parse opt
- $MSPEC_DEBUG.should be_true
+ expect($MSPEC_DEBUG).to be_truthy
$MSPEC_DEBUG = nil
end
end
end
-describe "MSpecOptions#all" do
+RSpec.describe "MSpecOptions#all" do
it "includes all options" do
meth = MSpecOptions.instance_method(:all)
file, line = meth.source_location
@@ -1299,6 +1297,6 @@ describe "MSpecOptions#all" do
option_methods = contents.scan(/def (\w+).*\n\s*on\(/).map(&:first)
option_methods[0].sub!("configure", "configure {}")
- calls.should == option_methods
+ expect(calls).to eq(option_methods)
end
end
diff --git a/spec/mspec/spec/utils/script_spec.rb b/spec/mspec/spec/utils/script_spec.rb
index c7fa3eb354..d9f6eac9a9 100644
--- a/spec/mspec/spec/utils/script_spec.rb
+++ b/spec/mspec/spec/utils/script_spec.rb
@@ -4,40 +4,40 @@ require 'mspec/runner/mspec'
require 'mspec/runner/filters'
require 'mspec/runner/actions/filter'
-describe MSpecScript, ".config" do
+RSpec.describe MSpecScript, ".config" do
it "returns a Hash" do
- MSpecScript.config.should be_kind_of(Hash)
+ expect(MSpecScript.config).to be_kind_of(Hash)
end
end
-describe MSpecScript, ".set" do
+RSpec.describe MSpecScript, ".set" do
it "sets the config hash key, value" do
MSpecScript.set :a, 10
- MSpecScript.config[:a].should == 10
+ expect(MSpecScript.config[:a]).to eq(10)
end
end
-describe MSpecScript, ".get" do
+RSpec.describe MSpecScript, ".get" do
it "gets the config hash value for a key" do
MSpecScript.set :a, 10
- MSpecScript.get(:a).should == 10
+ expect(MSpecScript.get(:a)).to eq(10)
end
end
-describe MSpecScript, "#config" do
+RSpec.describe MSpecScript, "#config" do
it "returns the MSpecScript config hash" do
MSpecScript.set :b, 5
- MSpecScript.new.config[:b].should == 5
+ expect(MSpecScript.new.config[:b]).to eq(5)
end
it "returns the MSpecScript config hash from subclasses" do
class MSSClass < MSpecScript; end
MSpecScript.set :b, 5
- MSSClass.new.config[:b].should == 5
+ expect(MSSClass.new.config[:b]).to eq(5)
end
end
-describe MSpecScript, "#load_default" do
+RSpec.describe MSpecScript, "#load_default" do
before :all do
@verbose = $VERBOSE
$VERBOSE = nil
@@ -53,7 +53,7 @@ describe MSpecScript, "#load_default" do
@engine = Object.const_get :RUBY_ENGINE
end
@script = MSpecScript.new
- MSpecScript.stub(:new).and_return(@script)
+ allow(MSpecScript).to receive(:new).and_return(@script)
end
after :each do
@@ -62,8 +62,8 @@ describe MSpecScript, "#load_default" do
end
it "attempts to load 'default.mspec'" do
- @script.stub(:try_load)
- @script.should_receive(:try_load).with('default.mspec').and_return(true)
+ allow(@script).to receive(:try_load)
+ expect(@script).to receive(:try_load).with('default.mspec').and_return(true)
@script.load_default
end
@@ -71,145 +71,145 @@ describe MSpecScript, "#load_default" do
Object.const_set :RUBY_ENGINE, "ybur"
Object.const_set :RUBY_VERSION, "1.8.9"
default = "ybur.1.8.mspec"
- @script.should_receive(:try_load).with('default.mspec').and_return(false)
- @script.should_receive(:try_load).with(default)
- @script.should_receive(:try_load).with('ybur.mspec')
+ expect(@script).to receive(:try_load).with('default.mspec').and_return(false)
+ expect(@script).to receive(:try_load).with(default)
+ expect(@script).to receive(:try_load).with('ybur.mspec')
@script.load_default
end
end
-describe MSpecScript, ".main" do
+RSpec.describe MSpecScript, ".main" do
before :each do
@script = double("MSpecScript").as_null_object
- MSpecScript.stub(:new).and_return(@script)
+ allow(MSpecScript).to receive(:new).and_return(@script)
# Do not require full mspec as it would conflict with RSpec
- MSpecScript.should_receive(:require).with('mspec')
+ expect(MSpecScript).to receive(:require).with('mspec')
end
it "creates an instance of MSpecScript" do
- MSpecScript.should_receive(:new).and_return(@script)
+ expect(MSpecScript).to receive(:new).and_return(@script)
MSpecScript.main
end
it "attempts to load the default config" do
- @script.should_receive(:load_default)
+ expect(@script).to receive(:load_default)
MSpecScript.main
end
it "attempts to load the '~/.mspecrc' script" do
- @script.should_receive(:try_load).with('~/.mspecrc')
+ expect(@script).to receive(:try_load).with('~/.mspecrc')
MSpecScript.main
end
it "calls the #options method on the script" do
- @script.should_receive(:options)
+ expect(@script).to receive(:options)
MSpecScript.main
end
it "calls the #signals method on the script" do
- @script.should_receive(:signals)
+ expect(@script).to receive(:signals)
MSpecScript.main
end
it "calls the #register method on the script" do
- @script.should_receive(:register)
+ expect(@script).to receive(:register)
MSpecScript.main
end
it "calls the #setup_env method on the script" do
- @script.should_receive(:setup_env)
+ expect(@script).to receive(:setup_env)
MSpecScript.main
end
it "calls the #run method on the script" do
- @script.should_receive(:run)
+ expect(@script).to receive(:run)
MSpecScript.main
end
end
-describe MSpecScript, "#initialize" do
+RSpec.describe MSpecScript, "#initialize" do
before :each do
@config = MSpecScript.new.config
end
it "sets the default config values" do
- @config[:formatter].should == nil
- @config[:includes].should == []
- @config[:excludes].should == []
- @config[:patterns].should == []
- @config[:xpatterns].should == []
- @config[:tags].should == []
- @config[:xtags].should == []
- @config[:atags].should == []
- @config[:astrings].should == []
- @config[:abort].should == true
- @config[:config_ext].should == '.mspec'
+ expect(@config[:formatter]).to eq(nil)
+ expect(@config[:includes]).to eq([])
+ expect(@config[:excludes]).to eq([])
+ expect(@config[:patterns]).to eq([])
+ expect(@config[:xpatterns]).to eq([])
+ expect(@config[:tags]).to eq([])
+ expect(@config[:xtags]).to eq([])
+ expect(@config[:atags]).to eq([])
+ expect(@config[:astrings]).to eq([])
+ expect(@config[:abort]).to eq(true)
+ expect(@config[:config_ext]).to eq('.mspec')
end
end
-describe MSpecScript, "#load" do
+RSpec.describe MSpecScript, "#load" do
before :each do
- File.stub(:exist?).and_return(false)
+ allow(File).to receive(:exist?).and_return(false)
@script = MSpecScript.new
@file = "default.mspec"
@base = "default"
end
it "attempts to locate the file through the expanded path name" do
- File.should_receive(:expand_path).with(@file, ".").and_return(@file)
- File.should_receive(:exist?).with(@file).and_return(true)
- Kernel.should_receive(:load).with(@file).and_return(:loaded)
- @script.load(@file).should == :loaded
+ expect(File).to receive(:expand_path).with(@file, ".").and_return(@file)
+ expect(File).to receive(:exist?).with(@file).and_return(true)
+ expect(Kernel).to receive(:load).with(@file).and_return(:loaded)
+ expect(@script.load(@file)).to eq(:loaded)
end
it "appends config[:config_ext] to the name and attempts to locate the file through the expanded path name" do
- File.should_receive(:expand_path).with(@base, ".").and_return(@base)
- File.should_receive(:expand_path).with(@base, "spec").and_return(@base)
- File.should_receive(:expand_path).with(@file, ".").and_return(@file)
- File.should_receive(:exist?).with(@base).and_return(false)
- File.should_receive(:exist?).with(@file).and_return(true)
- Kernel.should_receive(:load).with(@file).and_return(:loaded)
- @script.load(@base).should == :loaded
+ expect(File).to receive(:expand_path).with(@base, ".").and_return(@base)
+ expect(File).to receive(:expand_path).with(@base, "spec").and_return(@base)
+ expect(File).to receive(:expand_path).with(@file, ".").and_return(@file)
+ expect(File).to receive(:exist?).with(@base).and_return(false)
+ expect(File).to receive(:exist?).with(@file).and_return(true)
+ expect(Kernel).to receive(:load).with(@file).and_return(:loaded)
+ expect(@script.load(@base)).to eq(:loaded)
end
it "attempts to locate the file in '.'" do
path = File.expand_path @file, "."
- File.should_receive(:exist?).with(path).and_return(true)
- Kernel.should_receive(:load).with(path).and_return(:loaded)
- @script.load(@file).should == :loaded
+ expect(File).to receive(:exist?).with(path).and_return(true)
+ expect(Kernel).to receive(:load).with(path).and_return(:loaded)
+ expect(@script.load(@file)).to eq(:loaded)
end
it "appends config[:config_ext] to the name and attempts to locate the file in '.'" do
path = File.expand_path @file, "."
- File.should_receive(:exist?).with(path).and_return(true)
- Kernel.should_receive(:load).with(path).and_return(:loaded)
- @script.load(@base).should == :loaded
+ expect(File).to receive(:exist?).with(path).and_return(true)
+ expect(Kernel).to receive(:load).with(path).and_return(:loaded)
+ expect(@script.load(@base)).to eq(:loaded)
end
it "attempts to locate the file in 'spec'" do
path = File.expand_path @file, "spec"
- File.should_receive(:exist?).with(path).and_return(true)
- Kernel.should_receive(:load).with(path).and_return(:loaded)
- @script.load(@file).should == :loaded
+ expect(File).to receive(:exist?).with(path).and_return(true)
+ expect(Kernel).to receive(:load).with(path).and_return(:loaded)
+ expect(@script.load(@file)).to eq(:loaded)
end
it "appends config[:config_ext] to the name and attempts to locate the file in 'spec'" do
path = File.expand_path @file, "spec"
- File.should_receive(:exist?).with(path).and_return(true)
- Kernel.should_receive(:load).with(path).and_return(:loaded)
- @script.load(@base).should == :loaded
+ expect(File).to receive(:exist?).with(path).and_return(true)
+ expect(Kernel).to receive(:load).with(path).and_return(:loaded)
+ expect(@script.load(@base)).to eq(:loaded)
end
it "loads a given file only once" do
path = File.expand_path @file, "spec"
- File.should_receive(:exist?).with(path).and_return(true)
- Kernel.should_receive(:load).once.with(path).and_return(:loaded)
- @script.load(@base).should == :loaded
- @script.load(@base).should == true
+ expect(File).to receive(:exist?).with(path).and_return(true)
+ expect(Kernel).to receive(:load).once.with(path).and_return(:loaded)
+ expect(@script.load(@base)).to eq(:loaded)
+ expect(@script.load(@base)).to eq(true)
end
end
-describe MSpecScript, "#custom_options" do
+RSpec.describe MSpecScript, "#custom_options" do
before :each do
@script = MSpecScript.new
end
@@ -219,12 +219,12 @@ describe MSpecScript, "#custom_options" do
it "prints 'None'" do
options = double("options")
- options.should_receive(:doc).with(" No custom options registered")
+ expect(options).to receive(:doc).with(" No custom options registered")
@script.custom_options options
end
end
-describe MSpecScript, "#register" do
+RSpec.describe MSpecScript, "#register" do
before :each do
@script = MSpecScript.new
@@ -233,8 +233,8 @@ describe MSpecScript, "#register" do
end
it "creates and registers the formatter" do
- @formatter.should_receive(:new).and_return(@formatter)
- @formatter.should_receive(:register)
+ expect(@formatter).to receive(:new).and_return(@formatter)
+ expect(@formatter).to receive(:register)
@script.register
end
@@ -244,24 +244,24 @@ describe MSpecScript, "#register" do
end
it "calls #custom_register" do
- @script.should_receive(:custom_register)
+ expect(@script).to receive(:custom_register)
@script.register
end
it "registers :formatter with the formatter instance" do
- @formatter.stub(:new).and_return(@formatter)
+ allow(@formatter).to receive(:new).and_return(@formatter)
@script.register
- MSpec.formatter.should be(@formatter)
+ expect(MSpec.formatter).to be(@formatter)
end
it "does not register :formatter if config[:formatter] is false" do
@script.config[:formatter] = false
- MSpec.should_not_receive(:store)
+ expect(MSpec).not_to receive(:store)
@script.register
end
end
-describe MSpecScript, "#register" do
+RSpec.describe MSpecScript, "#register" do
before :each do
@script = MSpecScript.new
@@ -269,61 +269,61 @@ describe MSpecScript, "#register" do
@script.config[:formatter] = @formatter
@filter = double("filter")
- @filter.should_receive(:register)
+ expect(@filter).to receive(:register)
@ary = ["some", "spec"]
end
it "creates and registers a MatchFilter for include specs" do
- MatchFilter.should_receive(:new).with(:include, *@ary).and_return(@filter)
+ expect(MatchFilter).to receive(:new).with(:include, *@ary).and_return(@filter)
@script.config[:includes] = @ary
@script.register
end
it "creates and registers a MatchFilter for excluded specs" do
- MatchFilter.should_receive(:new).with(:exclude, *@ary).and_return(@filter)
+ expect(MatchFilter).to receive(:new).with(:exclude, *@ary).and_return(@filter)
@script.config[:excludes] = @ary
@script.register
end
it "creates and registers a RegexpFilter for include specs" do
- RegexpFilter.should_receive(:new).with(:include, *@ary).and_return(@filter)
+ expect(RegexpFilter).to receive(:new).with(:include, *@ary).and_return(@filter)
@script.config[:patterns] = @ary
@script.register
end
it "creates and registers a RegexpFilter for excluded specs" do
- RegexpFilter.should_receive(:new).with(:exclude, *@ary).and_return(@filter)
+ expect(RegexpFilter).to receive(:new).with(:exclude, *@ary).and_return(@filter)
@script.config[:xpatterns] = @ary
@script.register
end
it "creates and registers a TagFilter for include specs" do
- TagFilter.should_receive(:new).with(:include, *@ary).and_return(@filter)
+ expect(TagFilter).to receive(:new).with(:include, *@ary).and_return(@filter)
@script.config[:tags] = @ary
@script.register
end
it "creates and registers a TagFilter for excluded specs" do
- TagFilter.should_receive(:new).with(:exclude, *@ary).and_return(@filter)
+ expect(TagFilter).to receive(:new).with(:exclude, *@ary).and_return(@filter)
@script.config[:xtags] = @ary
@script.register
end
it "creates and registers a ProfileFilter for include specs" do
- ProfileFilter.should_receive(:new).with(:include, *@ary).and_return(@filter)
+ expect(ProfileFilter).to receive(:new).with(:include, *@ary).and_return(@filter)
@script.config[:profiles] = @ary
@script.register
end
it "creates and registers a ProfileFilter for excluded specs" do
- ProfileFilter.should_receive(:new).with(:exclude, *@ary).and_return(@filter)
+ expect(ProfileFilter).to receive(:new).with(:exclude, *@ary).and_return(@filter)
@script.config[:xprofiles] = @ary
@script.register
end
end
-describe MSpecScript, "#signals" do
+RSpec.describe MSpecScript, "#signals" do
before :each do
@script = MSpecScript.new
@abort = @script.config[:abort]
@@ -334,42 +334,42 @@ describe MSpecScript, "#signals" do
end
it "traps the INT signal if config[:abort] is true" do
- Signal.should_receive(:trap).with("INT")
+ expect(Signal).to receive(:trap).with("INT")
@script.config[:abort] = true
@script.signals
end
it "does not trap the INT signal if config[:abort] is not true" do
- Signal.should_not_receive(:trap).with("INT")
+ expect(Signal).not_to receive(:trap).with("INT")
@script.config[:abort] = false
@script.signals
end
end
-describe MSpecScript, "#entries" do
+RSpec.describe MSpecScript, "#entries" do
before :each do
@script = MSpecScript.new
- File.stub(:realpath).and_return("name")
- File.stub(:file?).and_return(false)
- File.stub(:directory?).and_return(false)
+ allow(File).to receive(:realpath).and_return("name")
+ allow(File).to receive(:file?).and_return(false)
+ allow(File).to receive(:directory?).and_return(false)
end
it "returns the pattern in an array if it is a file" do
- File.should_receive(:realpath).with("file").and_return("file/expanded.rb")
- File.should_receive(:file?).with("file/expanded.rb").and_return(true)
- @script.entries("file").should == ["file/expanded.rb"]
+ expect(File).to receive(:realpath).with("file").and_return("file/expanded.rb")
+ expect(File).to receive(:file?).with("file/expanded.rb").and_return(true)
+ expect(@script.entries("file")).to eq(["file/expanded.rb"])
end
it "returns Dir['pattern/**/*_spec.rb'] if pattern is a directory" do
- File.should_receive(:directory?).with("name").and_return(true)
- File.stub(:realpath).and_return("name", "name/**/*_spec.rb")
- Dir.should_receive(:[]).with("name/**/*_spec.rb").and_return(["dir1", "dir2"])
- @script.entries("name").should == ["dir1", "dir2"]
+ expect(File).to receive(:directory?).with("name").and_return(true)
+ allow(File).to receive(:realpath).and_return("name", "name/**/*_spec.rb")
+ expect(Dir).to receive(:[]).with("name/**/*_spec.rb").and_return(["dir1", "dir2"])
+ expect(@script.entries("name")).to eq(["dir1", "dir2"])
end
it "aborts if pattern cannot be resolved to a file nor a directory" do
- @script.should_receive(:abort)
+ expect(@script).to receive(:abort)
@script.entries("pattern")
end
@@ -382,47 +382,47 @@ describe MSpecScript, "#entries" do
it "returns the pattern in an array if it is a file" do
name = "#{@name}.rb"
- File.should_receive(:realpath).with(name).and_return(name)
- File.should_receive(:file?).with(name).and_return(true)
- @script.entries("name.rb").should == [name]
+ expect(File).to receive(:realpath).with(name).and_return(name)
+ expect(File).to receive(:file?).with(name).and_return(true)
+ expect(@script.entries("name.rb")).to eq([name])
end
it "returns Dir['pattern/**/*_spec.rb'] if pattern is a directory" do
- File.stub(:realpath).and_return(@name, @name+"/**/*_spec.rb")
- File.should_receive(:directory?).with(@name).and_return(true)
- Dir.should_receive(:[]).with(@name + "/**/*_spec.rb").and_return(["dir1", "dir2"])
- @script.entries("name").should == ["dir1", "dir2"]
+ allow(File).to receive(:realpath).and_return(@name, @name+"/**/*_spec.rb")
+ expect(File).to receive(:directory?).with(@name).and_return(true)
+ expect(Dir).to receive(:[]).with(@name + "/**/*_spec.rb").and_return(["dir1", "dir2"])
+ expect(@script.entries("name")).to eq(["dir1", "dir2"])
end
it "aborts if pattern cannot be resolved to a file nor a directory" do
- @script.should_receive(:abort)
+ expect(@script).to receive(:abort)
@script.entries("pattern")
end
end
end
-describe MSpecScript, "#files" do
+RSpec.describe MSpecScript, "#files" do
before :each do
@script = MSpecScript.new
end
it "accumulates the values returned by #entries" do
- @script.should_receive(:entries).and_return(["file1"], ["file2"])
- @script.files(["a", "b"]).should == ["file1", "file2"]
+ expect(@script).to receive(:entries).and_return(["file1"], ["file2"])
+ expect(@script.files(["a", "b"])).to eq(["file1", "file2"])
end
it "strips a leading '^' and removes the values returned by #entries" do
- @script.should_receive(:entries).and_return(["file1"], ["file2"], ["file1"])
- @script.files(["a", "b", "^a"]).should == ["file2"]
+ expect(@script).to receive(:entries).and_return(["file1"], ["file2"], ["file1"])
+ expect(@script.files(["a", "b", "^a"])).to eq(["file2"])
end
it "processes the array elements in order" do
- @script.should_receive(:entries).and_return(["file1"], ["file1"], ["file2"])
- @script.files(["^a", "a", "b"]).should == ["file1", "file2"]
+ expect(@script).to receive(:entries).and_return(["file1"], ["file1"], ["file2"])
+ expect(@script.files(["^a", "a", "b"])).to eq(["file1", "file2"])
end
end
-describe MSpecScript, "#files" do
+RSpec.describe MSpecScript, "#files" do
before :each do
MSpecScript.set :files, ["file1", "file2"]
@@ -434,21 +434,21 @@ describe MSpecScript, "#files" do
end
it "looks up items with leading ':' in the config object" do
- @script.should_receive(:entries).and_return(["file1"], ["file2"])
- @script.files([":files"]).should == ["file1", "file2"]
+ expect(@script).to receive(:entries).and_return(["file1"], ["file2"])
+ expect(@script.files([":files"])).to eq(["file1", "file2"])
end
it "aborts if the config key is not set" do
- @script.should_receive(:abort).with("Key :all_files not found in mspec config.")
+ expect(@script).to receive(:abort).with("Key :all_files not found in mspec config.")
@script.files([":all_files"])
end
end
-describe MSpecScript, "#setup_env" do
+RSpec.describe MSpecScript, "#setup_env" do
before :each do
@script = MSpecScript.new
@options, @config = new_option
- @script.stub(:config).and_return(@config)
+ allow(@script).to receive(:config).and_return(@config)
end
after :each do
@@ -457,19 +457,19 @@ describe MSpecScript, "#setup_env" do
it "sets MSPEC_RUNNER = '1' in the environment" do
ENV["MSPEC_RUNNER"] = "0"
@script.setup_env
- ENV["MSPEC_RUNNER"].should == "1"
+ expect(ENV["MSPEC_RUNNER"]).to eq("1")
end
it "sets RUBY_EXE = config[:target] in the environment" do
ENV["RUBY_EXE"] = nil
@script.setup_env
- ENV["RUBY_EXE"].should == @config[:target]
+ expect(ENV["RUBY_EXE"]).to eq(@config[:target])
end
it "sets RUBY_FLAGS = config[:flags] in the environment" do
ENV["RUBY_FLAGS"] = nil
@config[:flags] = ["-w", "-Q"]
@script.setup_env
- ENV["RUBY_FLAGS"].should == "-w -Q"
+ expect(ENV["RUBY_FLAGS"]).to eq("-w -Q")
end
end
diff --git a/spec/mspec/spec/utils/version_spec.rb b/spec/mspec/spec/utils/version_spec.rb
index 0b2d383c6d..ec367d2a1e 100644
--- a/spec/mspec/spec/utils/version_spec.rb
+++ b/spec/mspec/spec/utils/version_spec.rb
@@ -1,45 +1,45 @@
require 'spec_helper'
require 'mspec/utils/version'
-describe SpecVersion, "#to_s" do
+RSpec.describe SpecVersion, "#to_s" do
it "returns the string with which it was initialized" do
- SpecVersion.new("1.8").to_s.should == "1.8"
- SpecVersion.new("2.118.9").to_s.should == "2.118.9"
+ expect(SpecVersion.new("1.8").to_s).to eq("1.8")
+ expect(SpecVersion.new("2.118.9").to_s).to eq("2.118.9")
end
end
-describe SpecVersion, "#to_str" do
+RSpec.describe SpecVersion, "#to_str" do
it "returns the same string as #to_s" do
version = SpecVersion.new("2.118.9")
- version.to_str.should == version.to_s
+ expect(version.to_str).to eq(version.to_s)
end
end
-describe SpecVersion, "#to_i with ceil = false" do
+RSpec.describe SpecVersion, "#to_i with ceil = false" do
it "returns an integer representation of the version string" do
- SpecVersion.new("2.23.10").to_i.should == 1022310
+ expect(SpecVersion.new("2.23.10").to_i).to eq(1022310)
end
it "replaces missing version parts with zeros" do
- SpecVersion.new("1.8").to_i.should == 1010800
- SpecVersion.new("1.8.6").to_i.should == 1010806
+ expect(SpecVersion.new("1.8").to_i).to eq(1010800)
+ expect(SpecVersion.new("1.8.6").to_i).to eq(1010806)
end
end
-describe SpecVersion, "#to_i with ceil = true" do
+RSpec.describe SpecVersion, "#to_i with ceil = true" do
it "returns an integer representation of the version string" do
- SpecVersion.new("1.8.6", true).to_i.should == 1010806
+ expect(SpecVersion.new("1.8.6", true).to_i).to eq(1010806)
end
it "fills in 9s for missing tiny values" do
- SpecVersion.new("1.8", true).to_i.should == 1010899
- SpecVersion.new("1.8.6", true).to_i.should == 1010806
+ expect(SpecVersion.new("1.8", true).to_i).to eq(1010899)
+ expect(SpecVersion.new("1.8.6", true).to_i).to eq(1010806)
end
end
-describe SpecVersion, "#to_int" do
+RSpec.describe SpecVersion, "#to_int" do
it "returns the same value as #to_i" do
version = SpecVersion.new("4.16.87")
- version.to_int.should == version.to_i
+ expect(version.to_int).to eq(version.to_i)
end
end