mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Remove warnings shown when running tests
* For some reason, ActiveRecord was printing a warning saying that "active_record/base" was already being loaded and there was a possible circular dependency. We fix this by explicitly requiring "active_record/base" before `$VERBOSE` is set to true. * We were getting warnings when re-defining Kernel.capture, Kernel.silence_stream and Kernel.silence_stderr, so undefine them first.
This commit is contained in:
parent
6b9f22a92f
commit
6cc7fd8ca2
2 changed files with 8 additions and 0 deletions
|
@ -2,6 +2,8 @@ module Kernel
|
||||||
# #capture, #silence_stream, and #silence_stderr are deprecated after Rails
|
# #capture, #silence_stream, and #silence_stderr are deprecated after Rails
|
||||||
# 4.2 and will be removed in 5.0, so just override them completely here
|
# 4.2 and will be removed in 5.0, so just override them completely here
|
||||||
|
|
||||||
|
undef_method :capture
|
||||||
|
|
||||||
def capture(stream)
|
def capture(stream)
|
||||||
stream = stream.to_s
|
stream = stream.to_s
|
||||||
captured_stream = Tempfile.new(stream)
|
captured_stream = Tempfile.new(stream)
|
||||||
|
@ -18,6 +20,8 @@ module Kernel
|
||||||
stream_io.reopen(origin_stream)
|
stream_io.reopen(origin_stream)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
undef_method :silence_stream
|
||||||
|
|
||||||
def silence_stream(stream)
|
def silence_stream(stream)
|
||||||
old_stream = stream.dup
|
old_stream = stream.dup
|
||||||
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
||||||
|
@ -28,6 +32,8 @@ module Kernel
|
||||||
old_stream.close
|
old_stream.close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
undef_method :silence_stderr
|
||||||
|
|
||||||
def silence_stderr
|
def silence_stderr
|
||||||
silence_stream(STDERR) { yield }
|
silence_stream(STDERR) { yield }
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,8 @@ $test_app = UnitTests::RailsApplication.new
|
||||||
$test_app.create
|
$test_app.create
|
||||||
$test_app.load
|
$test_app.load
|
||||||
|
|
||||||
|
require 'active_record/base'
|
||||||
|
|
||||||
ENV['BUNDLE_GEMFILE'] ||= app.gemfile_path
|
ENV['BUNDLE_GEMFILE'] ||= app.gemfile_path
|
||||||
ENV['RAILS_ENV'] = 'test'
|
ENV['RAILS_ENV'] = 'test'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue