twilson63 / express-coffee

A Template for NodeJs Application using Express, CoffeeScript, Jade, Stylus, Nib
http://twilson63.github.io/express-coffee
MIT License
626 stars 152 forks source link

Tests don't run due to case mismatch #20

Closed NeilBryant closed 11 years ago

NeilBryant commented 11 years ago

Running cake test dies for me on Linux, as it's calling for files with a different case than the files on disk.

posts_test.coffee
line 3
Post = require process.cwd() + '/.app/models/Post'
should be
Post = require process.cwd() + '/.app/models/post'
---------------------------------------------^

users_test.coffee
line 3
User = require process.cwd() + '/.app/models/User'
should be
User = require process.cwd() + '/.app/models/user'
---------------------------------------------^
twilson63 commented 11 years ago

@NeilBryant when you make the change do the test run successfully? I am getting even more test breakage when I make the suggested change.

Thanks

Tom

NeilBryant commented 11 years ago

Yes, they do. But I've narrowed down what's going on a bit more. I apologize for not digging in earlier, I really didn't know what this folder was for, yet.

scaffold/index.js 6) var name = name.toLowerCase(); 21) renderAndSave("model.coffee.ejs", "src/models/"+ name+".coffee");

scaffold/model.coffee.ejs 8) module.exports = mongoose.model '<%=: name | capitalize %>', <%=: name | capitalize %>

scaffold/controller.coffee.ejs and scaffold/test.coffee.ejs are similar.

so--if I'm reading all this right--the scaffolding index lower-casees the names it is going to save, then the scaffolding templates upper-case the names they're going to call.

With my limited knowledge of javascript, I understand that uppercasing the models is the 'proper' way to go, so I'm goign to find that function, stuff it into the index file, and see if it works.

On Mon, Dec 31, 2012 at 5:34 PM, Tom Wilson notifications@github.comwrote:

@NeilBryant https://github.com/NeilBryant when you make the change do the test run successfully? I am getting even more test breakage when I make the suggested change.

Thanks

Tom

— Reply to this email directly or view it on GitHubhttps://github.com/twilson63/express-coffee/issues/20#issuecomment-11786242.

NeilBryant commented 11 years ago

So, here's what I've done now (Seems like I say that to me wife a lot :\ )

I omitted my previous changes (they're useless anyway, as building the scaffold overwrites them), and just modified ./scaffold/index.js as follows:

21)  renderAndSave("model.coffee.ejs", "src/models/"+ name +".coffee");
to
21) renderAndSave("model.coffee.ejs", "src/models/"+ name.replace( /^./ , function (c){return c.toUpperCase();}) +".coffee");

There's probably a better way to do that, but I'm new to javascript.

I lied a bit, inadvertently. This gets me past the initial crashes, but the tests don't seem to run completely. I get a timeout error after that. I believe it's unrelated, but I'm putting it here for completeness:

Post
    1) "before all" hook

  ✖ 1 of 17 tests failed:

  1) Post "before all" hook:
     Error: timeout of 2000ms exceeded
      at Object.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.list.ontimeout (timers.js:101:19)

I haven't dug in enough to figure out if that's an error, or just some lame thing I did...

twilson63 commented 11 years ago

@NeilBryant

I think I fixed the case issue with the tests, please pull down latest commit and let me know if the tests work for you.

As far as the scaffolding it should not be capitalizing the requires in the controller and tests if the files are being created as lower case.

I will try to dig into this further.

Thx

Tom

NeilBryant commented 11 years ago

@Tom I will try the newest commit as soon as I get the opportunity (I don't know when that will be).

As for the capitalization, the single change listed in my last comment fixes all of it. Creates the models uppercase (as I believe is conventional), and the controllers, etc, all match. The tests work that far, as well.

One advantage being that if you use the generators, it still works (the generators create controllers that look for uppercase models).

On Tue, Jan 1, 2013 at 10:15 PM, Tom Wilson notifications@github.comwrote:

@NeilBryant https://github.com/NeilBryant

I think I fixed the case issue with the tests, please pull down latest commit and let me know if the tests work for you.

As far as the scaffolding it should not be capitalizing the requires in the controller and tests if the files are being created as lower case.

I will try to dig into this further.

Thx

Tom

— Reply to this email directly or view it on GitHubhttps://github.com/twilson63/express-coffee/issues/20#issuecomment-11800427.

NeilBryant commented 11 years ago

@twilson63 Yes, the current version works well for me; at least, it gets as far as I have. I run into:

1) Post "before all" hook: Error: timeout of 2000ms exceeded

Which I understand is an error connecting to mongodb. When I pick this up again, that's what I'll be looking into.

twilson63 commented 11 years ago

Yes,

I personally think that tests should not rely on a database being up, but it seems these tests are configured to depend on MongoDB running, I don't know if there is a mocking lib like nock for mongodb, but if you know of one, let me know and I will look into incorporating it into the test script.

Thanks

Tom

On Wed, Jan 2, 2013 at 4:45 PM, NeilBryant notifications@github.com wrote:

@twilson63 https://github.com/twilson63 Yes, the current version works well for me; at least, it gets as far as I have. I run into:

1) Post "before all" hook: Error: timeout of 2000ms exceeded

Which I understand is an error connecting to mongodb. When I pick this up again, that's what I'll be looking into.

— Reply to this email directly or view it on GitHubhttps://github.com/twilson63/express-coffee/issues/20#issuecomment-11825686.

Tom Wilson Jack Russell Software Company Division of CareKinesis 1067 Cliffwood Drive Mount Pleasant, SC 29464 Phone: 843-606-0637 Email: tom@jackhq.com Web: http://www.jackhq.com Calendar: http://www.jackhq.com/calendar

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure by the Health Insurance Portability and Accountability Act (HIPAA) and other state and federal laws. This information is intended only for the individual names above. Any review, use disclosure or dissemination of this material is strictly prohibited. If you receive this information in error, please notify CareKinesis immediately at 888-974-2763 and delete the original at once.

twilson63 commented 11 years ago

This should be fixed!

Thanks

Tom