ruby-on-rails – Rails rspec is outputting too much

Question:

I'm using rails 4.2.4 and rspec-rails 3.3.3

.rspec file only --color .

When running a test (rspec or rake), there are a lot of lines like this after the standard error:

# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_dispatch/journey/formatter.rb:46:in `generate'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:729:in `generate'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:760:in `generate'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:755:in `generate_extras'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:750:in `extra_keys'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_controller/test_case.rb:208:in `assign_parameters'
# /home/ruslan/.rvm/gems/ruby-2.2.2@qna/gems/actionpack-4.2.4/lib/action_controlle...

How to get rid of such ( .../.rvm/gems/... ) lines?

Answer:

You need these lines. It is better not to get rid of them.

This is "stack trace" , popularly called "stack trace ".

Each subsequent line in this output shows where the previous one was called from. Having broken this, you are more likely to get confused yourself or confuse someone else if you encounter any meaningful errors.

Because the real error is not always on the surface of the stack trace. To structure the code so that they are always on the surface is a noble goal. But the harsh reality is that you have to go deeper.

  • Since it is common practice in Ruby to transfer your own executable code to libraries, you may have situations when an "explosion" occurred (by trace lines, 1) in your code, (2) called inside the gem, (3) which was in turn called in your code. If you remove the gem lines in the stack trace, the stack trace will contain a logical hole. If you don't remember that gem lines are muted, then you can spend a lot of time looking for a call that does not exist.
  • The error can easily be in the gem. Why not? You shouldn't blindly trust third-party libraries: their tests (if any) may be incomplete.
Scroll to Top