|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
at_exit in spec file?I need to perform some work (shutdown mysql servers & delete their
data directories) at the end of my tests. Naturally, I would like to use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and the tests are run twice). Help? _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On Oct 28, 2009, at 10:41 AM, Student wrote:
> I need to perform some work (shutdown mysql servers & delete their > data directories) at the end of my tests. Naturally, I would like to > use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and > the tests are run twice). > > Help? For better or worse, RSpec uses at_exit, so you can't for this purpose. What you _can_ do is add an after(:suite) block (typically in spec_helper.rb): Spec::Runner.configure do |config| after(:suite) do # shut stuff down here end end HTH, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Hmmm... That yields "undefined method `after' for main:Object
(NoMethodError)" ... BUT I'm pretty sure I'm barking up the wrong tree. I think that I'm getting hung up with mysqld_safe. I'm On Oct 28, 10:49 am, David Chelimsky <dchelim...@...> wrote: > On Oct 28, 2009, at 10:41 AM, Student wrote: > > > I need to perform some work (shutdown mysql servers & delete their > > data directories) at the end of my tests. Naturally, I would like to > > use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and > > the tests are run twice). > > > Help? > > For better or worse, RSpec uses at_exit, so you can't for this purpose. > > What you _can_ do is add an after(:suite) block (typically in > spec_helper.rb): > > Spec::Runner.configure do |config| > after(:suite) do > # shut stuff down here > end > end > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Looking over things, the problem is probably with fork/exec related.
I need to start mysql (two of them). They need to run in separate processes. However, I don't seem to be able to "really" exit when I call exit!. It's the final termination of these processes which trigger the reruns. I've tried several variations, nothing is working so far. On Oct 28, 10:49 am, David Chelimsky <dchelim...@...> wrote: > On Oct 28, 2009, at 10:41 AM, Student wrote: > > > I need to perform some work (shutdown mysql servers & delete their > > data directories) at the end of my tests. Naturally, I would like to > > use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and > > the tests are run twice). > > > Help? > > For better or worse, RSpec uses at_exit, so you can't for this purpose. > > What you _can_ do is add an after(:suite) block (typically in > spec_helper.rb): > > Spec::Runner.configure do |config| > after(:suite) do > # shut stuff down here > end > end > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Some trouble with the list here...
Hmmm... That yields "undefined method `after' for main:Object (NoMethodError)" ... BUT I'm pretty sure I'm barking up the wrong tree. I think that I'm getting hung up with mysqld_safe. I'm running two test servers, which need to be in separate threads. So I have to background them some way. I've tried playing games with fork & nohup, but no success so far. (When these threads exit, even exit!, the test gets reread & reexecuted.) On Oct 28, 10:49 am, David Chelimsky <dchelim...@...> wrote: > On Oct 28, 2009, at 10:41 AM, Student wrote: > > > I need to perform some work (shutdown mysql servers & delete their > > data directories) at the end of my tests. Naturally, I would like to > > use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and > > the tests are run twice). > > > Help? > > For better or worse, RSpec uses at_exit, so you can't for this purpose. > > What you _can_ do is add an after(:suite) block (typically in > spec_helper.rb): > > Spec::Runner.configure do |config| > after(:suite) do > # shut stuff down here > end > end > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Well, I've got it half solved. In the shell call, I background &
nohup the mysqld_safe call. After the fork, I do a Process.kill(9, pid) on each of them. That stops the "run twice" problem. So now I'm back to the "undefined method `after' for main:Object (NoMethodError)" problem. On Oct 28, 12:44 pm, Student <blog...@...> wrote: > Some trouble with the list here... > > Hmmm... That yields "undefined method `after' for main:Object > (NoMethodError)" ... BUT > > I'm pretty sure I'm barking up the wrong tree. I think that I'm > getting hung up with mysqld_safe. I'm running two test servers, which > need to be in separate threads. So I have to background them some > way. I've tried playing games with fork & nohup, but no success so > far. (When these threads exit, even exit!, the test gets reread & > reexecuted.) > > On Oct 28, 10:49 am, David Chelimsky <dchelim...@...> wrote: > > > On Oct 28, 2009, at 10:41 AM, Student wrote: > > > > I need to perform some work (shutdown mysql servers & delete their > > > data directories) at the end of my tests. Naturally, I would like to > > > use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and > > > the tests are run twice). > > > > Help? > > > For better or worse, RSpec uses at_exit, so you can't for this purpose. > > > What you _can_ do is add an after(:suite) block (typically in > > spec_helper.rb): > > > Spec::Runner.configure do |config| > > after(:suite) do > > # shut stuff down here > > end > > end > > > HTH, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On 28 Oct 2009, at 20:42, Student wrote: > So now I'm > back to the "undefined method `after' for main:Object (NoMethodError)" > problem. I think it was just a typo on David's part. Does the following work? Spec::Runner.configure do |config| config.after(:suite) do # shut stuff down here end end And I had no idea you could do before/after :suite... Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Sweet! Thanks!
On Oct 28, 3:52 pm, Ashley Moran <ashley.mo...@...> wrote: > On 28 Oct 2009, at 20:42, Student wrote: > > > So now I'm > > back to the "undefined method `after' for main:Object (NoMethodError)" > > problem. > > I think it was just a typo on David's part. Does the following work? > > Spec::Runner.configure do |config| > config.after(:suite) do > # shut stuff down here > end > end > > And I had no idea you could do before/after :suite... > > Ashley > > --http://www.patchspace.co.uk/http://www.linkedin.com/in/ashleymoranhttp://aviewfromafar.net/ > > _______________________________________________ > rspec-users mailing list > rspec-us...@...://rubyforge.org/mailman/listinfo/rspec-users rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?Sorry about that :( And thanks, Ashley, for righting (and writing) my
wrong. Cheers, David On Oct 28, 2009, at 4:06 PM, Student wrote: > Sweet! Thanks! > > On Oct 28, 3:52 pm, Ashley Moran <ashley.mo...@...> > wrote: >> On 28 Oct 2009, at 20:42, Student wrote: >> >>> So now I'm >>> back to the "undefined method `after' for main:Object >>> (NoMethodError)" >>> problem. >> >> I think it was just a typo on David's part. Does the following work? >> >> Spec::Runner.configure do |config| >> config.after(:suite) do >> # shut stuff down here >> end >> end >> >> And I had no idea you could do before/after :suite... >> >> Ashley >> >> --http://www.patchspace.co.uk/http://www.linkedin.com/in/ashleymoranhttp://aviewfromafar.net/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us...@...://rubyforge.org/mailman/listinfo/ >> rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users@... > http://rubyforge.org/mailman/listinfo/rspec-users Cheers, David _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On Oct 28, 2009, at 9:42 pm, David Chelimsky wrote: > Sorry about that :( And thanks, Ashley, for righting (and writing) > my wrong. No probs. I'm trying to answer the straightforward technical questions, at least non-Rails ones. To people who have clearly tried to help themselves first of course :) Hopefully will free up other people's time. But, is it me, or is rspec-users quieter than it used to be? I'm sure when I was learning the volume of questions was much higher. Are there fewer people using RSpec? Or is it just more stable and well- documented now? (Maybe I'm just imagining it anyway.) Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On Wed, Oct 28, 2009 at 4:49 PM, David Chelimsky <dchelimsky@...> wrote:
> On Oct 28, 2009, at 10:41 AM, Student wrote: > >> I need to perform some work (shutdown mysql servers & delete their >> data directories) at the end of my tests. Naturally, I would like to >> use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and >> the tests are run twice). >> >> Help? > > For better or worse, RSpec uses at_exit, so you can't for this purpose. > Why not? Kernel#at_exit will just push procs onto a list of procs and run them all when Ruby exits. > What you _can_ do is add an after(:suite) block (typically in > spec_helper.rb): > > Spec::Runner.configure do |config| > after(:suite) do > # shut stuff down here > end > end > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users@... > http://rubyforge.org/mailman/listinfo/rspec-users > rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On Thu, Oct 29, 2009 at 6:18 AM, Ashley Moran
<ashley.moran@...> wrote: > > But, is it me, or is rspec-users quieter than it used to be? I'm sure when > I was learning the volume of questions was much higher. Are there fewer > people using RSpec? Or is it just more stable and well-documented now? > (Maybe I'm just imagining it anyway.) Everyone's busy programming. >8-> (More helpfully: this stuff tends to come in waves. A busier list pushes up its visibility in people's mailboxes, which makes them participate more, which makes it busier. This one never seems to be totally quiet, though.) -- Have Fun, Steve Eley (sfeley@...) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On 29 Oct 2009, at 13:46, Stephen Eley wrote:
> Everyone's busy programming. >8-> I imagine the book helps a bit, too. Cheers, -Tom _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: at_exit in spec file?On 29 Oct 2009, at 13:58, Tom Stuart wrote: > On 29 Oct 2009, at 13:46, Stephen Eley wrote: >> Everyone's busy programming. >8-> > > I imagine the book helps a bit, too. The book pretty much replaces the slides I did for my mocking presentation, and may do the same for the rest of my consulting work =) Burn all the copies! And print the PDFs out and throw them on the fire!!! Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
| Free embeddable forum powered by Nabble | Forum Help |