-
-
Save matthijsgroen/3102900 to your computer and use it in GitHub Desktop.
Rails Backbone template
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
gem_group :assets do | |
gem 'haml_coffee_assets' | |
gem 'execjs' | |
gem 'i18n-js' | |
end | |
gem_group :assets, :development do | |
gem 'rails-backbone' | |
end | |
gem 'haml-rails' | |
gem_group :test, :development do | |
gem 'konacha' | |
gem 'capybara-webkit' | |
gem 'rspec-rails' | |
end | |
app_name = ask("name of the application?") | |
run 'bundle' | |
generate 'backbone:install' | |
generate 'rspec:install' | |
file 'app/assets/javascripts/backbone/models/application.js.coffee' do | |
<<-CODE.gsub(/^ {4}/, '') | |
class #{app_name}.Models.Application | |
initialize: -> | |
world = {} | |
@trigger 'application:setup', world | |
@trigger 'application:initialize', world | |
Backbone.history?.start() unless Backbone.History.started | |
_.extend #{app_name}.Models.Application.prototype, Backbone.Events | |
#{app_name}.app = new #{app_name}.Models.Application | |
CODE | |
end | |
file 'spec/javascripts/models/application_spec.js.coffee' do | |
<<-CODE.gsub(/^ {4}/, '') | |
#= require spec_helper | |
#= require generic | |
describe "Application", -> | |
model = null | |
beforeEach -> model = new Platform4.Models.Application | |
describe "#initialize", -> | |
callbacks = null | |
beforeEach -> | |
callbacks = [sinon.spy(), sinon.spy()] | |
callbacks[0].displayName = "First init" | |
callbacks[1].displayName = "Second init" | |
it "calls all setup initializers", -> | |
model.should.trigger('application:setup') | |
it "calls all initialize initializers", -> | |
model.should.trigger('application:initialize') | |
CODE | |
end | |
initializer 'konacha.rb' do | |
<<-INITIALIZER.gsub(/^ {4}/, '') | |
if defined?(Konacha) | |
Konacha.configure do |config| | |
config.spec_dir = 'spec/javascripts' | |
config.driver = :webkit | |
end | |
end | |
INITIALIZER | |
end | |
file 'spec/javascripts/spec_helper.js.coffee' do | |
<<-CODE.gsub(/^ {4}/, '') | |
#= require application | |
#= require ./lib/backbone-chai | |
#= require ./lib/sinon-chai | |
#= require ./lib/sinon-1.4.2 | |
chai.use sinonChai | |
chai.use backboneChai | |
CODE | |
end | |
run 'wget https://raw.github.com/matthijsgroen/backbone-chai/master/lib/backbone-chai.js.coffee -P spec/javascripts/lib/' | |
run 'wget https://raw.github.com/matthijsgroen/backbone-chai/master/lib/extend-chai.js.coffee -P spec/javascripts/lib/' | |
run 'wget https://raw.github.com/matthijsgroen/backbone-chai/master/lib/sinon-chai.js.coffee -P spec/javascripts/lib/' | |
run 'wget http://sinonjs.org/releases/sinon-1.4.2.js -P spec/javascripts/lib/' | |
rake 'db:create:all' | |
rake 'i18n:js:setup' | |
remove_file 'public/index.html' | |
git :init | |
git :add => "." | |
git :commit => "-a -m 'Initial commit'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment