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

74283a8aa16c958f3d48d41d96c99577?d=identicon&s=25 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/
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 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
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 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?
74283a8aa16c958f3d48d41d96c99577?d=identicon&s=25 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/
This topic is locked and can not be replied to.