summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/runner/exception_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/spec/runner/exception_spec.rb')
-rw-r--r--spec/mspec/spec/runner/exception_spec.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/spec/mspec/spec/runner/exception_spec.rb b/spec/mspec/spec/runner/exception_spec.rb
index 0e0a819992..a77a2c9cf4 100644
--- a/spec/mspec/spec/runner/exception_spec.rb
+++ b/spec/mspec/spec/runner/exception_spec.rb
@@ -4,16 +4,16 @@ require 'mspec/runner/example'
require 'mspec/runner/exception'
require 'mspec/utils/script'
-describe ExceptionState, "#initialize" do
+RSpec.describe ExceptionState, "#initialize" do
it "takes a state, location (e.g. before :each), and exception" do
context = ContextState.new "Class#method"
state = ExampleState.new context, "does something"
exc = Exception.new "Fail!"
- ExceptionState.new(state, "location", exc).should be_kind_of(ExceptionState)
+ expect(ExceptionState.new(state, "location", exc)).to be_kind_of(ExceptionState)
end
end
-describe ExceptionState, "#description" do
+RSpec.describe ExceptionState, "#description" do
before :each do
context = ContextState.new "Class#method"
@state = ExampleState.new context, "does something"
@@ -21,99 +21,99 @@ describe ExceptionState, "#description" do
it "returns the state description if state was not nil" do
exc = ExceptionState.new(@state, nil, nil)
- exc.description.should == "Class#method does something"
+ expect(exc.description).to eq("Class#method does something")
end
it "returns the location if it is not nil and description is nil" do
exc = ExceptionState.new(nil, "location", nil)
- exc.description.should == "An exception occurred during: location"
+ expect(exc.description).to eq("An exception occurred during: location")
end
it "returns both description and location if neither are nil" do
exc = ExceptionState.new(@state, "location", nil)
- exc.description.should == "An exception occurred during: location\nClass#method does something"
+ expect(exc.description).to eq("An exception occurred during: location\nClass#method does something")
end
end
-describe ExceptionState, "#describe" do
+RSpec.describe ExceptionState, "#describe" do
before :each do
context = ContextState.new "Class#method"
@state = ExampleState.new context, "does something"
end
it "returns the ExampleState#describe string if created with a non-nil state" do
- ExceptionState.new(@state, nil, nil).describe.should == @state.describe
+ expect(ExceptionState.new(@state, nil, nil).describe).to eq(@state.describe)
end
it "returns an empty string if created with a nil state" do
- ExceptionState.new(nil, nil, nil).describe.should == ""
+ expect(ExceptionState.new(nil, nil, nil).describe).to eq("")
end
end
-describe ExceptionState, "#it" do
+RSpec.describe ExceptionState, "#it" do
before :each do
context = ContextState.new "Class#method"
@state = ExampleState.new context, "does something"
end
it "returns the ExampleState#it string if created with a non-nil state" do
- ExceptionState.new(@state, nil, nil).it.should == @state.it
+ expect(ExceptionState.new(@state, nil, nil).it).to eq(@state.it)
end
it "returns an empty string if created with a nil state" do
- ExceptionState.new(nil, nil, nil).it.should == ""
+ expect(ExceptionState.new(nil, nil, nil).it).to eq("")
end
end
-describe ExceptionState, "#failure?" do
+RSpec.describe ExceptionState, "#failure?" do
before :each do
@state = ExampleState.new ContextState.new("C#m"), "works"
end
it "returns true if the exception is an SpecExpectationNotMetError" do
exc = ExceptionState.new @state, "", SpecExpectationNotMetError.new("Fail!")
- exc.failure?.should be_true
+ expect(exc.failure?).to be_truthy
end
it "returns true if the exception is an SpecExpectationNotFoundError" do
exc = ExceptionState.new @state, "", SpecExpectationNotFoundError.new("Fail!")
- exc.failure?.should be_true
+ expect(exc.failure?).to be_truthy
end
it "returns false if the exception is not an SpecExpectationNotMetError or an SpecExpectationNotFoundError" do
exc = ExceptionState.new @state, "", Exception.new("Fail!")
- exc.failure?.should be_false
+ expect(exc.failure?).to be_falsey
end
end
-describe ExceptionState, "#message" do
+RSpec.describe ExceptionState, "#message" do
before :each do
@state = ExampleState.new ContextState.new("C#m"), "works"
end
it "returns <No message> if the exception message is empty" do
exc = ExceptionState.new @state, "", Exception.new("")
- exc.message.should == "Exception: <No message>"
+ expect(exc.message).to eq("Exception: <No message>")
end
it "returns the message without exception class when the exception is an SpecExpectationNotMetError" do
exc = ExceptionState.new @state, "", SpecExpectationNotMetError.new("Fail!")
- exc.message.should == "Fail!"
+ expect(exc.message).to eq("Fail!")
end
it "returns SpecExpectationNotFoundError#message when the exception is an SpecExpectationNotFoundError" do
e = SpecExpectationNotFoundError.new
exc = ExceptionState.new @state, "", e
- exc.message.should == e.message
+ expect(exc.message).to eq(e.message)
end
it "returns the message with exception class when the exception is not an SpecExpectationNotMetError or an SpecExpectationNotFoundError" do
exc = ExceptionState.new @state, "", Exception.new("Fail!")
- exc.message.should == "Exception: Fail!"
+ expect(exc.message).to eq("Exception: Fail!")
end
end
-describe ExceptionState, "#backtrace" do
+RSpec.describe ExceptionState, "#backtrace" do
before :each do
@state = ExampleState.new ContextState.new("C#m"), "works"
begin
@@ -128,19 +128,19 @@ describe ExceptionState, "#backtrace" do
end
it "returns a string representation of the exception backtrace" do
- @exc.backtrace.should be_kind_of(String)
+ expect(@exc.backtrace).to be_kind_of(String)
end
it "does not filter files from the backtrace if $MSPEC_DEBUG is true" do
$MSPEC_DEBUG = true
- @exc.backtrace.should == @exception.backtrace.join("\n")
+ expect(@exc.backtrace).to eq(@exception.backtrace.join("\n"))
end
it "filters files matching config[:backtrace_filter]" do
MSpecScript.set :backtrace_filter, %r[mspec/lib]
$MSPEC_DEBUG = nil
@exc.backtrace.split("\n").each do |line|
- line.should_not =~ %r[mspec/lib]
+ expect(line).not_to match(%r[mspec/lib])
end
end
end