[rspec-users] [Cucumber] Fail a scenario from After or AfterStep

aslak hellesoy aslak.hellesoy at gmail.com
Fri May 15 04:25:44 EDT 2009

> I'm trying to make sure that my cucumber selenium suite fails if my Rails
> app returns any 500 response codes. I'm working on what the best way to
> identify this state, but the question I'd like to put to the list is this:
> If I want to check for this error condition in an After or AfterStep, how
> can I force a failure in the scenario?

To be honest, I don't remember what happened to AfterStep. I think we
had it at some point, but can't see it in the codebase. Did I remove
it? Or was that back in the pre-Cucumber days? Help me remember

> i.e. something like the following non-functional snippet:
> AfterStep do |scenario|
>  if foo_error_state_detected?
>    scenario.fail("A foo failure has been detected.")
>  end
> end
> Ideas?

I'm not so sure I like the idea of AfterStep - smells like a
workaround for something that belongs elsewhere. Can't your have
selenium-rc (or a helper method you create around it) raise those

Given /bla/ do
  # don't remember the API, but you get the idea
  @browser.goto_strict('/bla') # raises on 500 errors


> TIA,
> Luke
> --
> Luke Melia
> luke at lukemelia.com
> http://www.lukemelia.com/
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list