Skip to content

Instantly share code, notes, and snippets.

@richsoni
Created August 19, 2013 15:53
Show Gist options
  • Save richsoni/6270670 to your computer and use it in GitHub Desktop.
Save richsoni/6270670 to your computer and use it in GitHub Desktop.
Testing a backbone app with jasminerice in rails
localhost:[port]/jasmine
#REQUIRE THE FILE YOU ARE TESTING AND ANY YOU NEED TO TEST IT WITH
#= require backbone/core
describe "App.Core", ->
describe "find_class_in (attribute, class_type)", ->
it "handles no attribute", -> expect(App.Core.find_class_in(null, "Collections")).toBeNull()
it "gracfully rejects non existent class types", -> expect(App.Core.find_class_in("phone_number", "test")).toEqual(undefined)
it "gracfully rejects non existent attribute", -> expect(App.Core.find_class_in("chubby", "Models")).toEqual(false)
it "finds the v1 phone number model", ->
model = App.Core.find_class_in("phone_number", "Models")
expect(model).toEqual App.Models.PhoneNumber
it "finds the v2 client model", ->
model = App.Core.find_class_in("client", "Models")
expect(model).toEqual App.Models.V2.Client
describe "find_collection_for (attribute)", ->
it "handles no input", -> expect(App.Core.find_collection_for()).toBeNull()
it "finds a v1 collection", ->
collection = App.Core.find_collection_for("phone_numbers")
expect(collection).toEqual App.Collections.PhoneNumbers
it "finds a v2 collection", ->
collection = App.Core.find_collection_for("addresses")
expect(collection).toEqual App.Collections.V2.Addresses
describe "find_model_for (attribute)", ->
it "handles no input", -> expect(App.Core.find_model_for()).toBeNull()
it "finds a v1 model", ->
model = App.Core.find_model_for("phone_number")
expect(model).toEqual App.Models.PhoneNumber
it "finds a v2 model", ->
model = App.Core.find_model_for("address")
expect(model).toEqual App.Models.V2.Address
> cd ~/workspace/pos.rb
> bundle exec guard #will run the tests when code is updated
> ^D #will quit guard
@richsoni
Copy link
Author

On Commit the gem overcommit will run, and you need to correct your issues

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