Packaging for Rails applications

I am working on a Rails app, for deployment I usually checkout the code from git repository to the production servers which are running apache with mod-rails.

But checking out the complete code, I am also checking out the spec and tests folder, I would like to avoid having test/specs code on my production servers.

Is there a set way of packaging rails application for deployment ? I am using capistrano, so is there a way in capistrano to package so that test/spec are ignored while deploying ?

Regards,
Amiruddin Nagri,

Bangalore, 560008, KA
India

Y! IM : amir_nagri@yahoo.com
GTalk : amir.nagri@gmail.com

Why would you want to do that? How will you run tests on your
production application if you exclude those directories?

For deployment what things you are going to used? Are you deploying it automatically?

Is the problem with the spec’s cleaning your database? can you give clarification on that?

Why would you want to do that?

I want to follow a good practice of deploying only the code required to run the functionality on production servers. If you are coming from java world, that is what you do, have your application jar/war only containing your source code and resources, the tests are packaged in a separate jar.

How will you run tests on your production application if you exclude those directories?

Why would I want to run tests on my production servers ??? I have staging, uat and other environments to emulate production environment.

Regards,
Amiruddin Nagri,
Bangalore, 560008, KA
India

Y! IM : amir_nagri@yahoo.com
GTalk : amir.nagri@gmail.com

For deployment what things you are going to used? Are you deploying it automatically?

I am deploying it using capistrano, it has built in tasks, you just have to configure your server address, username, password etc in a config file.

Is the problem with the spec’s cleaning your database? can you give clarification on that?

No, I am not even running the specs against my production servers. I am trying to follow a good practice where you package only the things required to run your application, and exclude the development necessary stuffs like specs/test. This is what I used to follow when I was doing java projects, have separate jar/war for production code and separate packaging of tests.

there is a manual way to do it .

git rm -r . --cached

then edit .gitignore and add the specs folder

git add .

git commit -am " with no specs folder"

git push

to go back to normal

git rm -r . --cached

then edit .gitignore and remove the specs folder

git add .

git commit -am " with no specs folder"

git push

i think is possible to add this to you cap recipe , but the thing is you could add the specs folder to the .gitignore file and push, but before
adding it you have to flush the cached index.

Amiruddin Nagri wrote:

I will be very skeptical about running tests against production servers, what if by mistake I corrupt the data or drop the database itself.

Deleting the spec folder sounds ok, but there are also many test configuration files floating around that are not need for eg environments/test.rb etc. What about them ?

Rails is clearly missing the isolation for the necessary final executable code and rest of the files required for eg testing etc. It is much more clearly defined in Java world.

I think it is easy enough to do that.
First of all, it is not rails fault since rails never know what
plugins you're using for test(e.g. rspec).

You just make a branch and a tag for your particular release that
doesn't include all the files and folders you don't need in production
environment.
Then let your capistrano to checkout that tag from your git
repository.

Regards,
Lewisou

Amiruddin Nagri wrote:

But it would be best to keep the tests. If you run into a problem on
your production server, you should be able to run the tests to see where
things are going wrong.

I will be very skeptical about running tests against production servers,
what if by mistake I corrupt the data or drop the database itself.

Don't run them against the production *database*!

Deleting the spec folder sounds ok,

But it isn't.

but there are also many test
configuration files floating around that are not need for eg
environments/test.rb etc. What about them ?

Rails is clearly missing the isolation for the necessary final
executable
code and rest of the files required for eg testing etc. It is much more
clearly defined in Java world.

No...you're trying to define an isolation point where there really isn't
one.

Best,