Created
June 3, 2012 22:24
-
-
Save rosenfeld/2865221 to your computer and use it in GitHub Desktop.
oojs sample generated files
This file contains 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 fake_ajax_server | |
createProducts = -> [ | |
{id: 1, name: 'One'} | |
{id: 2, name: 'Two'} | |
] | |
extendClass 'specs.ShoppingCartSpec', -> | |
createFakeServer: -> | |
@fakeServer = new FakeAjaxServer (url, settings)-> | |
if settings then settings.url = url else settings = url | |
handled = false | |
switch settings.dataType | |
when 'json' then switch settings.type | |
when 'get' then switch settings.url | |
when '/products' then handled = true; settings.success createProducts() | |
# when 'post' then switch settings.url | |
# when ... | |
# when undefined then switch settings.type | |
# when 'get' then switch settings.url | |
# when ... | |
# when 'post' then switch settings.url | |
# when ... | |
return if handled | |
console.log arguments | |
throw "Unexpected AJAX call: #{settings.url}" |
This file contains 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 spec_helper | |
# =require_tree ./shopping_cart | |
$ -> new specs.ShoppingCartSpec | |
extendClass 'specs.ShoppingCartSpec', (spec)-> | |
initialize: -> | |
@createFakeServer() | |
@extend this, new specs.jasmine.AjaxHelpers(@fakeServer) | |
@describe() | |
describe: -> | |
describe 'ShoppingCart', => | |
@beforeAll() | |
beforeEach @beforeEach | |
@runSpecs() | |
runs @afterAll | |
beforeAll: -> | |
@fakeServer.start() | |
afterAll: => | |
@fakeServer.stop() | |
beforeEach: => | |
@fakeServer.ignoreAllRequests() | |
runSpecs: => | |
it 'passes', => | |
expect(@fakeServer).not.toBeUndefined() |
This file contains 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 application | |
# =require modules | |
# =require jquery | |
# =require jasmine_helpers | |
# #require jquery.ba-bbq # uncomment for enabling $.deparam() | |
# | |
# Put your common spec code here. | |
# Then put "# =require spec_helper" in your specs headers. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment