Repository is archived
Low commit activity in last 3 years
No release in over a year
Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax. Jasmine for Ruby is deprecated. We recommend using the jasmine-browser-runner NPM package instead. It supports all the same scenarios as this gem plus Webpacker. See https://jasmine.github.io/setup/browser.html for setup instructions, and https://github.com/jasmine/jasmine-gem/blob/main/release_notes/3.9.0.md for other options.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 6, < 7.0.0
>= 2.5.0

Runtime

>= 2.1.4
>= 0
= 3.99.0
 Project Readme

The Jasmine Gem

FOSSA Status Gem Version

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.

Webpacker support is provided via the jasmine-browser-runner NPM package, not this gem. jasmine-browser-runner can also be used to test JavaScript in Rails applications that use the Asset Pipeline.

Discontinued

The jasmine and jasmine-core Ruby gems are discontinued. There will be no further releases. We recommend that most users migrate to the jasmine-browser-runner npm package, which is the direct replacement for the jasmine gem.

If jasmine-browser-runner doesn't meet your needs, one of these might:

  • The jasmine npm package to run specs in Node.js.
  • The standalone distribution to run specs in browsers with no additional tools.
  • The jasmine-core npm package if all you need is the Jasmine assets. This is the direct equivalent of the jasmine-core Ruby gem.

Contents

This gem contains:

  • A small server that builds and executes a Jasmine suite for a project
  • A script that sets up a project to use the Jasmine gem's server
  • Generators for Ruby on Rails projects (Rails 4 and 5)

You can get all of this by: gem install jasmine or by adding Jasmine to your Gemfile.

group :development, :test do
  gem 'jasmine'
end

Init A Project

To initialize a rails project for Jasmine

rails generate jasmine:install

rails generate jasmine:examples

For any other project (Sinatra, Merb, or something we don't yet know about) use

jasmine init

jasmine examples

Usage

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:ci run. 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

Configuration

Customize spec/javascripts/support/jasmine.yml to 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.yml by setting an environment variable:

rake jasmine:ci JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.yml

In addition, the spec_helper key in your jasmine.yml specifies the path to a ruby file that can do programmatic configuration. After running jasmine init or rails generate jasmine:install it will point to spec/javascripts/support/jasmine_helper.rb which you can modify to fit your needs.

Running Jasmine on a different port

The ports that rake jasmine (or rake jasmine:server) and rake jasmine:ci run on are configured independently, so they can both run at the same time.

To change the port that rake jasmine uses:

In your jasmine_helper.rb:

Jasmine.configure do |config|
  config.server_port = 5555
end

By default rake jasmine:ci will attempt to find a random open port, to set the port that rake jasmine:ci uses:

In your jasmine_helper.rb:

Jasmine.configure do |config|
  config.ci_port = 1234
end

By default rake jasmine:ci will print results in color, to change this configuration:

In your jasmine_helper.rb:

Jasmine.configure do |config|
  config.color = false
end

Using headless Chrome

  • Add chrome_remote as a dependency
  • In your jasmine_helper.rb:
Jasmine.configure do |config|
  config.runner_browser = :chromeheadless
end

Additional configuration options

  • 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

On Travis-CI

Add this to your .travis.yml

addons:
  chrome: stable

Support

Documentation: jasmine.github.io Jasmine Mailing list: jasmine-js@googlegroups.com Twitter: @jasminebdd

Please file issues here at Github

Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.

License

FOSSA Status