-
Notifications
You must be signed in to change notification settings - Fork 118
Multiple Suites
Some reasons why you might want to organize your Jasmine tests into multiple suites:
-
Some apps have pages formatted for mobile devices, using Zepto instead of Jquery. You can't load jasmine-jquery and jasmine-zetpo both in the same test environment
-
Some apps have a stripped-down test suite that end-users can run in production. The suite would run operations on a mobile device to test compatibility, checks to see that firewall ports are open, etc.
This functionality is not yet included in the gem distributed through rubygems. Basically, this won't work for you if you have only gem 'jasminerice'
in your gemfile.
In order for this to work you have to source/download gem directly from github. That is easy enough, just put the following in your Gemfile
:
gem 'jasminerice', git: 'git://github.com/bradphelan/jasminerice.git'
In routes.rb:
if %w(development test).include? Rails.env
mount Jasminerice::Engine => "/jasmine/:suite"
end
Once this was done, I created three test suites: spec.js
, browser_spec.js
and mobile_spec.js
.
Note that when using multiple suites, you can no longer use the pipeline directive #=require_tree ./.
Instead, you have to call out the test directories one by one. For example:
In mobile_spec.js:
#=require_tree ./mobile_specs
#=require_tree ./more_mobile_specs
In browser_spec.js:
#=require_tree ./browser_specs
#=require_tree ./more_browser_specs
Each suite can be referenced by a separate url:
http://localhost:3000/jasmine
http://localhost:3000/jasmine/mobile
http://localhost:3000/jasmine/browser