secret

Loccasions 8:

  • Download Gist
App.MapProviders.Leaflet.js.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
App or= {}
 
App.MapProviders or= {}
 
App.MapProviders.Leaflet = ->
# Create new map
createMap: (elementId) ->
@map = new L.Map(elementId)
@addBaseMap()
map
addBaseMap: ()->
# TODO: This should probably be private
cloudmadeUrl = 'http://{s}.tile.cloudmade.com/640718c4d80b45d6a279dff45f8a6dae/997/256/{z}/{x}/{y}.png'
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade'
layer = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution})
@addLayerToMap(layer)
addLayerToMap: (layer) ->
@map.addLayer(layer)
setViewForMap: (options) ->
point = new L.LatLng(options.latitude, options.longitude)
@map.setView(point, options.zoomLevel)
 
 
 
eventListView.js.coffee
CoffeeScript
1 2 3 4 5 6
App or= {}
App.EventListView = Backbone.View.extend
el: "#eventsList"
//Added after first test run
,initialize: ->
@collection.bind("add", @eventAdded, @)
event_spec.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
describe("Event model", function() {
beforeEach(function() {
this.event = new App.Event({
name: "New Event",
description: "My Jasmine Event"
});
});
describe("when instantiated with attributes", function() {
it("should have a name and description", function() {
expect(this.event.get("name")).toEqual("New Event");
expect(this.event.get("description")).toEqual("My Jasmine Event");
});
});
describe("when saving", function() {
it("should not save when name is empty", function() {
var eventSpy = sinon.spy();
this.event.bind("error", eventSpy);
this.event.save({"name":""});
expect(eventSpy.calledOnce).toBeTruthy();
console.dir(eventSpy.args);
// Make sure it passes in the event
expect(eventSpy.args[0][0].cid).toEqual(this.event.cid);
expect(eventSpy.args[0][1]).toEqual("must have a valid name.");
});
});
describe("url", function() {
it("should have a value if model is not part of a collection", function() {
expect(this.event.url()).toEqual("/events");
});
it ("should reflect the collection url if part of a collection", function() {
var collection = {
url: "/loccasions"
};
this.event.collection = collection;
expect(this.event.url()).toEqual("/loccasions");
});
});
});
jasmine.yml
YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- spec/javascripts/helpers/jquery.js
- vendor/assets/javascripts/backbone/underscore-min.js
- vendor/assets/javascripts/backbone/backbone-min.js
- vendor/assets/javascripts/leaflet/leaflet.js
- app/assets/**/*.coffee
 
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
- stylesheets/**/*.css
 
# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- helpers/**/*.js
 
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
- '**/*[sS]pec.js'
 
# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:
# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir: spec/javascripts
 
# asset_pipeline_paths
#
# Paths you would like to be served by the Sprockets asset pipeline.
#
# If you include your spec_dir (eg: - spec/javascripts ) here,
# Jasmine will use the Sprockets asset pipeline to build your spec files.
#
# Default: []
#
# EXAMPLE:
# asset_pipeline_paths:
# - app/assets
# - spec/javascripts
asset_pipeline_paths:
- app/assets

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.