Browse files

Merge pull request #622 from slyphon/dump_failure_info_fix

call #to_s on exception_message before calling #split
  • Loading branch information...
1 parent fffc4c5 commit 6d83a5ecfc0d777037bf7e5e0a27846306b1f477 @dchelimsky dchelimsky committed May 18, 2012
View
2 lib/rspec/core/formatters/base_text_formatter.rb
@@ -179,7 +179,7 @@ def dump_failure_info(example)
exception = example.execution_result[:exception]
output.puts "#{long_padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}"
output.puts "#{long_padding}#{red(exception.class.name << ":")}" unless exception.class.name =~ /RSpec/
- exception.message.split("\n").each { |line| output.puts "#{long_padding} #{red(line)}" } if exception.message
+ exception.message.to_s.split("\n").each { |line| output.puts "#{long_padding} #{red(line)}" } if exception.message
if shared_group = find_shared_group(example)
dump_shared_failure_info(shared_group)
end
View
9 spec/rspec/core/formatters/base_text_formatter_spec.rb
@@ -65,6 +65,15 @@ def run_all_and_dump_failures
end
end
+ context "with an exception that has an exception instance as its message" do
+ it "should not raise NoMethodError" do
+ gonzo_exception = RuntimeError.new
+ gonzo_exception.stub(:message) { gonzo_exception }
+ group.example("example name") { raise gonzo_exception }
+ expect { run_all_and_dump_failures }.not_to 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 NameError.new('foo') }

0 comments on commit 6d83a5e

Please sign in to comment.