[katello-devel] Rspec hidden exceptions

Lukas Zapletal lzap at redhat.com
Fri Jan 13 16:29:27 UTC 2012


Hello,

this week, I was investigating why Rails sometimes "eats" exceptions
when executing rspec tests. It turns out an exception is consumed if
something bad happens in filters.

The problem is this line in the api_controller:

rescue_from Exception, :with => proc { |e| render_exception(500, e) }

It his much more difficult to find out the root cause and I usually need
to comment out this line to find it. For some reason exception stack
trace is not rendered using render_exception.

I am thinking about adding a condition to this general rescue_from:

rescue_from Exception, :with => proc { |e| render_exception(500, e) }
  unless Rails.env == "test"

There is one drawback - if I do this we have 24 tests failing now. The
reason is we do not properly stub calls, error is thrown but we expect
it or ignore or something. So I would need to fix that. That is not a
high number since we have 1546 examples.

For UI controller it is the very same, but guys are more lucky. Only 4
errors when rescue_from Exception is commented out (or given condition
like the one above).

Opinions? I spent this week implementing permissions for API calls and I
did lot of unit testing. I think this helps a lot. On the other hand
it's an investment of fixing 28 unit tests.

-- 
Later,

 Lukas Zapletal | E32E400A
 RHN Satellite Engineering
 Red Hat Czech s.r.o. Brno




More information about the katello-devel mailing list