UPDATE 20180209: I created a new dummy app with what comes with the initial Rails 5.1.4 install (which includes minitest 5.11.3) and tests completed without issue. Going to continue to experiment with the gemfile to see if I can't narrow down what in the world may be causing this problem...
If you have any ideas or pointers, please let me know!
I recently started testing a new portion of my codebase and I've discovered a very critical issue. For whatever reason, every test is now throwing the titled error. Looking into the trace, it looks like for some reason the quoted name/title of my tests is causing a problem. Going back and running tests that I know were passing (though admittedly on earlier gem versions) unfortunately yields the same results, as shown below with the User model.
I've tried everything I know to do, including completely removing and reinstalling RVM, Rails, and Ruby. I've even tried versioning Minitest to an earlier build, like 10.5.3, but still no luck. I've spent most of the day trying to fix this; I'm at my wits end and desperately need help! Though I've learned the hard way that I now need to explicitly version protect ALL of my gems ;)
Thank you in advance! Please let me know if you need me to include any more files/snippets. I'll do my best to reply to any questions as my schedule allows, hopefully within 24 hours.
Returned trace:
E
Error: UserTest#test_should_be_valid: TypeError: no implicit conversion of nil into String
/home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:70:in
method': undefined method
test_should_be_valid' for classMinitest::Result' (NameError) from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:70:in
format_rerun_snippet' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:23:inrecord' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:803:in
block in record' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:802:ineach' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:802:in
record' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:334:inrun_one_method' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:321:in
block (2 levels) in run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:320:ineach' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:320:in
block in run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:360:inon_signal' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:347:in
with_info_handler' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:319:inrun' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/line_filtering.rb:9:in
run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:159:inblock in __run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:159:in
map' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:159:in__run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:136:in
run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:63:inblock in autorun' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:171:in
fork' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:171:inserve' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:141:in
block in run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:135:inloop' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:135:in
run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in<top (required)>' from /home/blake/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in
require' from /home/blake/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from -e:1:in
'
This is from a fairly standard User model test that has not raised issues before...
user.rb
class User < ApplicationRecord
attr_accessor :remember_token, :activation_token, :reset_token
before_save :downcase_email
before_create :create_activation_digest
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password, presence: true, length: { minimum: 6 }, allow_nil: true
...
end
test/user_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User", email: "user@example.com",
password: "password", password_confirmation: "password")
end
test "should be valid" do
assert @user.valid?
end
...
end
test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
# NOTE: Disabling simplecov, trying to see if it is what is interfering with my backtrace_silencer settings
# require 'simplecov'
# SimpleCov.start
# require 'simplecov-json'
# SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
# Integrate AASM gem's custom testing methods into minitest
require 'aasm/minitest'
# NOTE: Minitest-reporters may overwrite backtrace_silencer settings. The below is supposed to force m-r to use the
# default Rails Minitest.backtrace_filter instead, though I'm still having trouble...
# https://github.com/kern/minitest-reporters
# require 'minitest/reporters'
# Minitest::Reporters.use!(
# Minitest::Reporters::ProgressReporter.new,
# ENV,
# Minitest.backtrace_filter)
# require 'fileutils'
class CarrierWave::Mount::Mounter
def store!
# Not storing uploads in the tests
end
end
class ActiveSupport::TestCase
include ApplicationHelper
include ActionDispatch::TestProcess
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# https://github.com/carrierwaveuploader/carrierwave/wiki/Using-Carrierwave-with-Minitest-and-Rails-5
# CarrierWave setup and teardown
carrierwave_template = Rails.root.join('test', 'fixtures', 'files')
carrierwave_root = Rails.root.join('test', 'support', 'carrierwave')
carrierwave_cache_dir = Rails.root.join('test', 'support', 'carrierwave', 'carrierwave_cache')
##
CarrierWave.configure do |config|
config.root = carrierwave_root
config.enable_processing = false
config.storage = :file
config.cache_dir = carrierwave_cache_dir
end
##
puts "*** Copying ***\n #{carrierwave_template.join('uploads').to_s}\n to\n #{carrierwave_root.to_s}"
FileUtils.cp_r carrierwave_template.join('uploads'), carrierwave_root
##
at_exit do
puts "*** Removing carrierwave test directories ***"
Dir.glob(carrierwave_root.join('*')).each do |dir|
#puts " #{dir}"
FileUtils.remove_entry(dir)
end
end
# CarrierWave.root = Rails.root.join('test/fixtures/files')
# FIXME: This seems to be causing some issues...
# def after_teardown
# super
# # Default clean schedule is one day, this changes is to immediately after use
# CarrierWave.clean_cached_files!(0)
# end
# Returns true if a test user is logged in
def is_logged_in?
!session[:user_id].nil?
end
# log in as particular user
def log_in_as(user)
session[:user_id] = user.id
end
end
class ActionDispatch::IntegrationTest
# Log in as a particular user
def log_in_as(user, password: 'password', remember_me: '1')
post login_path, params: { session: { email: user.email,
password: password,
remember_me: remember_me } }
end
end
I'm currently running
My gem list is as follows:
* CFPropertyList (2.3.6)
* aasm (4.12.3)
* actioncable (5.1.4)
* actionmailer (5.1.4)
* actionpack (5.1.4)
* actionview (5.1.4)
* activejob (5.1.4)
* activemodel (5.1.4)
* activerecord (5.1.4)
* activesupport (5.1.4)
* area (0.10.0)
* arel (8.0.0)
* ast (2.4.0)
* autoprefixer-rails (7.2.5)
* bcrypt (3.1.11)
* better_errors (2.4.0)
* bindex (0.5.0)
* binding_of_caller (0.8.0)
* bootstrap-sass (3.3.7)
* bootstrap-will_paginate (1.0.0)
* builder (3.2.3)
* bullet (5.7.2)
* bundler (1.16.1)
* carrierwave (1.2.2)
* carrierwave-imageoptimizer (1.4.0)
* coderay (1.1.2)
* coffee-rails (4.2.2)
* coffee-script (2.4.1)
* coffee-script-source (1.12.2)
* concurrent-ruby (1.0.5)
* crass (1.0.3)
* debug_inspector (0.0.3)
* domain_name (0.5.20170404)
* erubi (1.7.0)
* excon (0.60.0)
* execjs (2.7.0)
* faker (1.8.7)
* fastercsv (1.5.5)
* ffi (1.9.21)
* fission (0.5.0)
* flamegraph (0.9.5)
* fog (1.42.0)
* fog-aliyun (0.2.0)
* fog-atmos (0.1.0)
* fog-aws (2.0.0)
* fog-brightbox (0.14.0)
* fog-cloudatcost (0.1.2)
* fog-core (1.45.0)
* fog-digitalocean (0.3.0)
* fog-dnsimple (1.0.0)
* fog-dynect (0.0.3)
* fog-ecloud (0.3.0)
* fog-google (0.1.0)
* fog-internet-archive (0.0.1)
* fog-joyent (0.0.1)
* fog-json (1.0.2)
* fog-local (0.4.0)
* fog-openstack (0.1.23)
* fog-ovirt (0.1.2)
* fog-powerdns (0.1.1)
* fog-profitbricks (4.1.1)
* fog-rackspace (0.1.5)
* fog-radosgw (0.0.5)
* fog-riakcs (0.1.0)
* fog-sakuracloud (1.7.5)
* fog-serverlove (0.1.2)
* fog-softlayer (1.1.4)
* fog-storm_on_demand (0.1.1)
* fog-terremark (0.1.0)
* fog-vmfusion (0.1.0)
* fog-voxel (0.1.0)
* fog-vsphere (1.13.1)
* fog-xenserver (0.3.0)
* fog-xml (0.1.3)
* formatador (0.2.5)
* fuzzy_match (2.1.0)
* geocoder (1.4.5)
* globalid (0.4.1)
* guard (2.14.2)
* guard-compat (1.2.1)
* guard-minitest (2.4.6)
* http-cookie (1.0.3)
* i18n (0.9.3)
* image_optimizer (1.7.2)
* inflecto (0.0.2)
* ipaddress (0.8.3)
* jbuilder (2.7.0)
* jquery-rails (4.3.1)
* json (2.1.0)
* listen (3.1.5)
* loofah (2.1.1)
* lumberjack (1.0.12)
* mail (2.7.0)
* memory_profiler (0.9.8)
* method_source (0.8.2)
* mime-types (3.1)
* mime-types-data (3.2016.0521)
* mini_magick (4.8.0)
* mini_mime (1.0.0)
* mini_portile2 (2.3.0)
* minitest (5.11.3)
* multi_json (1.13.1)
* mustermann (1.0.1)
* nenv (0.3.0)
* netrc (0.11.0)
* nio4r (2.2.0)
* nokogiri (1.8.2)
* notiffany (0.1.1)
* parser (2.4.0.2)
* pg (0.21.0)
* pry (0.10.4)
* pry-nav (0.2.4)
* pry-rails (0.3.6)
* puma (3.11.2)
* rack (2.0.4)
* rack-mini-profiler (0.10.7)
* rack-protection (2.0.0)
* rack-test (0.8.2)
* rails (5.1.4)
* rails-controller-testing (1.0.2)
* rails-dom-testing (2.0.3)
* rails-html-sanitizer (1.0.3)
* railties (5.1.4)
* rake (12.3.0)
* rb-fsevent (0.10.2)
* rb-inotify (0.9.10)
* rbovirt (0.1.5)
* rbvmomi (1.11.6)
* rest-client (2.0.2)
* ruby_dep (1.5.0)
* sass (3.5.5)
* sass-listen (4.0.0)
* sass-rails (5.0.7)
* shellany (0.0.1)
* simple_form (3.5.0)
* sinatra (2.0.0)
* slop (3.6.0)
* solargraph (0.17.1)
* spring (2.0.2)
* spring-watcher-listen (2.0.1)
* sprockets (3.7.1)
* sprockets-rails (3.2.1)
* stackprof (0.2.11)
* thor (0.20.0)
* thread_safe (0.3.6)
* tilt (2.0.8)
* trollop (2.1.2)
* turbolinks (5.1.0)
* turbolinks-source (5.1.0)
* tzinfo (1.2.5)
* uglifier (4.1.6)
* unf (0.1.4)
* unf_ext (0.0.7.5)
* uniform_notifier (1.11.0)
* web-console (3.5.1)
* websocket-driver (0.6.5)
* websocket-extensions (0.1.3)
* will_paginate (3.1.6)
* xml-simple (1.1.5)
* yard (0.9.12)
Got this sorted out by reverting to an earlier commit when things were working as expected, and pulled in needed updates through a $ git checkout <branch> <file1> <file2>
approach.
If I had to guess I think the problem I was having may have had something to do with my intervening update to 2.5.0 through RVM, which introduced more headaches than it was worth (not Rails's fault, or even RVM's since 2.5.0 isn't yet officially supported by RVM).