wrong versions in gemfile :/
new gemfile
group :test, :development do
gem 'rspec-rails', '~> 1.2', :require => false
gem 'simplecov', :require => false
end
group :test do
gem 'test-unit', '1.2.3', :require => false # for rspec
gem 'rspec', '~> 1.2', :require => false
gem 'guard', :require => false
gem 'spork', '~> 0.8.0', :require => false
gem 'guard-rspec', :require => false
gem 'guard-spork', :require => false
gem 'growl', :require => false # notifications; optional
gem 'listen', '>= 0.5.1', :require => false
gem 'machinist', '~> 2.0', :require => false
gem 'database_cleaner', '~> 0.9.1', :require => false
end
Thanks to this post
Setting up RSpec, Guard, and Spork on a Rails 2 Project
I've done this a few times now; hopefully this will be helpful to anyone needing to maintain Rails 2.3 apps. This has worked great for the apps I've worked on, but I welcome contributions from others who suggest additional steps.
This guide assumes a Rails 2.3.x project on Bundler
Get rid of any old rspec plugins that are in your project, if any.
RSpec bits may be hiding in:
- Rakefile
- lib/tasks/rspec.rake
- vendor/plugins/rspec
- (anything else you can find)
RSpec 2 is not compatible with Rails 2; use RSpec 1 (docs). Put the most recent compatible gem versions to your Gemfile:
gem 'test-unit', '1.2.3', :require => false # for rspec
gem 'rspec', '~> 1.2', :require => false
gem 'rspec-rails', '~> 1.2', :require => false
gem 'guard', :require => false
gem 'spork', '~> 0.8.0', :require => false
gem 'guard-rspec', :require => false
gem 'guard-spork', :require => false
gem 'growl', :require => false # notifications; optional
gem 'rb-fsevent', :require => false # for OSX; optional
gem 'listen', '>= 0.5.1', :require => false
gem 'machinist', '~> 2.0', :require => false
gem 'database_cleaner', '~> 0.9.1', :require => false
Install the bundle.
Use bundle update for any gems that were already in your Gemfile.
Ensure
lib/tasks/rspec.rake
spec/spec_helper.rb do not exist.
./script/generate rspec
Remove the config.gem line that was added to config/environments/test.rb; the app uses bundler.
spork --bootstrap
Then edit spec/spec_helper.rb and follow the instructions.
Move everything from the stock spec_helper.rb into the prefork block,
except:Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
which belongs in each_run.
Install database_cleaner. In spec/spec_helper.rb,
In the prefork block: require 'database_cleaner'
In the each_run block: DatabaseCleaner.clean
Initialize Guardfile
guard init spork
guard init rspec
Modify the Guardfile's rspec guard to use the correct version and drb (spork):
guard 'rspec', :version => 1, :cli => '--drb --color' do
Modify the Guardfile as appropriate for your project
Run rake spec. You should get no output (if you have no tests). If you get errors, resolve them.
Run guard. No errors? Great, test away!
Problems? Try again more quickly by running spec spec instead of re-running guard.