How to run a single RSpec test?

后端 未结 17 795

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:26

    Run the commands from your project's root directory:

    # run all specs in the project's spec folder
    bundle exec rspec 
    
    # run specs nested under a directory, like controllers
    bundle exec rspec spec/controllers
    
    # run a single test file
    bundle exec rspec spec/controllers/groups_controller_spec.rb
    
    # run a test or subset of tests within a file
    # e.g., if the 'it', 'describe', or 'context' block you wish to test
    # starts at line 45, run:
    bundle exec rspec spec/controllers/groups_controller_spec.rb:45
    

提交回复
热议问题