Closed mulderp closed 12 years ago
sorry, just see this is a duplication of https://github.com/meleyal/backbone-on-rails/issues/5
I get some first results by using Jasminerice as @quartzmo proposed in principle, it looks easy to add jasminerice and go to http://0.0.0.0:3000/jasmine for seeing the spec. Still looking in some issues with getting all dependencies loaded
in spec/javascripts/spec.js.coffee, I try
spec/javascripts/spec.js.coffee //= require jquery //= require jquery_ujs //= require underscore //= require backbone //= require Tunes //= require modernizr-1.6.min
//= require peepcode2
Hmm.. personally, I prefer this to a strategy that seems to be discussed often in blogs, namely the use of Guard to automatically compile files, evt. Guard is needed too in this setup (?) still examining
ok, regarding dependencies, the above spec.js.coffee works, (with Tunes your general application javascript)
In the spec, you need to declare the full namespace of the model-under-test, like so:
describe "Album", -> beforeEach -> @album = new Tunes.Models.Album(albumData[0])
I'm working on the same thing at the moment, also with jasminerice.
A neat trick is to just include your application
manifest in each spec,
therefore ensuring that all dependencies are met:
#= require application
describe 'Album', ->
...
I've updated the title of this issue to be more specific to Jasmine, as I think that could be a useful feature.
Marking this as closed as it would be better implemented as a standalone gem, maybe one that hooks into the generators of this one.
As I am going through the Peepcode tutorials (which discuss backbone in the context of Sinatra/JS) by using backbone-on-rails, I am discovering that support for tests or specs is missing. That could be useful for playing with models in the web-browser.
To get this running, one might propose to create a /test-backbone directory with a SpecRunner.html and the Jasmine-lib. @topfunky uses a reference in the SpecRunner.html:
Additionally, the collections, models and specs should be loaded, e.g. such as these:
Not a big issue, but eventually interesting to note.