質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

1回答

1334閲覧

Rails tutorial のrails test でエラー発生

退会済みユーザー

退会済みユーザー

総合スコア0

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2021/09/10 23:05

編集2021/09/11 00:15

前提・実現したいこと

M1チップ搭載のmacbookにてRails tutorialを学習しております。

第3章 3.3.1「最初のテスト」にて
デフォルトでtest/controllers/static_pages_controller_test.rbファイルに置いてあるテストを
rails testコマンドで実行し、検証するという内容ですが、
コマンドを実行したところ以下のようなエラーが発生いたしました。

発生している問題・エラーメッセージ

/Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require': cannot load such file -- rexml/document (LoadError) from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/firefox.rb:22:in `<main>' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/webdrivers-4.6.1/lib/webdrivers/geckodriver.rb:72:in `<main>' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/webdrivers-4.6.1/lib/webdrivers.rb:4:in `<main>' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:60:in `block (2 levels) in require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:55:in `each' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:55:in `block in require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:44:in `each' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler/runtime.rb:44:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.27/lib/bundler.rb:174:in `require' from /Users/...../environment/sample_app/config/application.rb:7:in `<top (required)>' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:92:in `require' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:92:in `preload' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:155:in `serve' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:143:in `block in run' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:137:in `loop' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application.rb:137:in `run' from /Users/...../.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/application/boot.rb:19:in `<top (required)>' from <internal:/Users/...../.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/Users/...../.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from -e:1:in `<main>'

###デフォルトファイル(test/controllers/static_pages_controller_test.rb)の中身

require "test_helper" class StaticPagesControllerTest < ActionDispatch::IntegrationTest test "should get home" do get static_pages_home_url assert_response :success end test "should get help" do get static_pages_help_url assert_response :success end end

現在のgemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.4', '>= 6.1.4.1' # Use Puma as the app server gem 'puma', '~> 5.0' gem 'pg', '1.0.0' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 5.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.4', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'sqlite3', '~> 1.4' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 2.0' gem 'listen', '~> 3.3' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

試したこと

調べたところ、springを停止すればエラーが止まったとの記事を発見。

% sudo gem install spring

% spring stop

でspringを停止。

しかし変わらず。
といった現状です。
どこが誤っているかアドバイスを頂けると幸いです。

補足情報(FW/ツールのバージョンなど)

M1 macbook使用

% bundle lock --add-plataform x86_64-linux ```を実行しherokuに対応

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

`require': cannot load such file -- rexml/document (LoadError)

REXML は ruby3.0 から標準添付されなくなりました。
Gemfile に gem "rexml" を追加して $ bundle、その後テストを実行してみてください。

投稿2021/09/11 04:22

neko_daisuki

総合スコア2090

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/09/12 12:41

無事テストが実行されました、大変助かりました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問