Jasmine ruby gem
The Jasmine Ruby Gem is a package of helper code for developing Jasmine projects for Ruby-based web projects (Rails, Sinatra, etc.) or for JavaScript projects where Ruby is a welcome partner. It serves up a project's Jasmine suite in a browser so you can focus on your code instead of manually editing script tags in the Jasmine runner HTML file.
This gem contains:
You can get all of this by:
gem install jasmineor by adding Jasmine to your
Gemfile.
group :development, :test do gem 'jasmine' end
To initialize a rails project for Jasmine
rails generate jasmine:installrails generate jasmine:examples
For any other project (Sinatra, Merb, or something we don't yet know about) use
jasmine initjasmine examples
Start the Jasmine server:
rake jasmine
Point your browser to
localhost:8888. The suite will run every time this page is re-loaded.
For Continuous Integration environments, add this task to the project build steps:
rake jasmine:ci
This uses PhantomJS to load and run the Jasmine suite.
Please note that PhantomJS will be auto-installed by the phantomjs-gem at the first
rake jasmine:cirun. If you have a matching PhantomJS version somewhere on your path, it won't install. You can disable automatic installation altogether (and use the PhantomJS on your path) via the config helper in your jasmine_helper.rb:
Jasmine.configure do |config| config.prevent_phantom_js_auto_install = true end
Customize
spec/javascripts/support/jasmine.ymlto enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include. You may use dir glob strings.
Alternatively, you may specify the path to your
jasmine.ymlby setting an environment variable:
rake jasmine:ci JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.yml
In addition, the
spec_helperkey in your jasmine.yml specifies the path to a ruby file that can do programmatic configuration. After running
jasmine initor
rails generate jasmine:installit will point to
spec/javascripts/support/jasmine_helper.rbwhich you can modify to fit your needs.
The ports that
rake jasmine(or
rake jasmine:server) and
rake jasmine:cirun on are configured independently, so they can both run at the same time.
To change the port that
rake jasmineuses:
In your jasmine_helper.rb:
Jasmine.configure do |config| config.server_port = 5555 end
By default
rake jasmine:ciwill attempt to find a random open port, to set the port that
rake jasmine:ciuses:
In your jasmine_helper.rb:
Jasmine.configure do |config| config.ci_port = 1234 end
By default
rake jasmine:ciwill print results in color, to change this configuration:
In your jasmine_helper.rb:
Jasmine.configure do |config| config.color = false end
chrome_remoteas a dependency
config.chrome_binary- to customize which binary to execute
config.chrome_cli_options- if you know what you're doing you can customize the CLI
config.chrome_startup_timeout- change the amount of time to wait for chrome to start
Add this to your
.travis.yml
addons: chrome: stable
Documentation: jasmine.github.io Jasmine Mailing list: [email protected] Twitter: @jasminebdd
Please file issues here at Github
Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.