Created
August 19, 2013 15:53
-
-
Save richsoni/6270670 to your computer and use it in GitHub Desktop.
Testing a backbone app with jasminerice in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localhost:[port]/jasmine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> cd ~/workspace/pos.rb | |
> bundle exec guard #will run the tests when code is updated | |
> ^D #will quit guard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On Commit the gem overcommit will run, and you need to correct your issues