2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rspecでwarningが多すぎて辛い時

Posted at

概要

rspec実施時に出るwarningを消したい場合は、.rspecファイルとspec_helper.rbに出てくるwarningと書かれてる部分をとにかく消しまくればOK

背景

下のようにrspecを実施するとwarningがたくさん出て、肝心のエラーが見つけにくい

$ rake
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I/Users/hoge/.gem/ruby/2.0.0/gems/rspec-support-3.5.0/lib:/Library/Ruby/Gems/2.0.0/gems/rspec-core-3.5.3/lib /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.5.3/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/Library/Ruby/Gems/2.0.0/gems/holiday_japan-1.2.2/lib/holiday_japan.rb:65: warning: assigned but unused variable - name
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55: warning: loading in progress, circular require considered harmful - ./date.rb
...

解決策

  1. .rspecの修正
  2. spec_helper.rbの修正

1. .rspecの修正

./.rspecを下記のように修正

- --warnings

これだけで解決する場合もあるが、下記が同ファイルに記載されている場合は、2を実施する必要があるかもしれない

.rspec
--require spec_helper

2. spec_helper.rbの修正

./spec/spec_helper.rbを下記のように修正

-  config.warnings = true
+  config.warnings = false

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?