Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix NoMethodError when an exception has no message. #308

Closed
wants to merge 3 commits into from

2 participants

@i0rek

No description provided.

@dchelimsky
Owner

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

Hans Hasselberg added some commits
@i0rek

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

@i0rek

don't stumble over an exception without a message.

@dchelimsky
Owner

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.
6a12e37
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.
View
2  lib/rspec/core/formatters/base_text_formatter.rb
@@ -148,7 +148,7 @@ def dump_failure(example, index)
output.puts "#{short_padding}#{index.next}) #{example.full_description}"
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)}" }
+ 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]
View
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
end
+ context "with an exception without a message" do
+ it "does not throw NoMethodError" do
+ exception_without_message = Exception.new()
+ 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 NameError.new('foo') }
Something went wrong with that request. Please try again.