From db584858cf8fe360693eb37132884548201e703a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 15 Apr 2011 16:02:22 -0400 Subject: [PATCH] uh, maybe now --- bin/backbone-generator | 4 ++-- spec/bin/backbone-generator_spec.rb | 8 ++++---- templates/collection.js.erb | 2 +- templates/collection_spec.js.erb | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/backbone-generator b/bin/backbone-generator index 9480f75..7584916 100755 --- a/bin/backbone-generator +++ b/bin/backbone-generator @@ -39,8 +39,8 @@ class BackboneGenerator < Thor desc 'collection Namespaced::Name', "Create a collection" def collection(name) @name = name - template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s_collection.js") - template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_collection_spec.js") + template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s.js") + template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_spec.js") end desc 'collection-view Namespaced::Name', "Create a collection view" diff --git a/spec/bin/backbone-generator_spec.rb b/spec/bin/backbone-generator_spec.rb index 303cc0c..c3130e3 100644 --- a/spec/bin/backbone-generator_spec.rb +++ b/spec/bin/backbone-generator_spec.rb @@ -55,12 +55,12 @@ describe 'backbone-generator' do it "should generate the collection files" do system %{bin/backbone-generator collection Section::Model} - File.file?(collection = 'public/javascripts/collections/section/models_collection.js').should be_true - File.file?(spec = 'spec/javascripts/collections/section/models_collection_spec.js').should be_true + File.file?(collection = 'public/javascripts/collections/section/models.js').should be_true + File.file?(spec = 'spec/javascripts/collections/section/models_spec.js').should be_true - File.read(collection).should match(/SectionModelsCollection/) + File.read(collection).should match(/SectionModels/) File.read(collection).should match(%r{section/model}) - File.read(spec).should match(/SectionModelsCollection/) + File.read(spec).should match(/SectionModels/) end end end diff --git a/templates/collection.js.erb b/templates/collection.js.erb index a169271..1ed3bbf 100644 --- a/templates/collection.js.erb +++ b/templates/collection.js.erb @@ -1,4 +1,4 @@ -var <%= object_name %>sCollection = Backbone.Collection.extend({ +var <%= object_name %>s = Backbone.Collection.extend({ url: '/<%= underscore_name %>', model: <%= object_name %> }); diff --git a/templates/collection_spec.js.erb b/templates/collection_spec.js.erb index bb09394..d6b6709 100644 --- a/templates/collection_spec.js.erb +++ b/templates/collection_spec.js.erb @@ -1,4 +1,4 @@ -describe('<%= object_name %>sCollection', function() { +describe('<%= object_name %>s', function() { var collection, server; beforeEach(function() { @@ -10,7 +10,7 @@ describe('<%= object_name %>sCollection', function() { }); it('should fetch records from the API', function() { - collection = new <%= object_name %>sCollection(); + collection = new <%= object_name %>s(); server.respondWith('GET', '<%= underscore_name %>', [ 200, { 'Content-type': 'application/json' }, "[{id: 1}]" ]); collection.fetch()