Skip to content

Instantly share code, notes, and snippets.

@linjunpop
Last active August 14, 2021 05:42
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save linjunpop/4367228 to your computer and use it in GitHub Desktop.
Save linjunpop/4367228 to your computer and use it in GitHub Desktop.
Capybara, Rspec, Rails assets pipeline
# environments/capybara.rb
Dummy::Application.configure do
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.assets.compress = true
config.assets.compile = false
config.assets.precompile += %w(email.css)
config.assets.digest = true
config.assets.prefix = "/capybara_test_assets"
end
# spec/request_helper.rb
ENV["RAILS_ENV"] = 'capybara'
RSpec.configure do |config|
config.before(:suite) do
%x[bundle exec rake assets:precompile]
end
end
@apauly
Copy link

apauly commented Dec 2, 2016

You can save some seconds if you avoid to boot the rails environment twice:

config.before(:suite) do
  Rails.application.load_tasks
  Rake::Task["assets:precompile"].invoke
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment