私はthisのチュートリアルに従っていますが、今までは大きな問題はありませんでしたが、突然テスト(Or Guard)を実行しようとしたときに突然失敗しました。すべての故障のためにRailsのテストはBootstrap-Railsで失敗しました4
、それは私が解読できる
ERROR["test_should_get_home", StaticPagesControllerTest, 1.3221390806138515]
test_should_get_home#StaticPagesControllerTest (1.32s)
ActionView::Template::Error: ActionView::Template::Error: File to import not found or unreadable: bootstrap-sprockets.
Load paths:
/home/ubuntu/workspace/sample_app/app/assets/config
/home/ubuntu/workspace/sample_app/app/assets/images
/home/ubuntu/workspace/sample_app/app/assets/javascripts
/home/ubuntu/workspace/sample_app/app/assets/stylesheets
/home/ubuntu/workspace/sample_app/vendor/assets/javascripts
/home/ubuntu/workspace/sample_app/vendor/assets/stylesheets
/usr/local/rvm/gems/ruby-2.3.0/gems/jquery-rails-4.1.1/vendor/assets/javascripts
/usr/local/rvm/gems/ruby-2.3.0/gems/coffee-rails-4.2.1/lib/assets/javascripts
/usr/local/rvm/gems/ruby-2.3.0/gems/actioncable-5.0.0.1/lib/assets/compiled
/usr/local/rvm/gems/ruby-2.3.0/gems/turbolinks-source-5.0.0/lib/assets/javascripts
app/assets/stylesheets/custom.scss:1
app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb___4391039624438268474_46194740'
test/controllers/static_pages_controller_test.rb:15:in `block in <class:StaticPagesControllerTest>'
警告 - ブートストラップを使用しようとすることはできませんですが。
多分私はTDDについてよく知っているわけではないかもしれませんが、なぜそれがタイトルをレンダリングするためにブートストラップを取得しようとしているのですか?それは部分的なものなのでしょうか?
この同じ問題で他にも数多くの投稿が見つかりましたが、大多数が死亡したか、またはRails 3からのもので、サーバーを再起動するだけで解決しました。
私はそれを解決できましたが、私のGemfileを修正しました。私はgem 'bootstrap-sass', '3.3.6'
を上から移動して
group :assets, :test, :development do
gem 'bootstrap-sass', '3.3.6'
end
ブロックに移動しました。私はブロックの外側の宝石は永久に積み込まれていると思ったが、そうではない?私は将来このスタイルに固執すべきでしょうか?
(表記のために全体gemfileを配置)
source 'https://rubygems.org'
gem 'rails', '5.0.0.1'
gem 'puma', '3.4.0'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.2.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.4.1'
group :assets, :test, :development do
gem 'bootstrap-sass', '3.3.6'
end
group :development, :test do
gem 'sqlite3', '1.3.11'
gem 'byebug', '9.0.0', platform: :mri
end
group :development do
gem 'web-console', '3.1.1'
gem 'listen', '3.0.8'
gem 'spring', '1.7.2'
gem 'spring-watcher-listen', '2.0.0'
end
group :test do
gem 'rails-controller-testing', '0.1.1'
gem 'minitest-reporters', '1.1.9'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
group :production do
gem 'pg', '0.18.4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
EDIT:要求されたように両方のテストに追加します。
アプリケーションテスト
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
include ApplicationHelper
# Add more helper methods to be used by all tests here...
end
特定のテスト
私はでmaster
に私filling-in-layout
ブランチをマージした後、同じActionView::Template::Error: File to import not found or unreadable: bootstrap-sprockets.
症状を観察し 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
get contact_path
assert_select "title", full_title("Contact")
get signup_path
assert_select "title", full_title("Sign-Up")
end
end
You'rの問題として、それを止めます'app/assets/stylesheets/custom.scss:1'から始まり、importディレクティブがありますか?失敗したテストはどのように見えますか? – slowjack2k
@ slowjack2k正確なテスト自体を追加しました。 – DNorthrup