Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicinabox/jasmine-rails-boilerplate
https://github.com/nicinabox/jasmine-rails-boilerplate
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nicinabox/jasmine-rails-boilerplate
- Owner: nicinabox
- Created: 2012-03-29T14:23:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-03-30T00:31:14.000Z (over 12 years ago)
- Last Synced: 2023-03-11T01:38:25.324Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 113 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Using Jasmine with the asset pipeline #
Jasmine does not currently support the asset pipeline, but there's a lovely gem called [jasmine-rails](https://github.com/searls/jasmine-rails) that will give us this support. Used in conjunction with [jasmine-headless-webkit](http://johnbintz.github.com/jasmine-headless-webkit/), you can run your specs in Terminal, similar to `rspec` rather than in the browser (and it's fast!).
## Add to your Gemfile
First, lets add the necessary dependencies.
group :development, :test do
gem 'jasmine-rails'
gem 'jasmine-headless-webkit'
end## Initialize jasmine
jasmine init
Then remove the extra files it generates.
rm -rf spec/javascripts/helpers spec/javascripts/PlayerSpec.js
rm -rf public/javascripts/Player.js public/javascripts/Song.js## Update jasmine.yml
Because we're using the asset pipeline, we need to tell jasmine where our assets are.
src_dir: app/assets/javascripts
asset_paths:
- vendor/assets/javascriptssrc_files:
- "vendor/**/*.{js,coffee}"
- "lib/**/*.{js,coffee}"
- "app/**/*.{js,coffee}"spec_files:
- "**/*[Ss]pec.{js,coffee}"helpers:
- "helpers/**/*.{js,coffee}"spec_dir: spec/javascripts
## Make a sanity test
At this point, jasmine should be working. Lets make a sanity test to check. Create a file in `spec/javascripts` called `sanity_spec.coffee`.
describe "Sanity Check", ->
it "demonstrates a successful test", ->
expect(1).toEqual 1Then run `jasmine-headless-webkit -c` (that `-c` is for color).
Running Jasmine specs...
.
PASS: 1 test, 0 failures, 0.007 secs.Profit!
## A note on OSX Lion ##
If you're using Lion, you'll likely get a message like...
Can't load, the file may be broken.
...in which case you'll want to load the gem directly from Github.
gem 'jasmine-headless-webkit', :git => https://github.com/johnbintz/jasmine-headless-webkit.git
In some cases you may even need to install from source. Don't worry, it's not hard!
git clone https://github.com/johnbintz/jasmine-headless-webkit.git
cd jasmine-headless-webkit
gem build jasmine-headless-webkit.gemspec
gem install jasmine-headless-webkit.gem