# RSpec 2 autotest file

**URL:** <https://www.ruby-forum.com/t/rspec-2-autotest-file/192902>\
**Category:** RSpec\
**Created:** [August 8, 2010, 12:19am UTC](https://www.ruby-forum.com/t/rspec-2-autotest-file/192902 "2010-08-08T00:19:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [August 8, 2010, 12:19am UTC](https://www.ruby-forum.com/t/rspec-2-autotest-file/192902/1 "2010-08-08T00:19:32Z")

</div>

Hi

I’ve tried using the autotest file from RSpec 2 (lib/autotest/rspec2.rb)  
but I’ve found a problem with it, that I think is a bug.

The file contains two sections

- an Autotest `Autotest.add_hook :initialize` block
- an Autotest class “Autotest::Rspec2”

In one project I’m working on, the code in Autotest::Rspec2 is really  
useful to me, but the :initialize hook contains setup that interferes  
with my project structure (I don’t want a “lib” folder.

Unfortunately, it appears that Autotest’s `clear_mappings` can’t stop  
the :initialize mappings making it into the final setup. This means  
that to use Autotest::Rspec2, I’ve had to copy-paste the contents into  
my own autotest file, rather than subclassing.

Is this a bug? (ie, is there no workaround for the coupling between the  
two blocks?) If so, can it be fixed?

Alternatively (or as well), is it time to drop autotest and use watchr  
instead? I noticed RSpec 2 uses that, and it seems really fast and  
simple, both of which go down very well with me…

Any thoughts?

Cheers  
Ash

–  
[http://www.patchspace.co.uk/](http://www.patchspace.co.uk/)  
[http://www.linkedin.com/in/ashleymoran](http://www.linkedin.com/in/ashleymoran)

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [August 8, 2010, 1:01am UTC](https://www.ruby-forum.com/t/rspec-2-autotest-file/192902/2 "2010-08-08T01:01:05Z")

</div>

On Aug 7, 2010, at 4:54 PM, Ashley M. wrote:

> Unfortunately, it appears that Autotest’s `clear_mappings` can’t stop the :initialize mappings making it into the final setup. This means that to use Autotest::Rspec2, I’ve had to copy-paste the contents into my own autotest file, rather than subclassing.
> 
> Is this a bug?

Yes.

> (ie, is there no workaround for the coupling between the two blocks?) If so, can it be fixed?

Yes:

> <https://github.com/rspec/rspec-core/commit/c2e8a3947321e501b84113c1b2b1049df4868f4b>
>
> initalize hook.
> 
> \- otherwise end users lose control over the hook

> Alternatively (or as well), is it time to drop autotest and use watchr instead? I noticed RSpec 2 uses that, and it seems really fast and simple, both of which go down very well with me…

I don’t think we need to drop one to use the other 🙂

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [August 8, 2010, 1:12pm UTC](https://www.ruby-forum.com/t/rspec-2-autotest-file/192902/3 "2010-08-08T13:12:06Z")

</div>

On Aug 08, 2010, at 12:00 am, David C. wrote:

> Yes: [Set up autotest mappings in the initialize method instead of the · rspec/rspec-core@c2e8a39 · GitHub](http://github.com/rspec/rspec-core/commit/c2e8a3947321e501b84113c1b2b1049df4868f4b)

Cool, ta 🙂 I’ll update my code shortly.

Cheers  
Ash

–

> **[PatchSpace](http://www.patchspace.co.uk/)**

[http://www.linkedin.com/in/ashleymoran](http://www.linkedin.com/in/ashleymoran)
