call #to_s on exception_message before calling #split #622

Merged
merged 2 commits into from May 18, 2012
Jump to file or symbol
Failed to load files and symbols.
+10 −1
Split
@@ -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
@@ -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') }