diff options
Diffstat (limited to 'spec/mspec/spec/matchers/raise_error_spec.rb')
-rw-r--r-- | spec/mspec/spec/matchers/raise_error_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb index 88aab34d53..7c93f0f64c 100644 --- a/spec/mspec/spec/matchers/raise_error_spec.rb +++ b/spec/mspec/spec/matchers/raise_error_spec.rb @@ -90,6 +90,18 @@ describe RaiseErrorMatcher do ["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"] end + it "provides a useful failure message when no exception is raised and the result raises in #pretty_inspect" do + result = Object.new + def result.pretty_inspect + raise ArgumentError, "bad" + end + proc = Proc.new { result } + matcher = RaiseErrorMatcher.new(ExpectedException, "expected") + matcher.matches?(proc) + matcher.failure_message.should == + ["Expected ExpectedException (expected)", "but no exception was raised (#pretty_inspect raised ArgumentError; A #<Object> was returned)"] + end + it "provides a useful negative failure message" do proc = Proc.new { raise ExpectedException, "expected" } matcher = RaiseErrorMatcher.new(ExpectedException, "expected") |