Skip to content

Instantly share code, notes, and snippets.

@dmcaulay
Created February 24, 2012 01:41
Show Gist options
  • Save dmcaulay/1896608 to your computer and use it in GitHub Desktop.
Save dmcaulay/1896608 to your computer and use it in GitHub Desktop.
using jasmine: simple unit tests for a backbone index view
describe "Comnspace.Views.Entries.Index", ->
entries = undefined
view = undefined
$el = undefined
beforeEach ->
entries = new Comnspace.Collections.Entries()
entries.reset [
title: "Railscasts"
url: "www.railscasts.com"
,
title: "PeepCode"
url: "www.peepcode.com"
]
view = new Comnspace.Views.Entries.Index(collection: entries)
$el = $(view.render().el)
it "renders a collection of entries", ->
expect($el).toHaveText /Railscasts/
expect($el).toHaveText /PeepCode/
it "adds new entries when they're added to the collection", ->
entries.add new Comnspace.Models.Entry(
title: "thoughtbot backbone.js"
url: "https://workshops.thoughtbot.com/backbone-js-on-rails"
)
expect($el).toHaveText /thoughtbot backbone.js/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment