Combining autotest, rspec, rspec_on_rails and spec-server

Hello,

I’ve been trying to google the definitive way to combine autotest,
rspec, and spec-server, but to no avail. It seems like there are lots
of suggestions from old versions. Furthermore, some commands such as
rake:autotest don’t seem to be around anymore.

So, is it required to install ZenTest as a gem? I have version 3.9.1.
I believe this gets me the autotest command that I can issue on the
command line.

Must I install rspec as a gem? At first, I tried to not install it as
a gem and followed the instructions from http://rspec.info/
documentation/rails/install.html. I installed rspec as a plugin to my
Rails project and used just rake spec, but found that unless I
install rspec as a gem, there is no spec command for the command
line. That might make it easier to run my specs with options. So, I
installed rspec 1.1.3 as a gem. That provided me with the spec
command that I can issue on the command line.

What is the recommended way to start the spec-server? ./script/
spec_server or rake:spec:server:start? I’ve tried both and cannot
discern the differences.

Finally, what is the recommended way to run my specs? spec -O spec/
spec.opts spec/XXX or rake spec:XXX ? I’ve edited spec.opts to
include --drb on the first line. The rake method didn’t seem to use
the spec-server, despite this suggestion. So, I’ve tried the spec
command above. It still didn’t seem to use spec-server. However, when
I use spec -X -O spec/spec.opts, it does seem to use the spec_server.
I’m glad I’m able to finally use the spec_server, but it’s a real
drag switching back to my command line to issue this command after
every save. That’s exactly why I want to run autotest.

What is the recommended way to run autotest? autotest or rake
spec:autotest (I’ve seen this on google, but the command itself no
longer appears when I run rake -T spec. Is there something wrong with
my setup? Am I supposed to have a rake task for this or is it
deprecated). Without an available rake task, I am forced to try the
autotest command. However, I don’t think that the autotest command
accepts any options that tell it to use the spec_server. I tried
autotest -X, and of course, my spec.opts file does already say --drb
in the first line.

As you can see, I am really confused because there are at least 2
ways to do everything, and I haven’t been able to try every combination.

I’ve also noticed that autotest no longer runs the entire test suite
after a red-green cycle. I actually liked this behavior, but all I
could find was David C.'s blog on how to de-activate the
behavior. Why has it changed? Can it be restored?

If it helps, I’m running on Mac OS X 10.4.11, ruby 1.8.6 (2007-09-24
patchlevel 111) [powerpc-darwin8.11.0]

Thanks for your help!

-Anthony

On Mar 20, 2008, at 8:56 AM, Anthony C. wrote:

Hello,

I’ve been trying to google the definitive way to combine autotest,
rspec, and spec-server, but to no avail. It seems like there are lots
of suggestions from old versions. Furthermore, some commands such as
rake:autotest don’t seem to be around anymore.

So, is it required to install ZenTest as a gem? I have version 3.9.1.
I believe this gets me the autotest command that I can issue on the
command line.

Yep.

Must I install rspec as a gem? At first, I tried to not install it as
a gem and followed the instructions from http://rspec.info/
documentation/rails/install.html. I installed rspec as a plugin to my
Rails project and used just rake spec, but found that unless I
install rspec as a gem, there is no spec command for the command
line. That might make it easier to run my specs with options. So, I

If you have both rspec and rspec_on_rails installed in vendor/
plugins, and have issued a “ruby script/generate rspec” command, you
shouldn’t need the gem (in the rails project, at least)

installed rspec 1.1.3 as a gem. That provided me with the spec
command that I can issue on the command line.

What is the recommended way to start the spec-server? ./script/
spec_server or rake:spec:server:start? I’ve tried both and cannot
discern the differences.

There is no difference, except that the one gives you the command
line back. I’d recommend starting it directly. You will need to
restart it once in a while.

Finally, what is the recommended way to run my specs? spec -O spec/
spec.opts spec/XXX or rake spec:XXX ? I’ve edited spec.opts to
include --drb on the first line. The rake method didn’t seem to use
the spec-server, despite this suggestion. So, I’ve tried the spec
command above. It still didn’t seem to use spec-server. However, when
I use spec -X -O spec/spec.opts, it does seem to use the spec_server.
I’m glad I’m able to finally use the spec_server, but it’s a real
drag switching back to my command line to issue this command after
every save. That’s exactly why I want to run autotest.

Yeah. The spec server is great, but I’ve found it to be buggy (as
have others). Recently I’ve noticed that it doesn’t play well with
shared example groups.

Usually what I do is run a single spec file with -X (or --drb) and -c
(–color):

script/spec foo_spec.rb -X -c

If I have any problems, I’ll first try restarting the spec_server
(which I have running in a seperate term window). Otherwise, I’ll
just run the file individually.

When I’m done with each spec file individually, I’ll go and run rake
spec, which recreates the test database and so on, and runs the whole
suite of specs.

What is the recommended way to run autotest? autotest or rake
spec:autotest (I’ve seen this on google, but the command itself no

just plain old autotest.

longer appears when I run rake -T spec. Is there something wrong with
my setup? Am I supposed to have a rake task for this or is it
deprecated). Without an available rake task, I am forced to try the
autotest command. However, I don’t think that the autotest command
accepts any options that tell it to use the spec_server. I tried
autotest -X, and of course, my spec.opts file does already say --drb
in the first line.

Oh - there was a bug in the last stable release with --drb (or -X) in
spec.opts:

http://rspec.lighthouseapp.com/projects/5645/tickets/293-drb-does-not-
work-from-spec-opts

It’s been resolved in trunk.

Scott