mercredi 16 novembre 2016

My rails tests produce gibberish output

I just overtook a new project and the rake test produces a lot of gibberish output. Why is that the case? I tried removing all gems I don't know, but still my output is clouded. I am calling the test suite via bundle exec rake test.

Sample output - it's pages of this kind of stuff.

/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead
/Users/hendricius/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.22.5/lib/active_support/file_update_checker.rb:98: warning: File.exists? is a deprecated name,
use File.exist? instead

screenshot of the tests running

The ruby version from the .ruby-version file is 2.2.2. The installed rails version is 3.2.22.5.

My test gems are:

group :test, :development do
  # gem 'rack-mini-profiler'
  # gem 'minitest'
  gem 'minitest-rails'
  gem 'test-unit'
  gem 'shoulda'
  gem 'shoulda-matchers'
  gem 'fabrication'
  gem 'byebug'
end

I then double checked my Rakefile. It has the following content:

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

WooWoop::Application.load_tasks

task default: [:test]

The only other thing I could imagine would be my test_helper. I pasted the contents below. It looks good.

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "minitest/pride"
require 'shoulda'
require 'shoulda/matchers'
# $VERBOSE=nil

# ActiveRecord::Migration.check_pending!
ActiveSupport::TestCase.test_order = :random
# Protractor test or even some dirty debugging in the rails console on test environment
# might have left some garbage on the DB. Lets make sure we start with a clean state.
# parses the response and returns it.

The only way I can silence the output is if I use RUBYOPT=W0 TEST=test/unit/shop_test.rb be rake test. Is that the only way since I am using rails 3 still?

Update:

I now tried to downgrade to ruby 2.0.0

I still get a lot of strange warnings I have never seen before.

/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:89: warning: instance variable @mount_on not in
itialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:243: warning: instance variable @previous_model_for_showcase_cov
er_picture not initialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:89: warning: instance variable @mount_on not in
itialized
/Users/hendricius/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:243: warning: instance variable @previous_model_for_manager_pict
ure not initialized
(eval):11: warning: instance variable @opening_hours_monday_from not initialized
(eval):2: warning: instance variable @opening_hours_monday_to not initialized
(eval):11: warning: instance variable @opening_hours_tuesday_from not initialized
(eval):2: warning: instance variable @opening_hours_tuesday_to not initialized
(eval):11: warning: instance variable @opening_hours_wednesday_from not initialized
(eval):2: warning: instance variable @opening_hours_wednesday_to not initialized
(eval):11: warning: instance variable @opening_hours_thursday_from not initialized
(eval):2: warning: instance variable @opening_hours_thursday_to not initialized
(eval):11: warning: instance variable @opening_hours_friday_from not initialized
(eval):2: warning: instance variable @opening_hours_friday_to not initialized
(eval):11: warning: instance variable @opening_hours_saturday_from not initialized
(eval):2: warning: instance variable @opening_hours_saturday_to not initialized

Edit:

I ultimately ended up upgrading to rails 4. All the warnings are gone.

Aucun commentaire:

Enregistrer un commentaire