Home > Blockchain >  Is there a way to keep the order of cases as defined, while running bundle exec rspec {file_path} --
Is there a way to keep the order of cases as defined, while running bundle exec rspec {file_path} --

Time:11-24

I am having a problem while running

bundle exec rspec spec/services/abc_service_spec.rb --format documentation

The output of it, is not in the same order as the order of cases defined in the file. Is there any option to pass with while running rspec command ?

CodePudding user response:

https://relishapp.com/rspec/rspec-core/docs/command-line/order

bundle exec rspec spec/services/abc_service_spec.rb --format documentation --order defined

CodePudding user response:

According to the documentation, Rspec use the --order option to order the files, groups, and examples. The available ordering options are defined and rand while defined is the default options.

If somehow your Rspec order option has changed the run the rspec with --order defined like

exec rspec spec/services/abc_service_spec.rb --format documentation --order defined

If you want set it globally the add below code to your spec_helper.rb

Rspec.configure do |config|
  config.order = :defined
end

Hope you found this helpful.

  • Related