Мы обновляем приложение Rails с 3.2 до 5.0. Мы перешли на 4.2 и тестовый набор прошел 100%, сейчас мы находимся на 5.0.1, а тестовый набор выдает ошибку аргумента.
При запуске граблей spec: models возникает следующая ошибка:
An error occurred while loading rails_helper.
Failure/Error: require File.expand_path("../config/environment", __dir__)
ArgumentError:
wrong number of arguments (given 0, expected 2..3)
Ruby V 2.5.1
RSpec V 3.8
Запуск rake db: задача переноса в среде разработки завершена, однако ..
После запуска db: migrate в тестовой среде возникают следующие ошибки:
ArgumentError: wrong number of arguments (given 0, expected 2..3)
/home/vagrant/rtest/config/initializers/load_rtest_config.rb:5:in `test'
/home/vagrant/rtest/config/initializers/load_rtest_config.rb:5:in `<top
(required)>'
/home/vagrant/rtest/config/environment.rb:8:in `<top (required)>'
/home/vagrant/rtest/bin/rails:4:in `require'
/home/vagrant/rtest/bin/rails:4:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
envrionment.rb:
# Load the rails application
# require File.expand_path('../application', __FILE__) # RAILS 4.2
require_relative 'application'
# Initialize the rails application
# Changes for rtest upgrade
Rails.application.initialize!
load_rtest_config.rb:
require 'ostruct'
require 'yaml'
config = OpenStruct.new(YAML.load_file("#{Rails.root}/config/rtest.yml"))
::RTestConfig = OpenStruct.new(config.send(Rails.env))
::SummaryConfig = OpenStruct.new(YAML.load_file("#
{Rails.root}/config/summary.yml"))
::LDAPConfig = OpenStruct.new(YAML.load_file("#
{Rails.root}/config/ldap.yml"))
Соответствующие камни:
gem 'rails-controller-testing'
group :test do
gem 'factory_bot_rails', :require => false
gem 'capybara'
gem 'guard-rspec'
gem 'guard-spork'
gem 'shoulda'
gem 'rspec-its'
gem 'rubocop-rspec'
gem 'rspec-rails'
gem 'rails-controller-testing'
#Rails 5 Upgrade
# gem 'shoulda-matchers'
end
rails_helper.rb
require 'rubygems'
# require 'spork'
require 'database_cleaner'
require 'rspec/its'
# ActiveRecord::Migration.check_pending!
# ActiveRecord::Migration.maintain_test_schema!
require 'spec_helper'
require File.expand_path("../config/environment", __dir__)
require 'rspec/rails'
require 'rspec/autorun'
require 'factory_bot_rails'
require 'capybara/rspec'
require 'authlogic/test_case'
ENV["RAILS_ENV"] ||= 'test'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.expose_current_running_example_as :example
config.use_transactional_fixtures = true
config.include FactoryBot::Syntax::Methods
config.include Shoulda::Matchers::ActiveModel, type: :model
config.include Shoulda::Matchers::ActiveRecord, type: :model
config.include Devise::Test::ControllerHelpers, :type => :controller
config.include LoginMacros, :type => :controller
config.include LoginMacrosRequest, :type => :request
config.after(:each) { Warden.test_reset! }
end
puts "Reloading controllers and models"
Dir["#{Rails.root}/app/controllers//*.rb"].each do |controller|
load controller
end
Dir["#{Rails.root}/app/models//*.rb"].each do |model|
load model
end
puts "Done"
FactoryBot.reload
Dir[Rails.root.join("spec/support/**/*.rb")].each do |f|
require f
end
edit: Извиняюсь, если вопрос не ясен, это мой первый вопрос, спасибо.