开发者

RSpec > Is there a way to run all tests with one command?

开发者 https://www.devze.com 2023-03-30 19:04 出处:网络
Is there a command that does this? I\'ve searched 开发者_如何学Pythonbut can not find anythingTry this in your terminal window:

Is there a command that does this? I've searched 开发者_如何学Pythonbut can not find anything


Try this in your terminal window:

bundle exec rspec spec


if you are using rspec-rails then you can run using rake spec

if you're testing models, use rake spec:models (or rake spec:routing or rake spec:controllers)

if just testing one model, use rake SPEC=app/models/modelname.rb


  1. Create a .rspec file in the root of your project
  2. Add the path to where your specs are e.g.

    --default-path test/spec/

  3. Add the pattern of how your files are named e.g.

    --pattern ****/*.spec

  4. Run rspec and it should pick all your specs and run them :)

default-path and pattern are simply command line arguments, which means you can also add any other command line argument that rspec takes (can run rspec --help to see the available options)

According to https://www.relishapp.com/rspec/rspec-core/v/2-0/docs/configuration/read-command-line-configuration-options-from-files you can also put the options in ~/.rspec, which will make the options available globally. Local .rspec file options will override the global options.


For controller test

  1. bundle exec rake spec:controllers

For model test

  1. bundle exec rake spec:models

For all test

  1. bundle exec rake spec

For specific file test do

  1. rspec file_name_spec.rb (example rspec spec/controllers/groups_controller_spec.rb)


go to your app directory and run rspec spec or bundle exec rspec spec. use spork to speed your testing...(i kinda say its compulsory)

0

精彩评论

暂无评论...
验证码 换一张
取 消