Search code examples
ruby-on-railsunit-testingrspec-rails

how to remove all test modules in an existing Rails project?


I am new to ruby and Ruby on Rails. I used command rails new [project name] to create a new rails project, and when using rails generate scaffold [Model name] to create a model, rails itself always create a testing module related to the model and the controller. so, how do i remove all rails default testing module and replace with some custom testing modules like Rspec?


Solution

  • If you have gem rspec-rails in your Gemfile, and don't have minitest, then rails generators already informed that you use Rspec instead of Minitest. rails generate command will create specs instead of tests.

    Off-topic: it creates fixtures as well. If instead of fixtures you use factories you need to declare it to your config-file:

    # config/application.rb
    
    config.generators do |g|
      g.factory_bot dir: 'spec/factories'
    end