[rspec-users] Is there a way to get an "around" hook for each spec file?

David Chelimsky dchelimsky at gmail.com
Wed Sep 7 08:52:24 EDT 2011

On Sep 7, 2011, at 6:50 AM, John Feminella wrote:

> Is there a way to run an `around` block once for every spec *file*
> (not spec)?

Not at this point, and I don't think it would be a slam dunk to add.

> (I want to measure which files take the longest amount of
> time, count the number of specs in each file, and then report the
> average spec running time for that file.)

You can use before/after all in the outermost group:

describe "thing" do
  before(:all) { set_up_measurements }
  after(:all)  { report_measurements }


> ~ jf
> --
> John Feminella
> Principal Consultant, BitsBuilder
> LI: http://www.linkedin.com/in/johnxf
> SO: http://stackoverflow.com/users/75170/

More information about the rspec-users mailing list