Skip to content
Demo app for the JasmineCoffee CodeTV screencast
Ruby CoffeeScript JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app
config
db
doc
lib
log
public
script
spec/javascripts
test
vendor
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

Description

The client-side of your application deserves some tests too. In this episode we'll look at how to use the Jasmine testing framework with CoffeeScript inside of Rails. http://www.codeschool.com/code_tv/testing-coffeescript-with-jasmine

Notes

gemfile add

group :development, :test do
  gem 'evergreen', require:'evergreen/rails'
end

run bundle to install

$ bundle

see new evergreen rake command

$ rake -T spec

Run JavaScript specs via Evergreen

$ rake spec:javascripts

Create folder for tests

$ mkdir -p spec/javascripts
$ touch spec/javascripts/demo_spec.coffee

Add this to demo_spec.coffee

describe 'A Calculator', ->
  it 'should add two numbers', ->
  result = myApp.Calculator.add(2,3)
  expect(result).toEqual(5)

Run test again

$ rake spec:javascripts

Start evergreen server

$ evergreen serve

Add to spec/javascripts/demo_spec.coffee

myApp = {}
myApp.Calculator = {
  add: (a,b) -> a + b
}

Setup guitar app and Tests

In order to setup the app locally, first run bundle to install dependencies. Then, run bundle exec rake db:create db:migrate db:test:prepare to setup you database. To run the test suite including Jasmine specs, run bundle exec rake.

Something went wrong with that request. Please try again.