Including extra directories for Autospec

Is there a way to tell autospec for rails to run all the spec files
in the spec directory a la spec/**/*_spec.rb instead of just the ones
in model/controller/etc? I’ve experimented with adding my own mappings
in <project_dir>/.autotest but haven’t had any luck.

On Sun, May 17, 2009 at 11:45 AM, Adam A.
[email protected] wrote:

Is there a way to tell autospec for rails to run all the spec files
in the spec directory a la spec/**/*_spec.rb instead of just the ones
in model/controller/etc? I’ve experimented with adding my own mappings
in <project_dir>/.autotest but haven’t had any luck.

See if this helps:
http://blog.davidchelimsky.net/2008/01/15/rspec-1-1-2-and-zentest-3-8-0/

I’m really not sure what I’m doing wrong so I tried started from
scratch still with no positive results.

Here’s my setup:
rails 2.3.2
rspec 1.2.6
rspec-rails 1.2.6
ZenTest 4.0.0

Here’s what I did:
$ rails foo
$ cd foo
$ ./script/generate rspec
$ ./script/generate rspec_model Bar
$ rake db:migrate RAILS_ENV=test
$ autospec # => runs and passes one example
$ mkdir spec/something
$ touch ./autotest spec/something/lol_spec.rb
$ autospec -v # => correctly does not find a mapping for
spec/something/lol_spec.rb

Then I edit the files like so:

./autotest:
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/something/._spec.rb$%) do
at.files_matching(%r%^spec/something/.
_spec.rb$%)
end
end

spec/something/lol_spec.rb:
describe “Lol” do
it “should do a thing” do
false.should be_true
end
end

$ autospec -v # => still not finding a match for
spec/something/lol_spec.rb
loading autotest/rails_rspec
No tests matched app/helpers/application_helper.rb
No tests matched spec/rcov.opts
No tests matched test/test_helper.rb
No tests matched lib/tasks/rspec.rake
No tests matched Rakefile
No tests matched README
No tests matched .autotest
No tests matched spec/something/lol_spec.rb
No tests matched test/performance/browsing_test.rb
No tests matched spec/spec.opts
/opt/local/bin/ruby
/opt/local/lib/ruby/gems/1.8/gems/rspec-1.2.6/bin/spec --autospec
spec/models/bar_spec.rb -O spec/spec.opts
.

Finished in 0.135414 seconds

1 example, 0 failures

Waiting since 2009-05-17 16:22:56

Sorry to be so verbose but I’m honestly very lost at this point…
I’ve also tried variations of this the add_mapping method by using the
block variables but no go.

-Adam

Yeah. I apologize that was a typo on my part. It should have said
./.autotest

-Adam

Then I edit the files like so:

./autotest:
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/something/._spec.rb$%) do
at.files_matching(%r%^spec/something/.
_spec.rb$%)
end
end

Do you perhaps have a ~/.autotest with a hook to :initialize ?
If so, let it return nil, like this:

Autotest.add_hook :initialize do |at|
%w{.svn .hg .git}.each {|exception|
at.add_exception(exception)
}
nil
end

It’s documented, but a nasty default behaviour.

Bye,
Kero.


How can I change the world if I can’t even change myself?
– Faithless, Salva Mea

Oh! Yeah I did eventually reduce it to my ~/.autotest hooks clobbering
any
configuration in a ./.autotest so Kero’s solution makes good sense.

Such bizarre behavior. If I put the initialize block after my growl
setup
then it borks as usual even if I explicitly return nil. However, putting
the
block before my growl setup and explicitly returning nil makes
everything
work…

Thanks, Kero! And thanks, Dave for bumping this and making me look at it
again.

Adam, that’s not what Kero was asking about. In addition to the
./.autotest file, do you also have a ~/.autotest file?