How do you tell rails to generate integration tests using rspec and webrat?

1.3k Views Asked by At

I'm working through the Ruby on Rails Tutorial and I'm getting stuck on the integration tests. When I try to generate the integration tests for layout_links, I get the following comments in the generated test:

# Run the generator again with the --webrat flag if you want to use webrat methods/matchers

And I don't see the "response.should be_success" syntax that I expect. I think I've managed to hose my installation somehow but I don't know how to see which gems I have on the system and how to uninstall/reinstall them.

[edit]I do have webrat configured in the "test" section of my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.5'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'

group :development do
      gem 'rspec-rails', '2.5.0'
end

group :test do
      gem 'rspec', '2.5.0'
      gem 'webrat', '0.7.1'
end

Any help would be greatly appreciated.

2

There are 2 best solutions below

2
On BEST ANSWER

I believe that message means that webrat was not detected when the scaffold was generated. Look in your projects Gemfile for:

gem 'webrat'

Add it if it's missing, then run bundle install, then run the generator again.

0
On

I've gotten this to work and the problem seems to be my ruby/rails installation. I'm running Ubuntu and I think I've mixed a few packages installed via apt with those installed via bundle and gotten my system confused. I've followed this tutorial on installing Ruby on Rails in Ubuntu using rvm and now I can generate and run my tests again. I'm still having a few issues with autotest which I believe are related to conflicting packages. rvm looks like it's a much better way to set up a rails environment than apt and it allows you to only install your rails environment for one user. This way, you can set up a test user to make sure you get everything configured correctly without changing your entire system.

Thanks for all of the help.