This commit is contained in:
John Bintz 2011-11-22 14:38:16 -05:00
parent 83c2ae10d9
commit b8c5e3fe88

View File

@ -1,7 +1,6 @@
Use vendored Jasmine helpers! No more copying around all those fun helpers to all your projects!
Works with Rails gems like jquery-rails too!
Works in jasmine-headless-webkit versions after October 16, 2011. Whoa!
Works in jasmine-headless-webkit versions that support Sprockets.
## What it comes with...
@ -12,45 +11,19 @@ It comes with the libraries I need:
## How to use it
Add a `vendored_helpers` section to your `jasmine.yml` file:
It's Sprockets vendored gem goodness, so at the top of your `spec_helper`:
``` yaml
vendored_helpers:
- 'sinon'
- 'jasmine-jquery'
``` coffee
#= require jasmine-jquery
#= require sinon
...make cool code...
```
### ...and Rails asset gems, too?
Sure, this just looks for files in gems in the path `vendor/assets/javascripts/#{name}.js`. So if you want
to include jQuery from `jquery-rails`:
``` yaml
vendored_helpers:
- 'jquery'
```
Easy!
## Support in stock Jasmine yet?
Not yet, want to see how well this works first.
## Why?
Two reasons:
* Part of the problem with testing modern Rails apps is the use of JavaScript bundled in gems, specifically in
the `vendor/assets/javascripts` folder of the gems that provide them. Normally, one uses a Railtie to find
out what provides those files, but you can also do it the slow way and look at all loaded gems for that
directory. Recent versions (on GitHub) of jasmine-headless-webkit support loading those vendored files.
* I got sick of copying jasmine-jquery and sinon to all my projects. Now with one gem, they're all available. It also
makes it easier to copy around your own JS stuff.
## How do I do this myself? I don't care if it's super-slow finding all the files.
Look at https://github.com/johnbintz/jasmine-headless-webkit/blob/master/lib/jasmine/files_list.rb#L162
I got sick of copying jasmine-jquery and sinon to all my projects. Now with one gem, they're all available. It also
makes it easier to copy around your own JS stuff.
## Warnings from the bleeding edge