Skip to content

Instantly share code, notes, and snippets.

@searls
Created February 16, 2012 16:41
Show Gist options
  • Select an option

  • Save searls/1846333 to your computer and use it in GitHub Desktop.

Select an option

Save searls/1846333 to your computer and use it in GitHub Desktop.
window.ContactUs ||=
Views: {
SerializableView: Backbone.View
}
class ContactUs.Views.InformationView extends ContactUs.Views.SerializableView
template: "performance/information-accordion"
initialize: ->
@model.bind "change:info", => @render()
serialize: ->
info: @model.toJSON().info
describe "ContactUs.Views.InformationView", ->
Given -> @model = new Backbone.Model
Given -> @subject = new ContactUs.Views.InformationView model: @model
Then -> @subject.template == "performance/information-accordion"
describe "model binding", ->
Given -> spyOn(@subject, 'render')
When -> @model.set info: "FOO!"
Then -> expect(@subject.render).toHaveBeenCalled()
describe "#serialize", ->
Given -> @model.set info: "FOO!"
When -> @result = @subject.serialize()
Then -> expect(@result).toEqual
info: "FOO!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment