Elliot Winkler
unread,Nov 23, 2009, 2:20:56 PM11/23/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spor...@googlegroups.com
I posted this problem on the RSpec mailing list and they said to try
here, so that what I'm doing ;)
I'm having the hardest time trying to figure out something weird I've
suddenly run into. I'm running my specs using the RSpec Textmate bundle
+ Spork. So of course I've got TM_RSPEC_OPTS in Textmate set to --drb
and I'm running `spork` from the command line to fire up the Spork
server before I run the specs. However, if I run a spec file in
Textmate, it seems that my spec_helper is getting loaded one too many
times. This isn't a problem on small apps because it doesn't take that
long to re-load the spec_helper. However, on big apps this can add 4 or
5 seconds to the time, and when running just one spec file this is kind
of annoying.
I did a quick test by having spec_helper print out something at the
bottom of the file (outside of any prefork or each_run blocks) and then
wrote up a quick one-example spec file. When I ran it, the debug line in
spec_helper was printed to the window, then the examples were printed,
then the line in spec_helper was printed again. (I didn't get a second
set of examples because I think RSpec's smart about not re-running
examples, or maybe it's Spork that's smart about not re-running
each_run's). So it definitely looks like spec_helper is getting loaded
again, after all the specs are run.
Actually, what it looks like is that two commands are being executed:
one to run just the spec file I have open, another to run all the specs.
I put a debug line in Spec::OptionParser#order! just to see what
arguments it got called with, and here's what I got:
------------
Spec::OptionParser#order!: @argv is
["/Users/elliot/code/nonwork/proj/web/rails_apps/sample/spec/foo_spec.rb",
"--format", "textmate", "--drb"]
Spec::OptionParser#order!: @argv is
["/Users/elliot/code/nonwork/proj/web/rails_apps/sample/spec/foo_spec.rb",
"--format", "textmate"]
** Spec::Runner::DrbCommandLine.run: DRb run called with argv:
["/Users/elliot/code/nonwork/proj/web/rails_apps/sample/spec/foo_spec.rb",
"--format", "textmate"]
** Spork: spec_helper was loaded
** Spork: each_run block executed
(examples run)
Spec::OptionParser#order!: @argv is ["--colour", "--format", "progress",
"--loadby", "mtime", "--reverse", "--drb"]
Spec::OptionParser#order!: @argv is ["--colour", "--format", "progress",
"--loadby", "mtime", "--reverse"]
** Spec::Runner::DrbCommandLine.run: DRb run called with argv:
["--colour", "--format", "progress", "--loadby", "mtime", "--reverse"]
** Spork: spec_helper was loaded
** Spork: each_run block executed
Spec::OptionParser#order!: @argv is ["--colour", "--format", "progress",
"--loadby", "mtime", "--reverse"]
------------
So what seems to be run is the equivalent of `spec foo_spec.rb --format
textmate --drb` followed by just `spec --opts spec.opts`.. or something.
I'm not sure ;)
Things I've tried that haven't worked:
* running specs from the app I'm working on
* running specs from a fresh app
* reinstalling rspec, rspec-rails, the RSpec Textmate bundle, and spork
* updating Textmate to the latest version (1.5.8)
* downgrading to Textmate 1.5.7
* commenting out the line that requires spec_helper in my spec file
* disabling the --drb option in TM_RSPEC_OPTS
Just to emphasize, what I've described only happens when Spork is
running. If I leave TM_RSPEC_OPTS at --drb but fail to leave the Spork
server open, spec_helper only gets run once as it should.
Also, this is only for Textmate -- I've got --drb in my spec.opts and
`rake spec` works just fine when Spork is running.
Sorry for the long email. Tim, could you offer any ideas as to what
might be causing this problem?
-- Elliot