How to run a single RSpec test?

后端 未结 17 794

I have the following file:

/spec/controllers/groups_controller_spec.rb

What command in terminal do I use to run just that spec and in what

17条回答
  •  不思量自难忘°
    2020-12-04 05:16

    Another common mistake is to still have or have upgraded an older Rails app to Rails 5+ and be putting require 'spec_helper' at the top of each test file. This should changed to require 'rails_helper'. If you are seeing different behavior between the rake task (rake spec) and when you run a single spec (rspec path/to/spec.rb), this is a common reason

    the best solution is to

    1) make sure you are using require 'rails_helper' at the top of each of your spec files — not the older-style require 'spec_helper' 2) use the rake spec SPEC=path/to/spec.rb syntax

    the older-style rspec path/to/spec.rb I think should be considered out-of-vogue by the community at this time in 2020 (but of course you will get it to work, other considerations aside)

提交回复
热议问题