-
What is suggested way to clean generated assets before running rspec tests? When using webpacker, was running Webpacker.clobber, like:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you're using jsbundling-rails instead of webpacker in your Rails application, you can clean the generated assets before running RSpec tests by adding a custom Rake task to your project. Here's how you can do it: Create a new file called lib/tasks/jsbundling.rake (if the lib/tasks directory doesn't exist, create it). In the jsbundling.rake file, define a new Rake task to clean the generated assets. Add the following code: namespace :jsbundling do
desc "Clean generated assets"
task :clean do
`bundle exec rails jsbundling:clean`
end
end This task executes the jsbundling:clean task provided by jsbundling-rails using the bundle exec command. In your rails_helper.rb file, modify the configuration to invoke the custom Rake task before running RSpec tests. Update the code as follows: # rails_helper.rb
RSpec.configure do |config|
config.before(:suite) do
Rake::Task['jsbundling:clean'].invoke
end
end This configuration ensures that the custom Rake task is invoked before the test suite runs, cleaning the generated assets. With these changes, the generated assets will be cleaned before running RSpec tests when using jsbundling-rails. Make sure you have the necessary dependencies and configuration in place for jsbundling-rails to work properly. If it was helpful please mark as an answer, so that others could find it easily!✌️ |
Beta Was this translation helpful? Give feedback.
If you're using jsbundling-rails instead of webpacker in your Rails application, you can clean the generated assets before running RSpec tests by adding a custom Rake task to your project. Here's how you can do it:
Create a new file called lib/tasks/jsbundling.rake (if the lib/tasks directory doesn't exist, create it).
In the jsbundling.rake file, define a new Rake task to clean the generated assets. Add the following code:
This task executes the jsbundling:clean task provided by jsbundling-rails using the bundle exec command.
In your rails_helper.rb file, modify th…