Problems running RSpec 2 with autotest/autospec

It seems there is no bin/autospec with RSpec 2. So I got it running
simply with $ autotest

Been looking at instructions here
http://wiki.github.com/dchelimsky/rspec/autotest-integration

And here Getting Started with Autotest – Continuous Testing - PH7 Spot

But…

$ RSPEC=true autotest
loading autotest/cucumber_rspec
Error loading Autotest style autotest/cucumber_rspec (no such file to
load – autotest/rspec). Aborting.

What do I do here? I want to run it in “only rspec” mode for the time
being.

Also if I try to add the “redgreen” plugin

/.autotest

require “autotest/restart”

$ autotest
loading autotest/cucumber
style: Cucumber
/Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/gems/redgreen-1.2.2/
lib/redgreen/autotest.rb:6:in `<top (required)>': uninitialized
constant Object::PLATFORM (NameError)

Couldn’t find anything on the net related to this error. A ruby 1.9.2
issue?

On Jun 5, 2010, at 3:53 PM, Kristian M. wrote:

It seems there is no bin/autospec with RSpec 2. So I got it running
simply with $ autotest

Been looking at instructions here http://wiki.github.com/dchelimsky/rspec/autotest-integration

And here http://ph7spot.com/musings/getting-started-with-autotest

But…

$ RSPEC=true autotest

Don’t use RSPEC=true for rspec-2.

Also, probably need to set AUTOFEATURE=false.

loading autotest/cucumber_rspec
Error loading Autotest style autotest/cucumber_rspec (no such file to
load – autotest/rspec). Aborting.

What do I do here? I want to run it in “only rspec” mode for the time
being.
Also if I try to add the “redgreen” plugin

You don’t need this with rspec because rspec does it’s own colorizing.

HTH,
David

Thanks again David :slight_smile:

Don’t use RSPEC=true for rspec-2.

Also, probably need to set AUTOFEATURE=false.

OK, when I run it like this

$ AUTOFEATURE=false autotest

I get an empty autotest output whenever I change and save a spec.
The above lets me disable features, but how do I ENABLE specs with
rspec 2 if I can’t use RSPEC=true?

You don’t need this with rspec because rspec does it’s own colorizing.

Great! I disabled redgreen from my .autotest file. Now I just need to
get autotest working with RSpec 2 and coloring :wink:

PS: I added an RSpec 2 notes section to the bottom of the autotest
instructions at:
http://wiki.github.com/dchelimsky/rspec/autotest-integration
I know… there is a separate wiki for the rspec account as well, but
that wiki seems to have even less instructions. I would like to add
some wiki info there when I get all this working!

Thanks! I solved it all now and updated the RSpec 2 wiki about how to
set it all up :wink:

http://wiki.github.com/rspec/rspec/autotest

Hope these instructions provides a good base and is helpful to others!

Kristian M. wrote in post #917131:

Thanks! I solved it all now and updated the RSpec 2 wiki about how to
set it all up :wink:

http://wiki.github.com/rspec/rspec/autotest

Hope these instructions provides a good base and is helpful to others!

Hi Kristian, just wanted to pass on my appreciation for your efforts re
documenting rspec & autotest. As a newcomer to rspec (1 week and lovin’
it!), thanks to your wiki post, I have now got this working. I almost
had it, but your post sealed the deal.
cheers
Rob

Kristian M. wrote in post #917121:

As of beta.4, you’ll have to do add this configuration manually. Just
create an autotest directory in the root of your project, put the
following statement in ./autotest/discover.rb:

Autotest.add_discovery { “rspec2” }

Hi Kristian (or anyone who can shed some light on this),

I have followed the above instructions but to no avail. Looking at the
output of my command prompt below is there something obvious I am doing
incorrectly in getting autospec to work? I really would appreciate any
suggestions.

Thank-you in advance,
Michelle

C:\DEVELOPMENT\twits>cat autotest/discover.rb
Autotest.add_discovery { “rspec2” }

C:\DEVELOPMENT\twits>ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

C:\DEVELOPMENT\twits>gem list—local

  • LOCAL GEMS
    autotest (4.4.6)
    bundler (1.0.7)
    diff-lcs (1.1.2)
    git (1.2.5)
    jeweler (1.5.1)
    minitest (1.6.0)
    rake (0.8.7)
    rdiscount (1.6.5)
    rdoc (2.5.8)
    redcar (0.9.1)
    rspec (2.2.0)
    rspec-core (2.2.1)
    rspec-expectations (2.2.0)
    rspec-mocks (2.2.0)
    rubyzip (0.9.4)
    ZenTest (4.4.1)

C:\DEVELOPMENT\twits>autospec


REMOVAL NOTICE: you are using behaviour that has been
removed from rspec-2.

* The ‘autospec’ command is no longer supported.
* Please use ‘autotest’ insted.

This message will be removed from a future version of rspec


I found the solution here:
http://blog.davidchelimsky.net/category/autotest/


As of beta.4, you’ll have to do add this configuration manually. Just
create an autotest directory in the root of your project, put the
following statement in ./autotest/discover.rb:

Autotest.add_discovery { “rspec2” }

The final 2.0.0 release will include a generator (even for non-rails
projects) that will add this for you.

$ AUTOFEATURE=false autotest
(Not running features. To run features in autotest, set
AUTOFEATURE=true.)
loading autotest/rspec2
style: Rspec2

On Dec 9, 2010, at 6:19 AM, David C. wrote:

autotest-standalone-4.5.2

autotest # requires ./autotest/discover.rb
autotest --style rspec2

FYI - I filed a bug report in the ZenTest tracker [1], so hopefully this
will get resolved in a future release of ZenTest.

[1]
http://rubyforge.org/tracker/?func=detail&aid=28775&group_id=419&atid=1678

C:\DEVELOPMENT\twits>ruby -v
rake (0.8.7)
C:\DEVELOPMENT\twits>autospec

Cheers,
David

On Dec 8, 2010, at 11:22 PM, Michelle P. wrote:

I have followed the above instructions but to no avail. Looking at the
output of my command prompt below is there something obvious I am doing
incorrectly in getting autospec to work? I really would appreciate any
suggestions.

The ZenTest/autotest gem world is a bit confusing right now. Here’s the
deal:

ZenTest-4.4.1 rolled autotest (mostly) back into ZenTest, but introduced
a regression in which Autotest no longer sees ./autotest/discover.rb
when running on Ruby 1.9.2. This is because Ruby 1.9.2 does not add “.”
to the $LOAD_PATH and, while autotest-4.4.5 (before it got rolled back
to ZenTest) handled this, ZenTest-4.4.1 does not.

Additionally, there is now an autotest-standalone gem (currently at
4.5.2), which does handle the Ruby 1.9.2 situation correctly.

In any of these cases, autotest’s --style/-s option works correctly. So
your options are:

autotest-4.4.5

autotest # requires ./autotest/discover.rb
autotest --style rspec2

autotest-4.4.6 (with ZenTest-4.4.1)

autotest --style rspec2

autotest-standalone-4.5.2

autotest # requires ./autotest/discover.rb
autotest --style rspec2

HTH,
David

C:\DEVELOPMENT\twits>gem listlocal
redcar (0.9.1)
removed from rspec-2.
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Cheers,
David

David C. wrote in post #967405:

autotest-4.4.6 (with ZenTest-4.4.1)

autotest --style rspec2

Sorry David, truth be told I’m a ruby newbie working my way
through the new book “Continuous Testing with Ruby” so I’m a bit in the
dark here.

For what you mention above, where do I put these settings since
obviously not in discover.rb?

Thanks in advance, Michelle

On Thu, Dec 9, 2010 at 7:08 AM, Michelle P. [email protected]
wrote:

David C. wrote in post #967405:

autotest-4.4.6 (with ZenTest-4.4.1)

autotest --style rspec2

Sorry David, truth be told I’m a ruby newbie working my way
through the new book “Continuous Testing with Ruby” so I’m a bit in the
dark here.

For what you mention above, where do I put these settings since
obviously not in discover.rb?

These are commands you’d run from the command line. If you use the
–style option, you don’t need to worry about having
./autotest/discover.rb:

$ autotest --style rspec2

This works with any of autotest-4.4.5, 4.4.6, and
autotest-standalone-4.5.1.

If you want to use ./autotest/discover.rb to tell autotest to use
rspec instead of typing it on the command line, that only works with
autotest-4.4.5 and autotest-standalone-4.5.1 (if you’re using
ruby-1.9, that is - if you’re using ruby 1.8, it works with all three
versions):

$ autotest

HTH,
David

Hi David, sorry still no coconut. I should have explained myself better,
I actually need to run the “autospec” command as the book says:
“Thankfully, RSpec comes with a small script named autospec that
reconfigures autotest to run specs instead, so try that…”

So in the below I tried using your " --style rspec2" command for both
autotest and autospec. Any ideas how I get autospec to run?

C:\DEVELOPMENT\twits>autospec --style rspec2


REMOVAL NOTICE: you are using behaviour that has been
removed from rspec-2.

  • The ‘autospec’ command is no longer supported.
  • Please use ‘autotest’ insted.

This message will be removed from a future version of rspec.


C:\DEVELOPMENT\twits>autotest --style rspec2
loading autotest/rspec2
bundle exec C:\devtools\Ruby192\bin\ruby -S
C:/devtools/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2
.2.1/bin/rspec --tty ‘C:/DEVELOPMENT/twits/spec/twits_spec.rb’
Could not find gem ‘rspec (~> 2.1.0, runtime)’ in any of the
gem sources listed in your Gemfile.
Interrupt a second time to quit
Terminate batch job (Y/N)? y

Another quotation from this book which is sending me crazy:
Pragmatic Bookshelf: By Developers, For Developers
"Using RSpec 2?

The autospec command has been removed from RSpec 2, so
if you’ve upgraded, you’ll need to do something a little different.
You’re going to want to create a directory tree in the root
of your project named autotest/.autotest. Then inside that you
need to create a file named discover.rb. To that file we’ll need to
add the statement Autotest.add_discovery { “rspec2” }."

Thank-you very much for your help,
Michelle

Thanks (again) David for your replies and the time you’ve taken.

I am really bad at explaining myself. So I’ve drawn a picture for you to
show my problem and what I have done so far.

Please take a look: http://michellepace.com/pics/autospec-problem.jpg

Any suggestions?

On Thu, Dec 9, 2010 at 7:58 PM, Michelle P. [email protected]
wrote:


C:\DEVELOPMENT\twits>autotest --style rspec2
Another quotation from this book which is sending me crazy:
"Using RSpec 2?

The autospec command has been removed from RSpec 2, so
if youve upgraded, youll need to do something a little different.
Youre going to want to create a directory tree in the root
of your project named autotest/.autotest.

This is wrong ^^. The directory should be named autotest, and the file
named discover.rb. So if the project is at /home/michelle/my_project,
you’d want /home/michelle/my_project/autotest/discover.rb, with:

Autotest.add_discovery { “rspec2” }

Then, from the /home/michelle/my_project directory, just type this:

autotest

Try that - it should work with autotest-4.4.5 (make sure you remove
the ZenTest gem).

HTH,
David

Then inside that you
need to create a file named discover.rb. To that file well need to
add the statement Autotest.add_discovery { “rspec2” }."
Pragmatic Bookshelf: By Developers, For Developers

Michelle,

I think that the problem is that after that setup you want to use the
command autotest and NOT autospec

The book pages you have in your picture say that autospec has been
removed from rspec2 but don’t state explicitly that you should use the
autotest command rather than autospec.

Since “Continuous Testing with Ruby” is a beta book (first time I’ve
heard of it I must say), the authors would probably appreciate it if
you posted an erratum to the book’s site.

On Fri, Dec 10, 2010 at 2:18 AM, Michelle P. [email protected]
wrote:

Michelle


Posted via http://www.ruby-forum.com/.


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

On Fri, Dec 10, 2010 at 6:56 AM, David C. [email protected]
wrote:

Any of the following combinations will work:
$ gem uninstall autotest
$ autotest --style rspec2

This bypasses the search for autotest/discover.rb (so you can delete it if
you’re using this) and “just works.”

There are other options, but I don’t want to confuse you any further. I really
hope this clears things up.

Also, I’ve reported this issue to the ZenTest project, so there is some chance
that ZenTest-4.4.2 will add “.” to the $LOAD_PATH, at which point the material in
the book will work as written (except that the file is “autotest/discover.rb”, not
“autotest/.autotest/discover.rb”) with ruby-1.9.

Good luck!

FYI - Ryan D., in spite of his clear distaste for the approach [1],
just released ZenTest-4.4.2, which fixes this issue.

Cheers,
David

[1]

On Sat, Dec 11, 2010 at 12:54 PM, David C. [email protected]
wrote:

FYI - Ryan D., in spite of his clear distaste for the approach [1],
just released ZenTest-4.4.2, which fixes this issue.

Now that .rspec file is the recommended way of providing options for
RSpec2, can we use that to detect discovery?

Just a suggestion to avoid these type of conversations :wink:

Here is Bacon approach, checking for .bacon file


Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupry

On Dec 10, 2010, at 1:18 AM, Michelle P. wrote:

Thanks (again) Dave for your reply and the time you’ve taken.

However I think I must be really bad at explaining myself… so I’ve
drawn a picture for you which to show my problem. [One of the
requirements in the book is that I have to have ZenTest installed.]

You’re explaining yourself just fine. The problem is that you’re
listening 1/2 to the book and 1/2 to me, but you need to just listen to
me right now :slight_smile:

The problem is as follows:

  • the book uses ruby-1.8
  • you are using ruby-1.9
  • ruby-1.8 includes “.” on the $LOAD_PATH
  • ruby-1.9 does not include “.” on the $LOAD_PATH
  • ZenTest-4.4.1 does not add “.” to the $LOAD_PATH
  • these last two ^^ mean that if you’re using ruby-1.9, rspec-2, and
    ZenTest-4.4.1, the autotest command that ships with ZenTest will not
    find ‘./autotest/discover.rb’ and will not load the correct class
  • per the error message you got when you ran autospec, autospec has been
    removed from rspec-2, so you have to use the autotest command

Any of the following combinations will work:

  1. Run the following commands
    $ gem uninstall ZenTest
    $ gem uninstall autotest
    $ gem install autotest -v 4.4.5
    $ autotest

Again, use autotest, not autospec. autotest-4.4.5 is a standalone
autotest gem that does not require ZenTest. This will work using the
autotest/discover.rb file because autotest-4.4.5 adds “.” to the
$LOAD_PATH.

$ gem uninstall autotest
$ gem install ZenTest

At this point you have the book’s recommended setup, but the autotest
command will not see autotest/discover.rb. Your options are:

a) add “.” to the $LOAD_PATH yourself
$ ruby -I . -S autotest

The -I option tells ruby to add its argument (‘.’) to the command line.
The -S option tells ruby what script to run (autotest).

b) Use autotest’s --style option
$ autotest --style rspec2

This bypasses the search for autotest/discover.rb (so you can delete it
if you’re using this) and “just works.”

There are other options, but I don’t want to confuse you any further. I
really hope this clears things up.

Also, I’ve reported this issue to the ZenTest project, so there is some
chance that ZenTest-4.4.2 will add “.” to the $LOAD_PATH, at which point
the material in the book will work as written (except that the file is
“autotest/discover.rb”, not “autotest/.autotest/discover.rb”) with
ruby-1.9.

Good luck!

Cheers,
David


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Cheers,
David

On Sat, Dec 11, 2010 at 2:33 PM, David C. [email protected]
wrote:

One step ahead of you :slight_smile:

I’m going to beat your speed record David, some day… some day :slight_smile:

PS: Thank you :smiley:

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupry

On Dec 11, 2010, at 10:38 AM, Luis L. wrote:

Here is Bacon approach, checking for .bacon file

bacon/lib/autotest/discover.rb at master · leahneukirchen/bacon · GitHub

One step ahead of you :slight_smile:


Luis L.

Cheers,
David