uh, maybe now
This commit is contained in:
parent
f8fa5573c8
commit
db584858cf
|
@ -39,8 +39,8 @@ class BackboneGenerator < Thor
|
||||||
desc 'collection Namespaced::Name', "Create a collection"
|
desc 'collection Namespaced::Name', "Create a collection"
|
||||||
def collection(name)
|
def collection(name)
|
||||||
@name = name
|
@name = name
|
||||||
template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s_collection.js")
|
template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s.js")
|
||||||
template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_collection_spec.js")
|
template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_spec.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'collection-view Namespaced::Name', "Create a collection view"
|
desc 'collection-view Namespaced::Name', "Create a collection view"
|
||||||
|
|
|
@ -55,12 +55,12 @@ describe 'backbone-generator' do
|
||||||
it "should generate the collection files" do
|
it "should generate the collection files" do
|
||||||
system %{bin/backbone-generator collection Section::Model}
|
system %{bin/backbone-generator collection Section::Model}
|
||||||
|
|
||||||
File.file?(collection = 'public/javascripts/collections/section/models_collection.js').should be_true
|
File.file?(collection = 'public/javascripts/collections/section/models.js').should be_true
|
||||||
File.file?(spec = 'spec/javascripts/collections/section/models_collection_spec.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(collection).should match(%r{section/model})
|
||||||
File.read(spec).should match(/SectionModelsCollection/)
|
File.read(spec).should match(/SectionModels/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var <%= object_name %>sCollection = Backbone.Collection.extend({
|
var <%= object_name %>s = Backbone.Collection.extend({
|
||||||
url: '/<%= underscore_name %>',
|
url: '/<%= underscore_name %>',
|
||||||
model: <%= object_name %>
|
model: <%= object_name %>
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe('<%= object_name %>sCollection', function() {
|
describe('<%= object_name %>s', function() {
|
||||||
var collection, server;
|
var collection, server;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
@ -10,7 +10,7 @@ describe('<%= object_name %>sCollection', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch records from the API', 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}]" ]);
|
server.respondWith('GET', '<%= underscore_name %>', [ 200, { 'Content-type': 'application/json' }, "[{id: 1}]" ]);
|
||||||
collection.fetch()
|
collection.fetch()
|
||||||
|
|
Loading…
Reference in New Issue