[rspec-users] Cucumber seems to be running steps after failed steps ...

Korny Sietsma korny at sietsma.com
Fri Mar 13 02:55:51 EDT 2009

I'm a bit confused.
I have a scenario similar to (numbered for clarity):
  Scenario: view basic
1)     Given I am logged in as 'fred'
2)      When I navigate to the 'foo' tab
3)      And I select the 'bar' node
4)      Then the node 'baz' is displayed

Now, when I have a problem that the 'foo' tab isn't actually visible, I
expect the scenario to fail at step 2.
It seems that it *does* fail, but it also runs steps 3 and 4 silently.
The trouble is that without the 'foo' tab, the 'bar' and 'baz' nodes don't
exist.  But I have code behind the scenes that tracks selenium errors and
takes screenshots and generates log messages, which I don't really want - I
only care about the error at step 2.  (And I'm also wasting time at steps 3
and 4 waiting for selenium stuff to time out...)

Is this the expected behaviour?  I did some digging in the code, and it
seems the core functionality is in executor.rb:
    def visit_step(step)
      unless @pending || @error
          step.execute_in(@world, regexp, args, proc) unless @dry_run
          @after_step_procs.each{|p| p.call_in(@world, *[])}
          formatters.step_passed(step, regexp, args)
        rescue => e
          @failed = true
          @error = step.error = e
          formatters.step_failed(step, regexp, args)
          step.execute_in(@world, regexp, args, proc)
          formatters.step_skipped(step, regexp, args)
        rescue Exception
          formatters.step_skipped(step, regexp, args)

>From reading this, it seems that once @pending or @error are set, following
steps will indeed still be run, but the output will be displayed as if they
were skipped.

Is this right?  Is there some way to bypass this and say "this is a serious
error, abort this scenario and jump to the next one" ???

- Korny

Kornelis Sietsma  korny at my surname dot com
kornys on gmail, twitter, facebook, etc.
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090313/74269acd/attachment.html>

More information about the rspec-users mailing list