- source codeProject Files in Zip (275 KB)
- mp4Full Size H.264 Video (27.7 MB)
- m4vSmaller H.264 Video (17.2 MB)
- webmFull Size VP8 Video (41.3 MB)
- ogvFull Size Theora Video (35.1 MB)
Definitely check out Evergreen (https://github.com/jnicklas/evergreen) too, it's jasmine without generated code and Coffescript support.
I've been using jasmine on a project. It's quite nice, and works pretty well. Though ive had problems when the code im testing uses jQuery. For example, i've had to switch $.each() to use a for loop instead because it couldnt recognize the window.$ function.
Thanks, Ryan! I've been really needing to add testing into my latest app that's damn near all jquery & rails 3. I appreciate you diving into this subject.
finally something i can use for testing my apps js. thank ryanb
Exactly what I was looking for after adding jquery token input to my app!
Aaron - would love to talk to you about this. Jasmine doesn't do anything to $ at all and works fine w/ jQuery. We should be able to help you out.
And there are ways to run Jasmine specs headless if that's what you want to do.
Ryan - Thanks for featuring Jasmine!
@Jan, cool, I'll check out Evergreen. Thanks for the suggestion.
@Aaron, make sure that you're loading the files properly in the jasmine.yml file. Sounds like either jQuery isn't loaded or it's conflicting with something.
@Celestino, Jasmine isn't specific to the run environment, so you can use it without a browser as well. It is the Ruby gem which uses a browser based run environment.
Here's an example of using Node.js to test a jQuery plugin.
I liked see Jasmine in practice. Spec.js is only another solution, and...
Thanks for all! ;)
I liked to see Jasmine too, but why are you use jquery selector for each action? It is very slow and ugly. Much better to cache the selector in the variables like this https://gist.github.com/916179
PS. sorry for my english
This is awesome. It's all going into my app tonight! Thanks Ryan!
worth pointing out that Diaspora has a bunch of jasmine specs if you want more examples!
Check this out: https://github.com/johnbintz/jasmine-headless-webkit
It's allows to run specs without hitting a browser. It's lightning fast.
I'm using rails 3.0.7 with Ruby 1.9.2
If you'd like a tutorial for Jasmine, here is one I made: http://evanhahn.com/tape/how_do_i_jasmine.html
Hope it helps!
A little late to the party here, but...:
Scratchin' my noggin' about the asset pipline here...
note at the bottom about the jasmine-headless-webkit allowing cli spec running and CoffeeScript interpretation.
This is awesome. Ryan, How to use Jasmine in Rails 3.1?
Again, Thanks for all! :)
I don't think there's support for Jasmine and Rails 3.1 yet if you are using the asset pipeline. I'm trying to figure out why my tests aren't working, and it seems to me it is because the jQuery files are loaded when the pages of my Rails app load.
Here's something I grabbed from the Jasmine Google Group:
Hope this helps!
Thanks for using Jasmine!
We ran into this problem and wanted to reliably use the same version of jquery we were using in our project. Our solution was to hook into the rake task: https://gist.github.com/1557071
would love to see this updated for Rails 3 with asset pipeline and coffeescript. Or what's the current recommendation for js unit testing with rails?
hello, i think there is a little error in your tutorial,
should be stored in /helpers and described in helper:
The path for the Jasmine Bundle doesn't work.
Just wanted to contribute a bit of info, and mention the Teaspoon project.
Anyway, I'm not a fan of switching testing frameworks (honestly), and ended up writing a test runner that had all the features that I wanted -- along with several others.
It utilizes the asset pipeline, uses PhantomJS to run headless (or you can use Selenium Webdriver).. It comes with support for Jasmine, Mocha, and QUnit. You can run it via a rake task, or in the browser -- and since it's running via the Rails server itself it can be used in a more integration sort of way -- testing json api's etc.
Anyway, that's my experience, and my attempt at a solid solution. Hopefully the project will help others.