uh, maybe now

This commit is contained in:
John Bintz 2011-04-15 16:02:22 -04:00
parent f8fa5573c8
commit db584858cf
4 changed files with 9 additions and 9 deletions

View File

@ -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"

View File

@ -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

View File

@ -1,4 +1,4 @@
var <%= object_name %>sCollection = Backbone.Collection.extend({
var <%= object_name %>s = Backbone.Collection.extend({
url: '/<%= underscore_name %>',
model: <%= object_name %>
});

View File

@ -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()