> On May 15, 2009, at 10:16 AM, aslak hellesoy wrote: > >> Can you show me the code you would want to put in AfterStep that would >> detect a 500 error? > > I've written a simple piece of rack middleware (included below) that will > create a file in the event a 500 is raised. I would clear the file before > each scenario and check for it's existence in the AfterStep. For example: >
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? Then I might be able to suggest an alternative solution with the same result. Aslak > Before do > File.delete('/tmp/rails.error') if File.exist?('/tmp/rails.error') > end > > AfterStep do |scenario| > if File.exist?('/tmp/rails.error') > scenario.fail("Failed because app raised a 50x error.") > end > end > > Here's the rack piece, for the curious: > > class RackErrorTouch > def initialize(app, options = {}) > �...@app = app > �...@path = options[:path] > end > > def call(env) > rack_response = @app.call(env) > if rack_response.first >= 500 > `touch #...@path}` > end > rack_response > end > end > -- > Luke Melia > l...@lukemelia.com > http://www.lukemelia.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users