[rspec-users] cleaner failure messages?

15 views
Skip to first unread message

rogerdpack

unread,
Jun 19, 2010, 4:54:58 PM6/19/10
to rspec...@rubyforge.org
Hi all.
Sorry if this is an old request...

Currently when a failure is reported it looks like this:

C:\dev\ruby\faster_rubygems\spec>spec
spec.faster_rubygems_cacheing.rb
F

1)
RuntimeError in 'FasterRubyGems cacheing Gem.bin_path should cache and
reload Gem.bin_path where possible'
assertion failed
C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:
14:in `block (3 levels) in <top (required)>'

This is good because it tells me what line failed, but that's about
it.

The skinny of this request is that I'd find it more useful to actually
have the code displayed that failed on line 14, in this case, the word
"fail"

so like this:
C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:14:
"fail"
Instead of the current
C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:
14:in `block (3 levels) in <top (required)>'

So the failure report is good, but could be improved.
Another option would be to display the line below what is currently
output, like

C:/dev/ruby/faster_rubygems/spec/spec.faster_rubygems_cacheing.rb:
14:in `block (3 levels) in <top (required)>'
fail

Or something like that.
Any thoughts there?
Thanks.
-rp
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

David Chelimsky

unread,
Jun 19, 2010, 5:17:07 PM6/19/10
to rspec-users

Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever).

Cheers,
David

rogerdpack

unread,
Jun 22, 2010, 3:09:17 AM6/22/10
to rspec...@rubyforge.org
> > The skinny of this request is that I'd find it more useful to actually
> > have the code displayed that failed on line 14, in this case, the word
> > "fail"
...

> Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever).

Nice. Looks like rspec-2 will fit the bill for me for now, then.

1) Gem speeding Gem.bin_path the fake sick way should fake guess the
right path instead of loading full rubygems for now
Failure/Error: Unable to find matching line from backtrace
# spec.faster_rubygems.rb:29
# spec.faster_rubygems.rb:13

Perhaps it isn't quite windows friendly?
Thanks.
-rp

David Chelimsky

unread,
Jun 22, 2010, 8:40:19 AM6/22/10
to rspec-users
On Jun 22, 2010, at 2:09 AM, rogerdpack wrote:

>>> The skinny of this request is that I'd find it more useful to actually
>>> have the code displayed that failed on line 14, in this case, the word
>>> "fail"
> ...
>> Already done in rspec-2. Likely won't backport it to rspec-1 for some time (if ever).
>
> Nice. Looks like rspec-2 will fit the bill for me for now, then.
>
> 1) Gem speeding Gem.bin_path the fake sick way should fake guess the
> right path instead of loading full rubygems for now
> Failure/Error: Unable to find matching line from backtrace
> # spec.faster_rubygems.rb:29
> # spec.faster_rubygems.rb:13
>
> Perhaps it isn't quite windows friendly?

That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug.

HTH,
David

rogerdpack

unread,
Jun 22, 2010, 11:27:24 AM6/22/10
to rspec...@rubyforge.org
> >    Failure/Error: Unable to find matching line from backtrace

> > Perhaps it isn't quite windows friendly?


>
> That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug.

Interesting.
I get the same thing with Linux.
If I add the word "fail" to an rspec, it says the same (not an eval
string...)...

Here's the output if I run it -b

1) Gem speeding Gem.bin_path the fake sick way should fake guess the
right path instead of loading full rubygems for now
Failure/Error: Unable to find matching line from backtrace

# spec.faster_rubygems.rb:29:in `block (3 levels) in <main>'
# /home/rdp/installs/ruby-1.9.1-p376_installed/lib/ruby/gems/1.9.1/
gems/rspec-core-2.0.0.beta.12/lib/rspec/core/example.rb:47:in
`instance_eval'

Hmm.
-r

David Chelimsky

unread,
Jun 22, 2010, 12:08:37 PM6/22/10
to rspec-users

On Jun 22, 2010, at 10:27 AM, rogerdpack wrote:

>>> Failure/Error: Unable to find matching line from backtrace
>
>>> Perhaps it isn't quite windows friendly?
>>
>> That happens now and then when the error is in code generated with eval(string) with no file and ref numbers. Has nothing to do with Windows as far as I know, and is the same problem we have with ruby-debug.
>
> Interesting.
> I get the same thing with Linux.
> If I add the word "fail" to an rspec, it says the same (not an eval
> string...)...
>
> Here's the output if I run it -b
>
> 1) Gem speeding Gem.bin_path the fake sick way should fake guess the
> right path instead of loading full rubygems for now
> Failure/Error: Unable to find matching line from backtrace
> # spec.faster_rubygems.rb:29:in `block (3 levels) in <main>'
> # /home/rdp/installs/ruby-1.9.1-p376_installed/lib/ruby/gems/1.9.1/
> gems/rspec-core-2.0.0.beta.12/lib/rspec/core/example.rb:47:in
> `instance_eval'

Please file an issue at http://github.com/rspec/rspec-core/issues

Feel free to reference the method that handles this:

http://github.com/rspec/rspec-core/blob/master/lib/rspec/core/formatters/base_formatter.rb#L118

Thanks

Reply all
Reply to author
Forward
0 new messages