You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jasmine headless testing on Rails 3 asset pipeline
assets and specs can be CoffeeScript
3rd party JS can be placed to vendor/assets/javascripts or vendor gems
detects gem-vendored JS via application.js require
uses jasmine-headless-webkit to run the suite outside the browser
this requires Qt4.7 installation
Gemfile
group :development, :test do
# jasmine 1.2.0.rc2 and jhw 0.9.0.rc1
gem 'jasmine', :git => "git://github.com/pivotal/jasmine-gem.git"
gem 'jasmine-headless-webkit', :git => "git://github.com/johnbintz/jasmine-headless-webkit.git"
end
# add gems that vendor 3rd party JS
gem "jquery-rails"
app/assets/javascripts/application.js
//= require jquery
Jasmine init
$ bundle install
$ bundle exec rails g jasmine:install
spec/javascripts/support/jasmine.yml
# src_files
#
# An array of filepaths relative to asset_paths to include.
#
src_files:
- application.js # require gem vendored assets (such as jQuery) in application.js
- some.plugin.js # loaded from vendor/assets/javascripts
- app/assets/javascripts/*.js.coffee # load all custom CS files
- my.custom.js.coffee # ..or individually without path prefix
# asset_paths
#
# Paths you would like to be served by the Sprockets asset pipeline.
#
# If you include your spec_dir (eg: - spec/javascripts ) here,
# Jasmine will use the Sprockets asset pipeline to build your spec files.
#
asset_paths:
- app/assets/javascripts
- vendor/assets/javascripts
spec_dir: spec/javascripts
spec_files:
- "**/*[sS]pec.js.coffee"
# helpers
#
# Spec helpers relative to spec_dir to include.
#
helpers:
- helpers/**/*.js.coffee
spec/javascripts/example_spec.js.coffee
describe 'example', ->
it 'should have jQuery', ->
expect(jQuery).toBeDefined()