Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Question: Multiple Environments/Suites? #24

andyl opened this Issue · 8 comments

5 participants


From the Readme, it looks like you can establish only one jasmine rice environment:

- CoffeeScript: spec/javascripts/
- StyleSheet: spec/javascripts/spec.css
- Goto: http://localhost:3000/jasmine

I'd like to organize my tests into separate suites. Is there a way to establish multiple environments with jasminerice? Something like this in routes.rb:

mount Jasminerice::Engine => "/suite1", :spec => "spec/javascripts/"
mount Jasminerice::Engine => "/suite2", :spec => "spec/javascripts/"

Tx, Andy


Looks like the answer is 'no' - you can only establish one jasminerice environment, which loads all the test libraries from spec/javascripts/

FYI - I'd like to establish multiple environments for two reasons:

  • Some of my pages are for mobile devices, and use zepto instead of jquery. You can't load jasmine-jquery and jasmine-zetpo both in the same test environment
  • I'd like to create a stripped-down test suite that my end-users can run in production. It would run operations on a mobile device to test compatibility, checks to see that firewall ports are open, etc.

This would definitely be useful! +1


I am using Rails 3.1.3 for mobile application with Backbone and using Jamsine for BDD. However is using Zepto. Will there be support for Zepto in the pipeline? +1 for it


Actually it would be pretty easy to load multiple environments.


In the controller app/controllers/jasminerice/spec_controller.rb we could add

def get
    @specenv = params[:environment]
    render :index

and change app/views/jasminerice/spec/index.html.haml to something like

    %title Jasmine Spec Runner
    = stylesheet_link_tag "jasmine"
    = stylesheet_link_tag "spec"
    = javascript_include_tag "jasminerice"
    - if @environment
        = javascript_include_tag @environment 
    - else
        = javascript_include_tag "spec"
    = csrf_meta_tags

Please some feedback on the idea before I try to implement this or somebody is free to implement and provide feedback and a pull request.


Can we rename the question so that "environment" isn't used here since it confuses the hell out of it. It should be "suite" I believe.


+1 for renaming 'environment' to 'suite'. My first reaction upon re-reading my own question was to think about development/test/production environments - and that is an incorrect way to think about this issue. Suites is a better term.


@bradphelan thanks for your suggestions. I followed your advice and everything works. Here is my solution:

In routes.rb:

    if %w(development test).include? Rails.env
      mount Jasminerice::Engine => "/jasmine/:suite"

In app/controllers/jasminerice/spec_controller.rb:

    def index
      @specenv = params[:suite].try(:concat, "_spec") || "spec"

In app/views/jasminerice/spec/index.html.haml:

        %title Jasmine Spec Runner
        = stylesheet_link_tag "jasmine"
        = stylesheet_link_tag "spec"
        = javascript_include_tag "jasminerice"
        = javascript_include_tag @specenv
        = csrf_meta_tags

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

Then I ran each suite:


Everything worked perfectly. I'll send you a pull request with my changes.

@andyl andyl referenced this issue from a commit in andyl/jasminerice
@andyl andyl Update app/views/jasminerice/spec/index.html.haml
Changed "spec" to @specenv in order to support multiple test suites.  See Issue #24 for more info.
@andyl andyl referenced this issue from a commit in andyl/jasminerice
@andyl andyl Update app/controllers/jasminerice/spec_controller.rb
Added @specenv variable to support multiple environments.  See Issue #24 for more info.

Very excited about this update! We just may start unit testing the javascript in our Rails app! ;) Is this now in the current release, or how soon will this feature be released? (Looks like the issue is still open, so I'm not sure what that means)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.