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

Luke Melia luke at lukemelia.com
Fri May 15 17:12:04 EDT 2009


On May 15, 2009, at 3:36 PM, aslak hellesoy wrote:

> Thanks for doing that. I have one more favour to ask: Can you show me
> an example of a StepDefinition that would cause the file to be
> created?

That is a tougher question, because any browser interaction that  
causes an HTTP request to the app under test could result in a server  
error.

Ajax requests can be triggered by javascript, and in various parts of  
our app, they are triggered by clicking on links, submitting forms,  
dragging and dropping divs, hovering over a div, waiting for a page  
load to complete, as a callback from interacting with a 3rd party web  
service, or waiting for a setTimeout to execute.

So one way I could tackle it is to add a step to the end of every  
scenario that says "Then the application should not have issued any  
responses with 50x status codes", but that would be a) repetitive, and  
b) not fail until all steps had run, making it harder to track down  
the step in the test where the failure occurred.

One way to look at may be that I'm trying to enforce an invariant.  
Under no circumstances in my test suite is it appropriate for my app  
to raise a 50x error. In my Rails integration suite, webrat enforces  
this particular invariant for me, but can't find a good hook in the  
selenium test stack to do this, which is why I'm looking at this route.

Cheers,
Luke

--
Luke Melia
luke at lukemelia.com
http://www.lukemelia.com/



More information about the rspec-users mailing list