Forum: RSpec Is there a way to get an "around" hook for each spec file?

Posted by John Feminella (Guest)
on 2011-09-07 14:14
(Received via mailing list)
Is there a way to run an `around` block once for every spec *file*
(not spec)? (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.)

~ jf
--
John Feminella
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: http://stackoverflow.com/users/75170/
Posted by David Chelimsky (Guest)
on 2011-09-07 15:38
(Received via mailing list)
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 }
end

HTH,
David
Posted by Justin Ko (Guest)
on 2011-09-07 16:08
(Received via mailing list)
On Wed, Sep 7, 2011 at 5:50 AM, John Feminella 
<johnf@bitsbuilder.com>wrote:

> SO: http://stackoverflow.com/users/75170/
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


Why not just use the --profile option?
Posted by John Feminella (Guest)
on 2011-09-07 17:33
(Received via mailing list)
> Why not just use the --profile option?

Doesn't --profile only return the ten slowest examples? I have
thousands of specs, so I need a little more data than that.

~ jf
--
John Feminella
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: http://stackoverflow.com/users/75170/
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.