Autospec: non-standard filenames & redirecting output

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

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
}

  1. 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.

Thanks!

Sean DeNigris
[email protected]

Mac OS X 10.6.2
rspec 1.2.9
ZenTest 4.2.1

On Thu, Jan 14, 2010 at 10:10 PM, DeNigris S.
[email protected]wrote:

“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” }

at.add_mapping(%r%^examples/(example_helper|shared/.).rb$%) {
at.files_matching %r%^examples/.
_example.rb$%
}
nil
}

  1. 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

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” }
Beautiful, worked like a charm, thanks!

Still experimenting with getting the results to MacVim… I’ll post
anything I figure out.

Sean

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs