Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix NoMethodError when an exception has no message. #308

wants to merge 3 commits into from

2 participants


No description provided.


Please add a spec or cuke that fails without this change.

Hans Hasselberg added some commits

Sorry for the delay and for not providing any specs at first.


don't stumble over an exception without a message.


No apologies, please. Thanks for the contribution!

@andreastt andreastt referenced this pull request from a commit
Hans Hasselberg don't stumble over an exception without a message.
- Closes #308.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2011
  1. don't stumble over an exception without a message.

    Hans Hasselberg authored
Commits on Feb 15, 2011
  1. add spec which fails without my patch

    Hans Hasselberg authored
  2. more expressive

    Hans Hasselberg authored
This page is out of date. Refresh to see the latest.
2  lib/rspec/core/formatters/base_text_formatter.rb
@@ -148,7 +148,7 @@ def dump_failure(example, index)
output.puts "#{short_padding}#{}) #{example.full_description}"
output.puts "#{long_padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
output.puts "#{long_padding}#{red( << ":")}" unless =~ /RSpec/
- exception.message.split("\n").each { |line| output.puts "#{long_padding} #{red(line)}" }
+ exception.message.split("\n").each { |line| output.puts "#{long_padding} #{red(line)}" } if exception.message
example.example_group.ancestors.push(example.example_group).each do |group|
if group.metadata[:shared_group_name]
9 spec/rspec/core/formatters/base_text_formatter_spec.rb
@@ -46,6 +46,15 @@ def run_all_and_dump_failures
output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
+ context "with an exception without a message" do
+ it "does not throw NoMethodError" do
+ exception_without_message =
+ exception_without_message.stub(:message){nil}
+ group.example("example name") { raise exception_without_message }
+ expect { run_all_and_dump_failures }.to_not raise_error(NoMethodError)
+ end
+ end
context "with an exception class other than RSpec" do
it "does not show the error class" do
group.example("example name") { raise'foo') }
Something went wrong with that request. Please try again.