Rails 5.2.3 -- ActionView::Template::Error: The asset is not present in the asset pipeline
Rails 5.2.3 -- ActionView::Template::Error: The asset is not present in the asset pipeline
我想不通!任何帮助将不胜感激。
总结
升级到 Rails 5.2.3 后,我的 RSpec 测试失败,但应用程序在开发中运行良好。
测试失败表示资产(图像)不在管道中。问题是图像在管道中,应用程序在开发中正确显示图像。
应用程序和 RSpec 测试在 Rails(4.2 和 5.0)
的早期版本中有效
错误
Failures:
1) Lender Pages Show Lender Pages Term Lender should show term lenders details
Failure/Error: <div class = "lenderImage"><%= image_tag("lendersbig/#{@lender.image_file_big}", :alt => @lender.name ) %></div>
ActionView::Template::Error:
The asset "lendersbig/image1.png" is not present in the asset pipeline.
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/sprockets-rails-3.2.1/lib/sprockets/rails/helper.rb:83:in `compute_asset_path'
# ./app/views/lenders/_lender_introbox.html.erb:27:in `_app_views_lenders__lender_introbox_html_erb__4253291031052859852_70308380940160'
# ./app/views/lenders/show.html.erb:33:in `_app_views_lenders_show_html_erb__24939295181715536_70308376642600'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/tempfile_reaper.rb:15:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/etag.rb:25:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/conditional_get.rb:25:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/head.rb:12:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:232:in `context'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:226:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in `call_app'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:68:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `each'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/mock_session.rb:29:in `request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:266:in `process_request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:129:in `custom_request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:58:in `get'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:65:in `process'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:43:in `process_and_follow_redirects'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:23:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/driver.rb:45:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/session.rb:276:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/requests/lenders_pages_spec.rb:31:in `block (4 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# Sprockets::Rails::Helper::AssetNotFound:
# The asset "lendersbig/image1.png" is not present in the asset pipeline.
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/sprockets-rails-3.2.1/lib/sprockets/rails/helper.rb:83:in `compute_asset_path'
查看:html.erb代码
image_tag("lendersbig/#{@lender.image_file_big}")
在浏览器中检查元素
图像运行通过管道,即添加了指纹
<img src="/assets/lendersbig/loanstore-big-eb95ff2644927e978748f13dd30bfc99.png">
文件夹结构
app
--assets
-- images
-- lendersbig
-- <files>
Gem 和 Ruby 版本
ruby "2.6.4"
gem 'rails', '5.2.3'
gem 'rspec-rails','3.8.2'
尝试过的东西and/or研究过的
我在文件名前面加了一个“/”,测试通过了,但是当应用程序 运行ning 时图像不显示。
image_tag("/lendersbig/#{@lender.image_file_big}")
我尝试使用 "skip_pipeline: true"。测试通过但应用程序失败——损坏的图像。
image_tag("lendersbig/#{@lender.image_file_big}", skip_pipeline: true)
我认为我不需要玩 "config/initializers/assets.rb",因为图像位于默认管道路径中。
我在 sprocket-rails 中找到了描述此问题的帖子。好像没修好...
附加信息
此应用可在生产环境中运行并通过 RSpec Rail 4.2.11 和 Rails 5.0.7.2
测试
RSpec 确实在 Rails 5.1.0 中针对此问题抛出弃用警告,但我在路径前添加了“/”,并错误地认为它已解决。后来,我 运行 应用程序发现图像链接已损坏,即图像路径不正确。这是从 Rails 5.0.7.2 到 5.1.0 的包更新,导致弃用警告,"The asset XYZ is not present in the asset pipeline." 在 Rails 5.2 中,测试失败,如上所述。希望这有助于激发一些想法...
Using rake 12.3.3
Using concurrent-ruby 1.1.5
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.0 (was 5.0.7.2)
Using builder 3.2.3
Using erubi 1.8.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.4
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.2.0
Using actionview 5.1.0 (was 5.0.7.2)
Using rack 2.0.7
Using rack-test 0.6.3
Using actionpack 5.1.0 (was 5.0.7.2)
Using nio4r 2.5.1
Using websocket-extensions 0.1.4
Using websocket-driver 0.6.5
Using actioncable 5.1.0 (was 5.0.7.2)
Using globalid 0.4.2
Using activejob 5.1.0 (was 5.0.7.2)
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailer 5.1.0 (was 5.0.7.2)
Using arbre 1.2.1
Using formtastic 3.1.5
Using formtastic_i18n 0.6.0
Using has_scope 0.7.2
Using method_source 0.9.2
Using thor 0.20.3
Using railties 5.1.0 (was 5.0.7.2)
Using responders 3.0.0
Using inherited_resources 1.11.0
Using jquery-rails 4.3.5
Using kaminari-core 1.1.1
Using kaminari-actionview 1.1.1
Using activemodel 5.1.0 (was 5.0.7.2)
Using arel 8.0.0 (was 7.1.4)
Using activerecord 5.1.0 (was 5.0.7.2)
Using kaminari-activerecord 1.1.1
Using kaminari 1.1.1
Using polyamorous 2.3.0
Using ransack 2.3.0
Using ffi 1.11.1
Using sassc 2.2.0
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using tilt 2.0.9
Using sassc-rails 2.1.2
Using babel-source 5.8.35
Using execjs 2.0.2
Using babel-transpiler 0.7.0
Using sprockets-es6 0.9.2
Using activeadmin 2.2.0
Using public_suffix 4.0.1
Using addressable 2.7.0
Using json 1.8.6
Using uuidtools 2.1.5
Using aws-sdk 1.38.0
Using bcrypt 3.1.13
Using bindex 0.8.1
Using bundler 1.17.3
Using byebug 11.0.1
Using regexp_parser 1.6.0
Using xpath 3.2.0
Using capybara 3.28.0
Using childprocess 2.0.0
Using climate_control 0.2.0
Using cocaine 0.5.8
Using coderay 1.1.2
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using coffee-rails 4.2.2
Using database_cleaner 1.7.0
Using orm_adapter 0.5.0
Using warden 1.2.8
Using devise 4.7.0
Using diff-lcs 1.3
Using factory_bot 5.0.2
Using factory_bot_rails 5.0.2
Using faker 1.4.3
Using figaro 1.1.1
Using jbuilder 2.9.1
Using jquery-ui-rails 5.0.5
Using launchy 2.4.2
Using libv8 3.16.14.19 (x86_64-darwin-18)
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.0
Using ruby_dep 1.5.0
Using listen 3.1.5
Using mime-types-data 3.2019.0904
Using mime-types 3.3
Using paperclip 4.1.1
Using pg 0.21.0
Using slop 3.6.0
Using pry 0.9.12.6
Using pry-nav 0.2.3
Using puma 3.12.0
Using rails 5.1.0 (was 5.0.7.2)
Using rails-controller-testing 1.0.4
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using rails_12factor 0.0.2
Using ref 2.0.0
Using rspec-support 3.8.2
Using rspec-core 3.8.2
Using rspec-expectations 3.8.4
Using rspec-mocks 3.8.1
Using rspec-rails 3.8.2
Using rubyzip 1.2.4
Using sass-rails 6.0.0
Using selenium-webdriver 3.142.4
Using shoulda-context 1.2.2
Using shoulda-matchers 2.8.0
Using shoulda 3.5.0
Using spring 2.1.0
Using spring-commands-rspec 1.0.4
Using spring-watcher-listen 2.0.1
Using therubyracer 0.12.3
Using turbolinks-source 5.2.0
Using turbolinks 5.2.0
Using uglifier 4.1.20
Using web-console 3.7.0
Using webdrivers 4.1.2
结论
所以我觉得要么我在做一些非常愚蠢的事情并且遗漏了一些东西(很可能),要么这与 Sprockets 与 Rails 的集成有关。感谢您的任何建议!
我发现了问题 -- 测试环境 管道中没有图像。
在此应用程序中,每个图像都附加到数据库中的一条记录,并且仅在显示该记录时调用(认为这可以使用 Rails5 中的 ActiveStorage 来完成)。图像存储在管道中,因此一切都在开发和生产中发挥作用。测试时调用图片时没有测试图片
为了解决这个问题,我调整了工厂
# spec/factories/lender.rb
FactoryBot.define do
factory :lender do
# other attributes
image_file_big { "test-image" }
end
end
然后将图像文件添加到 ../lendersbig/test-image.png
事后看来,这在过去应该失败了,但也许 sprockets-rails
gem 中的升级导致现在正确地失败了。
如果有更好的方法,请告诉我。谢谢!
在 Rails 6.1.3.1 中,我在生产模式(不是开发模式)中遇到了这个问题,我区分了 config/environments/development.rb 和 config/environments/production.rb 和推断将以下设置从 false 更改为 true 可以解决问题
config.assets.compile = 真
我想不通!任何帮助将不胜感激。
总结
升级到 Rails 5.2.3 后,我的 RSpec 测试失败,但应用程序在开发中运行良好。
测试失败表示资产(图像)不在管道中。问题是图像在管道中,应用程序在开发中正确显示图像。
应用程序和 RSpec 测试在 Rails(4.2 和 5.0)
的早期版本中有效错误
Failures:
1) Lender Pages Show Lender Pages Term Lender should show term lenders details
Failure/Error: <div class = "lenderImage"><%= image_tag("lendersbig/#{@lender.image_file_big}", :alt => @lender.name ) %></div>
ActionView::Template::Error:
The asset "lendersbig/image1.png" is not present in the asset pipeline.
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/sprockets-rails-3.2.1/lib/sprockets/rails/helper.rb:83:in `compute_asset_path'
# ./app/views/lenders/_lender_introbox.html.erb:27:in `_app_views_lenders__lender_introbox_html_erb__4253291031052859852_70308380940160'
# ./app/views/lenders/show.html.erb:33:in `_app_views_lenders_show_html_erb__24939295181715536_70308376642600'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/tempfile_reaper.rb:15:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/etag.rb:25:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/conditional_get.rb:25:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/head.rb:12:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:232:in `context'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:226:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in `call_app'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:68:in `block in call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `each'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `call'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/mock_session.rb:29:in `request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:266:in `process_request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:129:in `custom_request'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/rack-test-1.1.0/lib/rack/test.rb:58:in `get'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:65:in `process'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:43:in `process_and_follow_redirects'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/browser.rb:23:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/rack_test/driver.rb:45:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/session.rb:276:in `visit'
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/capybara-3.28.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/requests/lenders_pages_spec.rb:31:in `block (4 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# Sprockets::Rails::Helper::AssetNotFound:
# The asset "lendersbig/image1.png" is not present in the asset pipeline.
# /Users/cw/.rvm/gems/ruby-2.6.4@rails5.2.3/gems/sprockets-rails-3.2.1/lib/sprockets/rails/helper.rb:83:in `compute_asset_path'
查看:html.erb代码
image_tag("lendersbig/#{@lender.image_file_big}")
在浏览器中检查元素
图像运行通过管道,即添加了指纹
<img src="/assets/lendersbig/loanstore-big-eb95ff2644927e978748f13dd30bfc99.png">
文件夹结构
app
--assets
-- images
-- lendersbig
-- <files>
Gem 和 Ruby 版本
ruby "2.6.4"
gem 'rails', '5.2.3'
gem 'rspec-rails','3.8.2'
尝试过的东西and/or研究过的
我在文件名前面加了一个“/”,测试通过了,但是当应用程序 运行ning 时图像不显示。
image_tag("/lendersbig/#{@lender.image_file_big}")
我尝试使用 "skip_pipeline: true"。测试通过但应用程序失败——损坏的图像。
image_tag("lendersbig/#{@lender.image_file_big}", skip_pipeline: true)
我认为我不需要玩 "config/initializers/assets.rb",因为图像位于默认管道路径中。
我在 sprocket-rails 中找到了描述此问题的帖子。好像没修好...
附加信息
此应用可在生产环境中运行并通过 RSpec Rail 4.2.11 和 Rails 5.0.7.2
测试RSpec 确实在 Rails 5.1.0 中针对此问题抛出弃用警告,但我在路径前添加了“/”,并错误地认为它已解决。后来,我 运行 应用程序发现图像链接已损坏,即图像路径不正确。这是从 Rails 5.0.7.2 到 5.1.0 的包更新,导致弃用警告,"The asset XYZ is not present in the asset pipeline." 在 Rails 5.2 中,测试失败,如上所述。希望这有助于激发一些想法...
Using rake 12.3.3
Using concurrent-ruby 1.1.5
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.0 (was 5.0.7.2)
Using builder 3.2.3
Using erubi 1.8.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.4
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.2.0
Using actionview 5.1.0 (was 5.0.7.2)
Using rack 2.0.7
Using rack-test 0.6.3
Using actionpack 5.1.0 (was 5.0.7.2)
Using nio4r 2.5.1
Using websocket-extensions 0.1.4
Using websocket-driver 0.6.5
Using actioncable 5.1.0 (was 5.0.7.2)
Using globalid 0.4.2
Using activejob 5.1.0 (was 5.0.7.2)
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailer 5.1.0 (was 5.0.7.2)
Using arbre 1.2.1
Using formtastic 3.1.5
Using formtastic_i18n 0.6.0
Using has_scope 0.7.2
Using method_source 0.9.2
Using thor 0.20.3
Using railties 5.1.0 (was 5.0.7.2)
Using responders 3.0.0
Using inherited_resources 1.11.0
Using jquery-rails 4.3.5
Using kaminari-core 1.1.1
Using kaminari-actionview 1.1.1
Using activemodel 5.1.0 (was 5.0.7.2)
Using arel 8.0.0 (was 7.1.4)
Using activerecord 5.1.0 (was 5.0.7.2)
Using kaminari-activerecord 1.1.1
Using kaminari 1.1.1
Using polyamorous 2.3.0
Using ransack 2.3.0
Using ffi 1.11.1
Using sassc 2.2.0
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using tilt 2.0.9
Using sassc-rails 2.1.2
Using babel-source 5.8.35
Using execjs 2.0.2
Using babel-transpiler 0.7.0
Using sprockets-es6 0.9.2
Using activeadmin 2.2.0
Using public_suffix 4.0.1
Using addressable 2.7.0
Using json 1.8.6
Using uuidtools 2.1.5
Using aws-sdk 1.38.0
Using bcrypt 3.1.13
Using bindex 0.8.1
Using bundler 1.17.3
Using byebug 11.0.1
Using regexp_parser 1.6.0
Using xpath 3.2.0
Using capybara 3.28.0
Using childprocess 2.0.0
Using climate_control 0.2.0
Using cocaine 0.5.8
Using coderay 1.1.2
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using coffee-rails 4.2.2
Using database_cleaner 1.7.0
Using orm_adapter 0.5.0
Using warden 1.2.8
Using devise 4.7.0
Using diff-lcs 1.3
Using factory_bot 5.0.2
Using factory_bot_rails 5.0.2
Using faker 1.4.3
Using figaro 1.1.1
Using jbuilder 2.9.1
Using jquery-ui-rails 5.0.5
Using launchy 2.4.2
Using libv8 3.16.14.19 (x86_64-darwin-18)
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.0
Using ruby_dep 1.5.0
Using listen 3.1.5
Using mime-types-data 3.2019.0904
Using mime-types 3.3
Using paperclip 4.1.1
Using pg 0.21.0
Using slop 3.6.0
Using pry 0.9.12.6
Using pry-nav 0.2.3
Using puma 3.12.0
Using rails 5.1.0 (was 5.0.7.2)
Using rails-controller-testing 1.0.4
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using rails_12factor 0.0.2
Using ref 2.0.0
Using rspec-support 3.8.2
Using rspec-core 3.8.2
Using rspec-expectations 3.8.4
Using rspec-mocks 3.8.1
Using rspec-rails 3.8.2
Using rubyzip 1.2.4
Using sass-rails 6.0.0
Using selenium-webdriver 3.142.4
Using shoulda-context 1.2.2
Using shoulda-matchers 2.8.0
Using shoulda 3.5.0
Using spring 2.1.0
Using spring-commands-rspec 1.0.4
Using spring-watcher-listen 2.0.1
Using therubyracer 0.12.3
Using turbolinks-source 5.2.0
Using turbolinks 5.2.0
Using uglifier 4.1.20
Using web-console 3.7.0
Using webdrivers 4.1.2
结论
所以我觉得要么我在做一些非常愚蠢的事情并且遗漏了一些东西(很可能),要么这与 Sprockets 与 Rails 的集成有关。感谢您的任何建议!
我发现了问题 -- 测试环境 管道中没有图像。
在此应用程序中,每个图像都附加到数据库中的一条记录,并且仅在显示该记录时调用(认为这可以使用 Rails5 中的 ActiveStorage 来完成)。图像存储在管道中,因此一切都在开发和生产中发挥作用。测试时调用图片时没有测试图片
为了解决这个问题,我调整了工厂
# spec/factories/lender.rb
FactoryBot.define do
factory :lender do
# other attributes
image_file_big { "test-image" }
end
end
然后将图像文件添加到 ../lendersbig/test-image.png
事后看来,这在过去应该失败了,但也许 sprockets-rails
gem 中的升级导致现在正确地失败了。
如果有更好的方法,请告诉我。谢谢!
在 Rails 6.1.3.1 中,我在生产模式(不是开发模式)中遇到了这个问题,我区分了 config/environments/development.rb 和 config/environments/production.rb 和推断将以下设置从 false 更改为 true 可以解决问题
config.assets.compile = 真