Forum: RSpec autotest?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Denis H. (Guest)
on 2009-05-20 06:55
(Received via mailing list)
Can someone point me to some decent doc on autotest?  Everything I'm
finding seems either pretty old, or says "autotest and rspec work out of
the box", which it isn't for me...

I installed the grosser-autotest gem (just guessing) and when I run
autotest it only runs (legacy) test/unit tests.

Suggestions?

Thanks...

dwh
Ben M. (Guest)
on 2009-05-20 07:22
(Received via mailing list)
Denis H. wrote:
> Can someone point me to some decent doc on autotest?  Everything I'm
> finding seems either pretty old, or says "autotest and rspec work out
> of the box", which it isn't for me...
>
> I installed the grosser-autotest gem (just guessing) and when I run
> autotest it only runs (legacy) test/unit tests.
>
> Suggestions?
RSpec now ships with an autospec command that acts as a wrapper.. are
you using it?

-Ben
Denis H. (Guest)
on 2009-05-20 07:41
(Received via mailing list)
Hmm.  Okay, tried that but:

$ autospec
(Not running features.  To run features in autotest, set
AUTOFEATURE=true.)
loading autotest/rails_rspec
Autotest style autotest/rails_rspec doesn't seem to exist. Aborting.

I'm running my rails rspec examples just fine manually...

dwh
Scott T. (Guest)
on 2009-05-20 08:26
(Received via mailing list)
Denis H. wrote:
> dwh
>
What version of the ZenTest gem do you have?
Denis H. (Guest)
on 2009-05-20 14:48
(Received via mailing list)
I didn't have ZenTest installed.  I just did, but I still get the same
error.  Should I *not* have grosser-autotest installed?

$ gem list | grep -i test
grosser-autotest (4.0.4)
test-unit (2.0.2)
ZenTest (4.0.0)

dwh
Scott T. (Guest)
on 2009-05-20 17:02
(Received via mailing list)
Denis H. wrote:
> I didn't have ZenTest installed.  I just did, but I still get the same
> error.  Should I *not* have grosser-autotest installed?
>
> $ gem list | grep -i test
> grosser-autotest (4.0.4)
> test-unit (2.0.2)
> ZenTest (4.0.0)
Try removing it.

Make sure to grab the latest ZenTest (which you now have), and rspec
(and rspec-on-rails, if you are in a rails project).

Aslak used to have some good abbreviation for this phrase: what versions
of everything are you using?

- rspec
- rspec on rails (if in a rails project)
- rails (if in a rails project)
- OS

Scott
Denis H. (Guest)
on 2009-05-21 09:31
(Received via mailing list)
Thanks.  Ok -- removing grosser-autotest lets autotest run, but it's
only running my unit tests, not rspec:

$ autotest
(Not running features.  To run features in autotest, set
AUTOFEATURE=true.)
loading autotest/rails
/usr/bin/ruby1.8 -I.:lib:test -rubygems -e "%w[test/unit
test/unit/design_test.rb test/functional/admin/user_controller_test.rb
test/unit/helpers/admin/user_helper_test.rb test/unit/garment_test.rb
test/functional/admin/admin_controller_test.rb
test/unit/helpers/admin/admin_helper_test.rb].each { |f| require f }" |
unit_diff -u

Here's all my versions:

cucumber (0.3.3)
rails (2.3.2, 2.2.2)
rspec (1.2.6, 1.1.12)
rspec-rails (1.2.6)
ZenTest (4.0.0)

OS: Ubuntu 8.10

I *was* missing rspec-rails, but even after installing it, same result
as above.

Is there some configuration I need to do to get rid of unit/functional
tests and only run rspec+cucumber?

Thanks!

dwh
Scott T. (Guest)
on 2009-05-21 10:22
(Received via mailing list)
Denis H. wrote:
> test/functional/admin/admin_controller_test.rb
>
> OS: Ubuntu 8.10
>
> I *was* missing rspec-rails, but even after installing it, same result
> as above.
>
> Is there some configuration I need to do to get rid of unit/functional
> tests and only run rspec+cucumber?
>
Run "autospec", which should come with the latest rspec gem.

Scott
Kero van Gelder (Guest)
on 2009-05-21 11:20
(Received via mailing list)
> Is there some configuration I need to do to get rid of unit/functional
> tests and only run rspec+cucumber?

This eplains all there is to explain (though terse and not from
your use case)
   http://zentest.rubyforge.org/ZenTest/Autotest.html

and you now have to add code from that to your .autotest

If you want to clear existing mappings, and add new mappings,
while also ignoring any temp file created by cucumber (or autotest
will keep triggering because it saw an updated file; which
surprises me, as there is no mapping for those files...)
you get something like this:

Autotest.add_hook(:initialize) {|at|
  at.add_exception %r{^\.git}
  at.add_exception %r{^./tmp}
  at.clear_mappings  # take out the default (test/test*rb)
  at.add_mapping(%r{^lib/.*\.rb$}) {|filename, _|
    Dir['spec/**/*.rb']
  }
  nil
}

The nil make sure that other :initialize hooks get executed.
Very relevant if you have both ~/.autotest and .autotest

I guess I should add this in some form to the rspec wiki ;)

Bye,
Kero.

___
How can I change the world if I can't even change myself?
  -- Faithless, Salva Mea
Kero van Gelder (Guest)
on 2009-05-21 12:00
(Received via mailing list)
> > Is there some configuration I need to do to get rid of unit/functional
> > tests and only run rspec+cucumber?

[...]
> I guess I should add this in some form to the rspec wiki ;)

Done:
   http://wiki.github.com/dchelimsky/rspec/autotest-integration

Bye,
Kero.
___
How can I change the world if I can't even change myself?
  -- Faithless, Salva Mea
Denis H. (Guest)
on 2009-05-21 14:44
(Received via mailing list)
Cool. Scott, Kero -- thanks.

dwh
David C. (Guest)
on 2009-05-21 15:24
(Received via mailing list)
On Thu, May 21, 2009 at 2:27 AM, Kero van Gelder 
<removed_email_address@domain.invalid> wrote:
>> > Is there some configuration I need to do to get rid of unit/functional
>> > tests and only run rspec+cucumber?
>
> [...]
>> I guess I should add this in some form to the rspec wiki ;)
>
> Done:
>   http://wiki.github.com/dchelimsky/rspec/autotest-integration

Thanks Kero. I added a bit of information about autospec to that wiki
page.

Cheers,
David
Scott T. (Guest)
on 2009-05-21 18:11
(Received via mailing list)
Kero van Gelder wrote:
>    http://wiki.github.com/dchelimsky/rspec/autotest-integration
>

+1.

Thanks Kero.

Scott
Kero van Gelder (Guest)
on 2009-05-21 19:49
(Received via mailing list)
> >> > Is there some configuration I need to do to get rid of unit/functional
> >> > tests and only run rspec+cucumber?
> >
> > [...]
> >> I guess I should add this in some form to the rspec wiki ;)
> >
> > Done:
> >   http://wiki.github.com/dchelimsky/rspec/autotest-integration
>
> Thanks Kero. I added a bit of information about autospec to that wiki page.

I keep learning things...
add_mapping returns nil, that's why it works for autotest/rspec.rb

But I've ran strace to confirm the problem I had with non-nil myself:
~/.autotest is ran *before* ./.autotest on my system (debian unstable).
Are you sure it's the other way around on your system?
I haven't seen autospec docs that claim one or the other.

Bye,
Kero.
___
How can I change the world if I can't even change myself?
  -- Faithless, Salva Mea
David C. (Guest)
on 2009-05-21 20:25
(Received via mailing list)
On Thu, May 21, 2009 at 10:34 AM, Kero van Gelder 
<removed_email_address@domain.invalid>
wrote:
>
> I keep learning things...
> add_mapping returns nil, that's why it works for autotest/rspec.rb
>
> But I've ran strace to confirm the problem I had with non-nil myself:
> ~/.autotest is ran *before* ./.autotest on my system (debian unstable).
> Are you sure it's the other way around on your system?
> I haven't seen autospec docs that claim one or the other.

No - you're correct - I had it wrong- and what you're experiencing
makes more sense. The local .autotest should load after the global
~/.autotest so it can do app-specific stuff.

I'll update the wiki page as soon as I can load it (having trouble
reaching github this moment).

Cheers,
David
This topic is locked and can not be replied to.