ruby - Stop execution of particular rspec test (not test suite) on first failure -


is there programmatic way force rspec test stop on first failure?

for example,

  1. i have test suite couple of rspec tests , run them @ once.
  2. every rspec test located in separate spec.rb file

if failure occurs in of these tests, stop execution of specific test further on particular test step failed not stop execution of whole test suite i'm running.

i know there following way:

rspec.configure |c|   c.fail_fast = true end 

but defining in of spec files ran in test suite causes execution of suite fail.

any way case can handled?

thanks in advance

i know old question, stumbled across while looking achieve same behavior myself. after fruitless searching, came straightforward implement provides desired behavior!

just add following each spec file skip subsequent examples (in specific file) when exception occurs:

  before :all     $continue = true   end    around :each |example|     if $continue       $continue = false       example.run       $continue = true unless example.exception     else       example.skip     end   end 

the logic here should self-explanatory. continue running examples until exception occurs, skip rest of examples spec. around each hook facilitates logic nicely since can control execution of each example. see rspec documentation more info on "around" hook.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -