I did a little googling, and according to this thread on the rspec ruby forum and this closed rspec-rails issue, this is an issue with rspec-rails that has been fixed.
I am running Ruby 1.9.2p136 on Windows 7 using rails 3.0.3.
This is what my Gemfile looked like, which shows the versions of rspec and rspec-rails that I was using:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.4.1'
end
group :test do
gem 'rspec', '2.4.0'
gem 'webrat', '0.7.1'
end
I say "lookED like" because when I tried to run the rspec rails generator, this is what I got:
C:\Ruby\sample_app>rails generate rspec:install
create .rspec
create spec
create spec/spec_helper.rb
Could not find "autotest" in any of your source paths. Your current source paths
are:
C:/Ruby/sample_app/lib/templates/rspec/install
C:/Ruby/192-stackoverflow/lib/ruby/gems/1.9.1/gems/rspec-rails-2.3.0/lib/generators/rspec/install/templates
So then I added autotest to my Gemfile (and did bundle install again), then tried rails generate rspec:install again and it worked with no errors. So this is what my Gemfile looks like now:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'autotest'
gem 'rspec-rails', '2.4.1'
end
group :test do
gem 'rspec', '2.4.0'
gem 'webrat', '0.7.1'
end
And the version of autotest that this installs is 4.4.6:
C:\Ruby\sample_app>bundle show autotest
C:/Ruby/192-stackoverflow/lib/ruby/gems/1.9.1/gems/autotest-4.4.6
I then created the controller as instructed in the tutorial:
$ rails generate controller Pages home contact
And I was able to run both "bundle exec autotest" and "rspec spec/" without getting the error you are seeing:
C:\Ruby\sample_app>bundle exec autotest
loading autotest/rspec2
bundle exec C:\Ruby\192-stackoverflow\bin\ruby -S C:/Ruby/192-stackoverflow/lib/ruby/gems/1.9.1/gems/rspec-core-2.4.0/bin/rspec --tty 'C:/Ruby/sample_app/spec/controllers/pages_controller_spec.rb'
..
Finished in 23.04 seconds
2 examples, 0 failures
# I killed autotest with CTRL-c at this point
Interrupt a second time to quit
Terminate batch job (Y/N)? y
Terminate batch job (Y/N)? y
C:\Ruby\sample_app>rspec spec/
..
Finished in 23.11 seconds
2 examples, 0 failures
I also continued on with the tutorial, writing specs for the About page, while autotest was running and it was running on my changes without any problems.
So please try:
- Updating your Gemspec to look similar to my 2nd one posted here
- Running 'bundle install'
- Running 'bundle exec autotest'
and let me know if that works. I will be checking back!