Spork.each_run instructions: spec_helper not getting reloaded

111 views
Skip to first unread message

Jo Liss

unread,
Feb 1, 2011, 11:34:12 AM2/1/11
to spor...@googlegroups.com
Hey everyone,

The instructions for Spork.each_run in the bootstrap.rb file say:

# - Sort through your spec_helper file. Place as much environment loading
# code that you don't normally modify during development in the
# Spork.prefork block.
# - Place the rest under Spork.each_run block

For this to work as advertised, spec_helper.rb would have to get
reloaded every time the tests are run, but that doesn't seem to be the
case, at least when I'm using Spork with RSpec 2:

To reproduce, I add `p "--------- in Spork.each_run ---------"` to the
each_run block. Now it doesn't get picked up when I run `rspec --drb
spec/`. Only after I restart Spork does the message get printed at
each run.

Am I doing something wrong, should the instructions be changed, or is
this a bug in Spork?

Thanks,
Jo

--
Jo Liss
http://opinionated-programmer.com/

Tim Harper

unread,
Feb 1, 2011, 11:46:16 AM2/1/11
to spor...@googlegroups.com
On Tue, Feb 1, 2011 at 9:34 AM, Jo Liss <joli...@gmail.com> wrote:
> Hey everyone,
>
> The instructions for Spork.each_run in the bootstrap.rb file say:
>
> # - Sort through your spec_helper file. Place as much environment loading
> #   code that you don't normally modify during development in the
> #   Spork.prefork block.
> # - Place the rest under Spork.each_run block
>
> For this to work as advertised, spec_helper.rb would have to get
> reloaded every time the tests are run, but that doesn't seem to be the
> case, at least when I'm using Spork with RSpec 2:

It's potentially poorly worded. What this saying is have the prefork
block of code load as much of your environment that you don't modify
during the development process. Then, have the each_run block load the
portions of your environment that DO change during the development
process. I'm not sure if you see the difference there, but basically,
your findings are correct: the each_run block does not reload with
each run of tests. Although, is conceivably possible to do so, there
are issues with it: what if you put in each_run block inside of your
prefork block somewhere? Would that get loaded?

It seems best to just place all test code that you do normally modify
in a separate file (spec_helpers/*?)


>
> To reproduce, I add `p "--------- in Spork.each_run ---------"` to the
> each_run block.  Now it doesn't get picked up when I run `rspec --drb
> spec/`.  Only after I restart Spork does the message get printed at
> each run.
>
> Am I doing something wrong, should the instructions be changed, or is
> this a bug in Spork?
>
> Thanks,
> Jo
>
> --
> Jo Liss
> http://opinionated-programmer.com/
>

> --
> You received this message because you are subscribed to the Google Groups "sporkgem" group.
> To post to this group, send email to spor...@googlegroups.com.
> To unsubscribe from this group, send email to sporkgem+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sporkgem?hl=en.
>
>

Jo Liss

unread,
Feb 1, 2011, 12:47:32 PM2/1/11
to spor...@googlegroups.com
On Tue, Feb 1, 2011 at 5:46 PM, Tim Harper <timch...@gmail.com> wrote:
> On Tue, Feb 1, 2011 at 9:34 AM, Jo Liss <joli...@gmail.com> wrote:
>> # - Sort through your spec_helper file. Place as much environment loading
>> #   code that you don't normally modify during development in the
>> #   Spork.prefork block.
>> # - Place the rest under Spork.each_run block
>
> It's potentially poorly worded. What this saying is have the prefork
> block of code load as much of your environment that you don't modify
> during the development process. Then, have the each_run block load the
> portions of your environment that DO change during the development
> process.

*reads-twice* Ah, haha. Now I see what this is about -- thanks for
elaborating! I've sent you a pull request with (hopefully) clearer
instructions for the bootstrap file. :)

> the each_run block does not reload with
> each run of tests. Although, is conceivably possible to do so,

Meh, whatever. It's not really necesarry.

> It seems best to just place all test code that you do normally modify
> in a separate file (spec_helpers/*?)

Good point. I've added this to the instructions.

Reply all
Reply to author
Forward
0 new messages