gpt4 book ai didi

ruby-on-rails - Travis 因 webpacker 问题 (Rspec) rails 5.2 而失败

转载 作者:行者123 更新时间:2023-12-04 02:52:47 24 4
gpt4 key购买 nike

我刚刚开始在我的 Rails 5.2 应用程序中使用 RSpec 进行测试。我正在将我的应用程序部署到我的远程 Github 存储库,然后在部署到 Heroku 之前由 Travis 对其进行测试。

我创建了一些非常简单的测试,这些测试一直通过,但我刚刚添加了一个新模型 distilleries,Travis 现在构建失败。

Travis 似乎在提示无法在我的 Webpack list 中找到文件。我的应用程序在本地完美运行。

当我在控制台中运行 rspec spec/models/distillery_spec.rb 时,我得到 0 个错误。

我是 Rails 测试的新手,所以如果我在某个地方犯了菜鸟错误,请多多包涵。

Travis 日志

...    
Failures:

1) Distilleries GET /distilleries works! (now write some real specs)
Failure/Error: <%= javascript_pack_tag 'application' %>

ActionView::Template::Error:
Webpacker can't find application.js in /home/travis/build/sfcooper/GD/public/packs-test/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
# ./app/views/layouts/application.html.erb:17:in `_app_views_layouts_application_html_erb___92036987216695529_24174260'
# ./spec/requests/distilleries_spec.rb:6:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# Webpacker::Manifest::MissingEntryError:
# Webpacker can't find application.js in /home/travis/build/sfcooper/GD/public/packs-test/manifest.json. Possible causes:
# 1. You want to set webpacker.yml value of compile to true for your environment
# unless you are using the `webpack -w` or the webpack-dev-server.
# 2. webpack has not yet re-run to reflect updates.
# 3. You have misconfigured Webpacker's config/webpacker.yml file.
# 4. Your webpack configuration is not creating a manifest.
# Your manifest contains:
# {
# }
# ./app/views/layouts/application.html.erb:17:in `_app_views_layouts_application_html_erb___92036987216695529_24174260'
Finished in 1.04 seconds (files took 2.32 seconds to load)
9 examples, 1 failure
Failed examples:
rspec ./spec/requests/distilleries_spec.rb:5 # Distilleries GET /distilleries works! (now write some real specs)

...

distillery_spec.rb

require 'rails_helper'

RSpec.describe Distillery, type: :model do
context 'validations' do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:snippet) }
end
context 'associations' do
it { should have_many(:gins) }
end
end

factories/distilleries.rb

FactoryGirl.define do
factory :distillery do

end
end

travis.yml

language: ruby
rvm:
- 2.4.0
before_script:
- bundle exec rake db:create --all
- bundle exec rake db:migrate
script:
- bundle exec rake ci:tests
services:
- postgresql
notifications:
email: false
deploy:
provider: heroku
api_key:
secure: ******
app:
master: thegd
on:
repo: sfcooper/GD
run:
- rails db:migrate

更新

我现在删除了整个 distilleries_spec.rb 文件,但我仍然遇到同样的问题。我只是看不出 Travis 在哪里发现 list 文件的问题。

public/packs/manifest.json {

"application.css": "/packs/application-25e3a7ac7f3afb6db64c457a591257f8.css",
"application.css.map": "/packs/application-25e3a7ac7f3afb6db64c457a591257f8.css.map",
"application.js": "/packs/application-135f3e8e200516e9e3cd.js",
"application.js.map": "/packs/application-135f3e8e200516e9e3cd.js.map",
"botanicalselector.js": "/packs/botanicalselector-c06eacfbeb4820a881b6.js",
"botanicalselector.js.map": "/packs/botanicalselector-c06eacfbeb4820a881b6.js.map",
"countryselector.js": "/packs/countryselector-9f4de505e0d165ed7721.js",
"countryselector.js.map": "/packs/countryselector-9f4de505e0d165ed7721.js.map"
}

同时牢记错误:

Webpacker can't find application.js in /home/travis/build/sfcooper/GD/public/packs-test/manifest.json

我已确保此路径不在 .gitignore 中。

最佳答案

解决了

感谢这个 - https://github.com/rails/webpacker/issues/1494

我花了一点时间才注意到,Travis 正在 /public/packs-test/ 中寻找 manifest.json,而不仅仅是 /public/packs

运行后:

RAILS_ENV=test bundle exec rails webpacker:compile

Travis 现在通过了构建。

关于ruby-on-rails - Travis 因 webpacker 问题 (Rspec) rails 5.2 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54272210/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com