

$ git commit -a -m'Initial commit' The gems (I could have configured my application template to do this step manually, but I wanted to explicitly show it as a separate step, partially to keep the application template clean and easily understandable.) $ git add. Once I’ve created my project, I add it to version control. $ rails new my_project -T -d postgresql \
#Define rails full
In this case I’m using a URL so that you can just copy and paste my full rails new command as-is if you want to. Application templates can be specified using either a local file path or a URL. In this particular case I’m also using the -m flag so I can pass in my application template. This choice of course has little to do with testing but I’m including it for completeness.

When I run rails new, I always use the -T flag for “skip test files” because I always use RSpec instead of the Minitest that Rails comes with by default.Īlso, incidentally, I always use PostgreSQL. That’s not to say I never write any of these types of tests, just sufficiently rarely that it makes more sense for me to create files manually in those cases than for me to allow files to get generated every single time I generate a scaffold. There are certain kinds of tests I tend not to write and I don’t want to clutter up my codebase with a bunch of empty files. The code in the file says “when a scaffold is generated, don’t generate files for fixtures, view specs, helper specs, routing specs, request specs or controller specs”. The second chunk of code creates a file at config/initializers/generators.rb. A more detailed explanation of these gems is below. The first chunk of code will add a certain set of gems to my Gemfile. A more detailed explanation can be found below the code.
#Define rails install
Here’s an application template I created that will do two things: 1) install a handful of testing-related gems and 2) add a config file that will tell RSpec not to generate certain types of files. This is useful if you create a lot of new Rails applications with parts in common. My application templateįirst, if you don’t know, it’s possible to create a file called an application template that you can use to create a Rails application with certain code or configuration included. Let’s start with the application template. My setup process (commands I run to create a new Rails app).An application template that can add all the necessary gems and configuration.

Below is how I set up a fresh Rails application for testing.
