[rspec-users] autospec: non-standard filenames & redirecting output

David Chelimsky dchelimsky at gmail.com
Fri Jan 15 09:09:43 EST 2010


On Thu, Jan 14, 2010 at 10:10 PM, DeNigris Sean <sean at clipperadams.com>wrote:

> Rspec gurus,
>
> I have 2 questions about autospec.  I've played around quite a bit, but
> can't figure it out...
>
> 1.  I got autospec to work with my directory structure
> ("examples/*_example.rb"), but it only works if I have an empty spec/
> directory.  Otherwise it reverts to running tests instead of examples...
> Current ./.autotest:
> Autotest.add_discovery do
>  "rspec" if File.directory?('examples')
> end
>

If you crack open ZenTest and look at these files:

bin/autotest
lib/autotest.rb

you'll see (eventually) that ./.autotest is loaded too late in the process.
It's actually loaded during the initialization of an Autotest object (or
subclass), so the class must already be determined.

Per the docs for autodiscover, all autotest/discover.rb files on your path
are loaded in order to determine what file to load. Try adding an autotest
directory in your project with a discover.rb file in it with:

Autotest.add_discovery { "rpspec" }


> Autotest.add_hook(:initialize) {|at|
>  ##at.add_exception %r{^\.git}  # ignore Version Control System
>  at.clear_mappings         # take out the default (test/test*rb)
>
>  at.add_mapping(%r%^examples/.*_example.rb$%) { |filename, _|
>    filename
>  }
>  at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
>    ["examples/#{m[1]}_example.rb"]
>  }
>  at.add_mapping(%r%^examples/(example_helper|shared/.*)\.rb$%) {
>    at.files_matching %r%^examples/.*_example\.rb$%
>  }
>        nil
> }
>
> 2.  Does anyone have a technique for redirecting the output (in my case to
> MacVim)?  I really only want it to happen if there are errors.  If
> everything went smoothly, probably a growl notification would be easier.
>

I'm not sure about redirecting to MacVim, but I do use growl notifications
for success and failure. If there's a failure, I go look at the shell
output. FWIW.

HTH,
David


>
> Thanks!
>
> Sean DeNigris
> sean at clipperadams.com
>
> Mac OS X 10.6.2
> rspec 1.2.9
> ZenTest 4.2.1
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100115/3af2469d/attachment.html>


More information about the rspec-users mailing list