저는 Ruby on Rails 초보자 및 필기 테스트입니다. 이들 중 일부는 예외를 생성합니다. "레이크 테스트"출력에서 예외 오류 메시지를 표시하지만 전체 역 추적은 제공하지 않습니다. (. 내가 다음에 채울 수 있습니다 구현되지 않은 기능을 발휘 테스트를 작성하고 싶습니다) 예를 들어레일스가 에러를 테스트 할 때 스택 트레이스를 억제합니다.
, 실제 출력 :
Started
E
Finished in 0.081054 seconds.
1) Error:
test_should_fail(VersioningTest):
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "client_ip" violates not-null constraint
: INSERT INTO "revisions" ("created_at", "id") VALUES ('2011-02-03 20:14:17', 980190962)
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `rescue in log'
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:194:in `log'
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:496:in `execute'
[... etc. etc. etc. ...]
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
원하는 출력 :
Started
E
Finished in 0.081054 seconds.
1) Error:
test_should_fail(VersioningTest):
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "client_ip" violates not-null constraint
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
I 발견 된 정보 (e.g.)는 반대 방향이지만 스택 추적을 억제하지는 않습니다.
편집 :
ON과 OFF 쉽게 설정하는 좋은 것; 아래에 지적했듯이 때로는 버그를 추적하는 데 유용합니다.
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but
# don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying do debug a
# problem that might steem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
Rails.backtrace_cleaner.add_silencer {|line| line =~ /gems/}
Rails.backtrace_cleaner.add_silencer {|line| line =~ /passenger/}
당신이 할 수 있어야한다처럼 보이는 : -
좋아, 그래서 스택 추적 텍스트 장식물의 불량 데이터에서 오는 것으로 판명; 수리 한 결과 출력은 예상대로입니다. 틀린 가정에 근거한 질문을 다루기위한 에티켓은 무엇입니까? – Reid