Reputation: 1594
I've just started using RSpec for testing in my rails 5.2 app. I am deploying my app to my remote Github repository which is then tested by Travis before getting deployed to Heroku.
I had created some very simple tests which had been passing ok, but I have just added a new model distilleries
and Travis is now failing the build.
Travis appears to be complaining about not being able to find a file in my Webpack manifest. My app works perfectly locally.
When I run rspec spec/models/distillery_spec.rb
in the console I get 0 errors.
I'm brand new to testing in Rails, so please be gentle if I've made a rookie error somewhere.
Travis Log
...
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
Update
I've now deleted the entire distilleries_spec.rb
file, and I still get the same issues persisting. I just can't see where Travis is finding an issue with the manifest file.
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"
}
Also bearing in mind the error:
Webpacker can't find application.js in /home/travis/build/sfcooper/GD/public/packs-test/manifest.json
I've ensured this path is not in .gitignore
.
Upvotes: 3
Views: 2095
Reputation: 1594
Solved It
With thanks to this - https://github.com/rails/webpacker/issues/1494
What took me a little while to notice was that Travis was looking for the manifest.json in /public/packs-test/
not just /public/packs
.
After running:
RAILS_ENV=test bundle exec rails webpacker:compile
Travis now passes the build.
Upvotes: 5