実現したいことと起きていること
Rspecでテストを書いています。
Rspecを実行したところエラーが出てきました。font-awesome関係のエラーだということはわかるのですが、どこが原因なのかわかりません。
rails sで画面を表示すると正常にfont-awesomeは表示されます。
エラーの表示(ターミナル)
Failures: 1) 投稿機能 一覧表示機能 ユーザーAがログインしている時 ユーザーAが作成したタスクが表示される Failure/Error: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> ActionView::Template::Error: File to import not found or unreadable: font-awesome-sprockets. [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_nested_nested_a_ユーザーaが作成したタスクが表示される_196.png # (sass):19 # ./app/views/layouts/application.html.erb:13:in `_app_views_layouts_application_html_erb___609583835091614989_68780' # ------------------ # --- Caused by: --- # Sass::SyntaxError: # File to import not found or unreadable: font-awesome-sprockets. # ./app/views/layouts/application.html.erb:13:in `_app_views_layouts_application_html_erb___609583835091614989_68780' Finished in 2.17 seconds (files took 1.88 seconds to load) 1 example, 1 failure Failed examples: rspec ./spec/system/microposts_spec.rb:20 # 投稿機能 一覧表示機能 ユーザーAがログインしている時 ユーザーAが作成したタスクが表示される
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.2' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # 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.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', 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] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] #ページネーション gem 'kaminari' # Fontawsome # gem 'font-awesome-sass', '~> 5.4.1' # 画像用 gem 'carrierwave', '~> 1.3', '>= 1.3.1' gem 'mini_magick' gem 'cloudinary' gem 'rmagick' # JQUERY導入 gem 'jquery-rails' # デバッカ gem 'pry-byebug', group: :development # 検索機能 gem 'ransack' # Google マップ gem 'geocoder' # テスト group :test do gem 'capybara', '>= 2.15' gem 'selenium-webdriver' gem 'chromedriver-helper' gem 'rspec-rails', '~> 3.7' end # FactoryBot 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 'factory_bot_rails', '~> 4.11' end
application.html.erb
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel= "stylesheet" href = "../assets/stylesheets/applocation.css" > <title>Microposts</title> <%= csrf_meta_tags %> <%= csp_meta_tag %> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script> <script defer src="https://use.fontawesome.com/releases/v5.7.2/js/all.js"></script> <script src="https://kit.fontawesome.com/383cff6671.js" crossorigin="anonymous"></script> </head> <body> <%= render 'layouts/navbar' %> <div class="container"> <%= render 'layouts/flash_messages' %> <%= yield %> </div> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> </body> </html>
その他
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/25 11:12
2020/08/25 11:23