Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't generate test automatically in Rails

I'm using rspec with Rails 4 and when creating controllers, for example, I always have to pass the "--no-test-framework" parameter. Is there a way to not generate these tests by default without needing to explicitly specify it (I often forget and then need to manually delete the generated tests).

Thank you!

like image 418
ilovebigmacs Avatar asked Aug 01 '13 18:08

ilovebigmacs


People also ask

Where do I add tests to my Rails application?

Once the skeleton of the new Rails application has been built, you will see a folder called test in the root of the new application, and many subfolders and files within the test directory. For the purposes of this post, I will be focusing on adding tests to the models directory, since unit testing in Rails primarily involves testing models.

How do you test functional tests in rails?

The easiest way to see functional tests in action is to generate a controller using the scaffold generator: $ bin/rails generate scaffold_controller article title:string body:text ... create app/controllers/articles_controller.rb ... invoke test_unit create test/controllers/articles_controller_test.rb ...

What are model tests in rails?

Model tests are used to test the various models of your application. Rails model tests are stored under the test/models directory. Rails provides a generator to create a model test skeleton for you. Model tests don't have their own superclass like ActionMailer::TestCase. Instead, they inherit from ActiveSupport::TestCase.

What is the use of test directory in rails?

Rails creates a test directory for you as soon as you create a Rails project using rails new application_name. If you list the contents of this directory then you shall see: The helpers, mailers, and models directories are meant to hold tests for view helpers, mailers, and models, respectively.


1 Answers

Just add the following to config/application.rb (within the Application class):

config.generators.test_framework false
like image 71
Gray Avatar answered Oct 16 '22 04:10

Gray