Ошибка / Ошибка при запуске rspec, неявное преобразование String Into Hash - PullRequest
0 голосов
/ 13 января 2019

Я только что установил новое приложение rails, и само приложение работает нормально, но при запуске rspec возвращается ошибка ниже. Я не могу понять, что здесь не так. Кто-нибудь может помочь? Все тесты были загружены из базового приложения композитора и не были изменены.

$ rspec

An error occurred while loading rails_helper.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)

TypeError:
  no implicit conversion of String into Hash
# ./config/application.rb:10:in `<module:Smarthost>'
# ./config/application.rb:9:in `<top (required)>'
# ./config/environment.rb:2:in `require_relative'
# ./config/environment.rb:2:in `<top (required)>'
# ./spec/rails_helper.rb:4:in `<top (required)>'

Application.rb: (строка 10 следующая: «класс Application

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Smarthost
  class Application < Rails::Application

    config.generators do |g|
      g.test_framework :rspec,
        fixtures: true,
        view_specs: false,
        helper_specs: false,
        routing_specs: false,
        controller_specs: false,
        request_specs: false
      g.fixture_replacement :factory_bot, dir: "spec/factories"
    end

    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.2

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
  end
end

Выполнение полной трассировки с помощью rake --trace возвращает следующее, что указывает на ошибку в Figaro. Я не касался ни одного из этих файлов, хотя. Есть мысли о том, в чем может быть проблема?

rake aborted!
TypeError: no implicit conversion of String into Hash
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro/application.rb:32:in `merge'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro/application.rb:32:in `configuration'/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro/application.rb:42:in `each'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro/application.rb:36:in `load'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro.rb:23:in `load'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/figaro-1.1.1/lib/figaro/rails/railtie.rb:5:in `block in <class:Railtie>'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:95:in `inherited'
/mnt/c/Users/chave/Documents/apps/smarthost/config/application.rb:10:in `<module:Smarthost>'
/mnt/c/Users/chave/Documents/apps/smarthost/config/application.rb:9:in `<top (required)>'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/mnt/c/Users/chave/Documents/apps/smarthost/Rakefile:5:in `<top (required)>'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/home/achaves/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/home/achaves/.rbenv/versions/2.5.3/bin/rake:23:in `load'
/home/achaves/.rbenv/versions/2.5.3/bin/rake:23:in `<main>'

1 Ответ

0 голосов
/ 13 января 2019

Я решил исправить это, переустановив figaro и скопировав старое содержимое application.yml во вновь созданный файл после запуска:

bundle exec figaro install
...