Skip to content

Instantly share code, notes, and snippets.

@lxyuma
Last active December 17, 2015 19:29
Show Gist options
  • Save lxyuma/5660240 to your computer and use it in GitHub Desktop.
Save lxyuma/5660240 to your computer and use it in GitHub Desktop.
jasmine rails

introduction

jasmine rails

https://github.com/searls/jasmine-rails

railsでjasmine使うためのgem。

coffeeでも書ける。

how to install

# Gemfile
gem 'jasmine-rails'

で、bundle install

settings


# config/routes.rb

mount JasmineRails::Engine => "/specs" if defined?(JasmineRails)

# spec/javascripts/support/jasmine.yml

# path to parent directory of src_files
# relative path from Rails.root
# defaults to app/assets/javascripts
src_dir: "app/assets/javascripts"

# list of file expressions to include as source files
# relative path from scr_dir
src_files:
 - "application.{js,coffee}"

# path to parent directory of spec_files
# relative path from Rails.root
# defaults to spec/javascripts
spec_dir: spec/javascripts

# list of file expressions to include as helpers into spec runner
# relative path from spec_dir
helpers:
  - "helpers/**/*.{js,coffee}"

# list of file expressions to include as specs into spec runner
# relative path from spec_dir
spec_files:
  - "**/*[Ss]pec.{js,coffee}"

実行

RAILS_ENV=test bundle exec rake spec:javascript

微調整

Jasmine runner at '/specs' returned a 404 error: Not Found

と言われる

testdouble/jasmine-rails#36

config/routes.rbで、rootの後ろにjasmineのspecs置くと駄目らしいので注意。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment