`bundle exe c rails new` внутри задачи rspe c / rake - PullRequest
0 голосов
/ 07 марта 2020

Я тестирую драгоценный камень, который добавляет несколько генераторов к рельсам.

Для того, чтобы протестировать, у меня есть задача rake, которая готовит новое приложение к рельсам, устанавливает мой драгоценный камень и запускает генератор.

Проблема в том, что в грабли (spec:prepare) я не могу заставить это работать: bundle exec rails new test_app...

Если я остановлюсь bundle exec все в порядке.

Ближайший I добиться успеха можно так:

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

namespace :spec do
  task :prepare do
    Dir.chdir('spec') do
      sh('rm -rf test_app')
      Bundler.with_clean_env do
        sh('rails -v')
        # works: sh('rails new test_app -T') # works !
        sh('bundle exec rails new test_app -T')  # fails ...
      end
      # ... more stuff but doesn't get this far unless I don't use bundler above
      end
    end
  end
end

task :default => :spec

С учетом вышесказанного у меня есть следующее Gemfile в каталоге spec:

gem 'rails', '~> 6.0'

Это успешно создает структуру приложения rails , затем запускает пакетную установку, но затем я получаю эту ошибку:

Bundle complete! 14 Gemfile dependencies, 66 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted
       rails  webpacker:install
Traceback (most recent call last):
    3: from bin/rails:8:in `<main>'
    2: from bin/rails:8:in `require_relative'
    1: from .../ruby/rails-hyperstack/spec/test_app/config/boot.rb:4:in `<top (required)>'
.../ruby/rails-hyperstack/spec/test_app/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
rake aborted!
Command failed with status (1): [bundle exec rails new test_app -T...]
...