
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
rails-sandbox-assets
Advanced tools
Customize your test runner while taking advantage of the Rails asset pipeline.
Add this line to your application's Gemfile:
gem 'rails-sandbox-assets'
Or if you prefer to use the master branch:
gem 'rails-sandbox-assets', git: 'git://github.com/rosenfeld/rails-sandbox-assets' # or:
gem 'rails-sandbox-assets', github: 'rosenfeld/rails-sandbox-assets' # Bundler-pre syntax
And then execute:
$ bundle
Place your tests under test/javascripts/*_test.js or spec/javascripts/*_spec.js.coffee. Use JavaScript or CoffeeScript.
You can add your test assets to test/assets/javascripts, test/assets/stylesheets,. spec/assets/javascripts and spec/assets/stylesheets.
$ rake sandbox_assets:serve
Follow the instructions in http://localhost:5000 for how to override the void bundled test-runner.
You can run a subset of your tests by specifying a path like http://localhost:5000/products.
This will only run your tests which path starts with test/javascripts/products, for example.
You can change your settings directly from config/application.rb, if you want to:
config.sandbox_assets.template = 'spec_runner/runner'
By default this setting is nil, which will follow the Rails convention and use app/views/sandbox_assets/test_runner/index.html.erb. You could actually use HAML if you prefer.
Just create such file in your application to override the default one. With the option in the example above, you should create your view in app/views/spec_runner/runner.html.erb.
Or you can create a separate initializer if you prefer:
# config/initializers/setup_sandbox_assets.rb
SandboxAssets::Engine.config.sandbox_assets.tap do |c|
c.template = 'test_runner/index' # set the runner template path
c.disable_template_param = true
end
Default settings:
c.port = 5000
# By default, sandbox_assets will look for your tests in test/javascripts and spec/javascripts
c.tests_roots = %w(test/javascripts spec/javascripts)
# Add to Rails assets path. Besides your tests/spec, any assets in those paths will be served
# by the asset pipeline:
c.assets_paths = c.tests_roots +
%w(test/assets/javascripts test/assets/stylesheets
spec/assets/javascripts spec/assets/stylesheets)
# Pattern to find your tests or spec inside the tests_roots directories:
c.tests_patterns = %w(**/*_{test,spec}.{js,coffee}*)
# By default, you can override which template to use in the params, like:
# http://localhost:5000/?template=spec_runner/runner
c.disable_template_param = false
Here are some more examples on how you can use this gem:
Creating new engines depending on this one:
Creating application depending direcly on this gem:
The above application shows how to set-up a mixed environment with specs written both in Jasmine and Mocha/Chai, using different spec runners, of course. Also it demonstrates how to set up your custom spec runner.
In this case it is a simple HTML pointing to the paths for each supported spec runner, but you can use the @tests and @stylesheets instance variables to include them anywhere in your custom template file.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that rails-sandbox-assets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.