testing - How do I test multiple angularjs apps with the rails jasmine gem? -


i have rails 3 app 2 different angular apps (which share code) include in different areas of rails app ie,

app1.js

//= require vendor/angular.min //= require vendor/angular-resource  //= require app/app1  //= require services/someservice  //= require controllers/app2specificcontroller 

app/app1.js

(function() {   "use strict";    var app = app || {};   app.controllers = angular.module('app.controllers', []);   app.services = angular.module('app.services', ["ngresource"]);    // make app global   window.app = app;    angular.module('app', [       "app.controllers",       "app.directives",       "app.services"     ])     .config(['$routeprovider', function($routeprovider) {       $routeprovider.         // routes     }]); })(); 

app2.js

//= require vendor/angular.min //= require vendor/angular-resource  //= require app/app2  //= require services/someservice  //= require controllers/app2specificcontroller 

app/app2.js

(function() {   "use strict";    var app = app || {};   app.controllers = angular.module('app.controllers', []);   app.services = angular.module('app.services', ["ngresource"]);    // make app global   window.app = app;    angular.module('app', [       "app.controllers",       "app.directives",       "app.services"     ])     // no routes required })(); 

i've set jasmine-gem, test 1 of apps, can't figure out how expand both apps.

some options can think of:

  • fork jasmine-gem able run multiple jasmine.yml config files, , run tests 1 after - feels overkill.
  • combine apps 1 angular app, quite difficult do, work differently (one more angular-ly, , 1 more rails-y).

are there other options?

you can rename app1 , app2 modules still assign them same global var app.

window.app = angular.module('app1', [ ... ]); 

and

window.app = angular.module('app2', [ ... ]); 

by renaming each module, can load each app separately in jasmine tests.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -