Customize your test runner while taking advantage of the Rails asset pipeline.
Add this line to your application's Gemfile:
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:
$ 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.
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 ::.config.sandbox_assets.tap do |c| c.template = 'test_runner/index' # set the runner template path c.disable_template_param = true end
Gems using Rails Sandbox Assets
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.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request