0

UPDATE 20180209: Rails 5.1.4 の初期インストール (ミニテスト 5.11.3 を含む) に付属する新しいダミー アプリを作成し、テストは問題なく完了しました。世界で何がこの問題を引き起こしているのかを絞り込めないかどうかを確認するために、gemfile を使って実験を続けます...

アイデアやヒントがあれば教えてください!


最近、コードベースの新しい部分のテストを開始しましたが、非常に重大な問題を発見しました。何らかの理由で、すべてのテストでタイトルのエラーがスローされるようになりました。トレースを調べると、何らかの理由で引用された名前/テストのタイトルが問題を引き起こしているようです。パスしたことがわかっているテストに戻って実行すると(確かに以前の gem バージョンでは)、残念ながら、以下の User モデルで示すように、同じ結果が得られます。

RVM、Rails、Ruby を完全に削除して再インストールするなど、できることはすべて試しました。Minitest を 10.5.3 などの以前のビルドにバージョンアップしようとしましたが、まだうまくいきません。私はこれを修正するために一日のほとんどを費やしました。私は頭がいっぱいで、必死に助けが必要です! 私はすべてのgemを明示的にバージョン保護する必要があるという難しい方法を学びました;)

前もって感謝します!さらにファイル/スニペットを含める必要がある場合はお知らせください。スケジュールが許す限り、できれば 24 時間以内にご質問にお答えできるよう最善を尽くします。

返されたトレース:

エラー: UserTest#test_should_be_valid: TypeError: nil から 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 methodtest_should_be_valid' for class Minitest::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:informat_rerun_snippet' from /home/blake' /home/blake/.rvm/gems/record' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:803:inからの /.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:23:in block in record' ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:802:in each' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:802:inrecord' 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ブロック (2 レベル) in run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/ minitest.rb:320:in each' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:320:inblock 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:inwith_info_handler' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:319:in run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/railties-5.1.4/lib/rails/test_unit/line_filtering.rb:9:inrun' from /home/blake/.rvm/gems /ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:159:in block in __run' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:159:inmap' 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:inrun' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/minitest-5.11.3/lib/minitest.rb:63 : block in autorun' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:171:in/home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:171 からのフォーク内: serve' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:141:in/home/ からの実行中のブロック内blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:135:in loop' from /home/blake/.rvm/gems/ruby-2.4.1@land_app/gems/spring-2.0.2/lib/spring/application.rb:135:inrun' from /home/blake/.rvm/gems/ruby-2.4 .1@land_app/gems/spring-2.0.2/lib/spring/application/boot.rb:19:の<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:inrequire' 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 -e:1:in'

これは、以前に問題が発生したことのない、かなり標準的なユーザー モデル テストからのものです...

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

テスト/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

私は現在走っています

  • ルビー 2.4.1
  • レール 5.1.4

私の宝石リストは次のとおりです。

  * 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)
4

1 に答える 1