My project is to refactor an old application running on Rails 5.1 to set it up on Rails 7. I will use TDD (with RSPEC) to re-implement feature after feature, and add improvements. My first step is to setup the Rails 7 environment including RSPEC, and some base gems such as Devise, Cancancan...
Gemfile
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.3.0"
gem "rails", "~> 7.1"
gem "sprockets-rails"
gem "pg", "~> 1.5.6"
gem "puma", "~> 5.0"
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "jbuilder"
# Domain specific logging
gem 'multi_logger'
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem "bootsnap", require: false
### Features
# Authentication and Authorisations
gem 'devise'
gem 'devise-jwt'
gem 'devise-security'
gem 'cancancan', '~> 3.0'
gem "bcrypt", "~> 3.1.7"
### Frontend publication
gem 'bootstrap', '~> 5.2'
gem "sassc-rails"
gem 'pagy'
group :development, :test do
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem 'annotate'
gem 'rspec-rails', '~> 6.1'
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem 'database_cleaner-active_record'
gem 'factory_bot_rails'
gem 'faker'
gem 'shoulda-matchers'
end
I did not paste a single line of code yet, I am only configuring the Rails 7 framework. For this project, I use Codesandbox who provides a Docker container, which was upgraded to Ruby 3.3.0.
Dockerfile
# Dockerfile.rails
FROM ruby:3.1.2 AS rails-toolbox
# Install rails
RUN gem install rails bundler
Installing Rails 7.1, I expected not to need an extra JavaScript runtime anymore. But when configuring RSPEC, I get the following error :
rails generate rspec:install
/usr/local/rvm/gems/default/gems/execjs-2.9.1/lib/execjs/runtimes.rb:68:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
Is there a way to workaround this issue?