Sha256: 8d8a9e76ff644f6cbb2ceb41e477366b49eeb62e3c2ec796a9d92fa0b123343b

Contents?: true

Size: 871 Bytes

Versions: 11

Compression:

Stored size: 871 Bytes

Contents

# =require fake_ajax_server

createProducts = -> [
  {id: 1, name: 'One'}
  {id: 2, name: 'Two'}
]

extendClass 'specs.<%= class_name %>Spec', ->
  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}"

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
oojs-0.3.0 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.2.3 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.2.2 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.2.1 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.2.0 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.1.1 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.1.0 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.0.4 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.0.3 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.0.2 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb
oojs-0.0.1 lib/generators/oojs/spec/templates/fake_ajax_server.js.coffee.erb