How do you run a single test/spec file in RSpec?

前端 未结 14 1661
-上瘾入骨i
-上瘾入骨i 2020-12-12 08:45

I want to be able to run a single spec file\'s tests — for the one file I\'m editing, for example. rake spec executes all the specs. My project is not a

14条回答
  •  [愿得一人]
    2020-12-12 09:10

    Lets say, you're running test for creating todo. You can always run that specific todo spec code using the file crete_spec.rb file as below.

          rspec/spec/features/controller/spec_file_name.rb
    
       Example:
    
       Creating  rspec spec/features/todos/create_spec.rb
       Editing   rspec spec/features/todos/edit_spec.rb
       Deleting  rspec spec/features/todos/destroy_spec.rb
    

    If you want to run all the specs in one single short.

       rspec 
    

    If you want to run all the specs in a specific controller user this.

      rspec/spec/feaures/controller_name
    
      Example:   rspec/spec/features/todos
    

    Hope it gives you more understanding!

提交回复
热议问题