Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails new "-T" option, does it create an app without tests?

I am following this tutorial. In listing 1.1, it states:

Be aware that we’ll be using Rspec as the testing suite, so just make sure you include the -T option when creating the rails application.

What does the -T option do in this case?

like image 514
snowflakekiller Avatar asked Sep 09 '15 11:09

snowflakekiller


People also ask

How to create a new application in rails?

The syntax starts with the rails keyword “rails”. The keyword “rails” ensure to denote that the specific operation is a rails based operation. Hence the rails command executor will be triggered in the background. The command executor follows that the operation is a “ new “ creation operation. . Following this has to be the Application Name value.

How do I change the test environment of a Rails application?

By default, every Rails application has three environments: development, test, and production. Each environment's configuration can be modified similarly. In this case, we can modify our test environment by changing the options found in config/environments/test.rb. Your tests are run under RAILS_ENV=test.

How do I check if my Rails application is running?

To see your application in action, open a browser window and navigate to http://localhost:3000. You should see the Rails default information page: When you want to stop the web server, hit Ctrl+C in the terminal window where it's running.

What's in your rails app folder?

Most of the work in this tutorial will happen in the app folder, but here's a basic rundown on the function of each of the files and folders that Rails creates by default: Contains the controllers, models, views, helpers, mailers, channels, jobs, and assets for your application.


1 Answers

If you type:

rails -h

You'll see it explains the -T option like so:

-T, [--skip-test-unit], [--no-skip-test-unit]          # Skip Test::Unit files

In other words, this command tells Rails to skip the generation of Test::Unit files and folders. (Test::Unit is the default Rails testing framework.)

Without the -T option, two things happen by default:

  1. The rails app is intialized with a test directory containing:

    test/controllers
    test/fixtures
    test/helpers
    test/integration
    test/mailers
    test/models
    test_helper.rb
    

    You won't need these directories or the test_helper because you'll be using RSpec, which has it's own folder structure and helpers.

  2. Test::Unit test cases are auto-generated whenever you generate a model, controller, scaffold, etc.

    This is also unneeded because once you install RSpec, you'll be using RSpec's automatic spec generators.

Hope that helps!

like image 175
madcow Avatar answered Sep 19 '22 12:09

madcow