1

I am working on a sample RoR app and I am having trouble testing it with rspec. I have rspec installed and running the tests however they are failing and I don't know why. I run the command:

bundle exec rspec spec/

And when I run this; this is the error message I get:

Failures:



1) PagesController GET 'home' should be successful
     Failure/Error: Unable to find matching line from backtrace
     NameError:
       uninitialized constant ActionController::TestCase::Assertions
     # /usr/lib/ruby/vendor_ruby/action_controller/integration.rb:18
     # /usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/lib/webrat/integrations/rails.rb:2
     # /usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/configuration.rb:105:in `mode='
 # /usr/lib/ruby/gems/1.8/gems/rspec-rails-2.6.1/lib/rspec/rails/vendor/webrat.rb:26
 # /usr/lib/ruby/gems/1.8/gems/webrat-

And alot more error messages.

I'm no expert on RoR and would really appreciate help. Thanks in advance.

jefflunt
  • 33,527
  • 7
  • 88
  • 126
Hugs
  • 915
  • 4
  • 20
  • 47
  • What version of webrat and Rspec are in your `Gemfile`. Also what does `gem list` tell you you are using? – Noah Clark Oct 25 '11 at 13:30
  • gem 'rspec-rails', '2.6.1' gem 'webrat', '0.7.1' – Hugs Oct 25 '11 at 14:42
  • rspec (2.6.0) rspec-core (2.6.4) rspec-expectations (2.6.0) rspec-mocks (2.6.0) rspec-rails (2.6.1) webrat (0.7.1) and this is from the gem list output. – Hugs Oct 25 '11 at 14:44
  • Have you looked through: http://stackoverflow.com/questions/5032119/rspec-error-while-following-http-ruby-railstutorial-org-tutorial ? You wouldn't happen to be using a systems package manager like apt-get to install rails? – Noah Clark Oct 25 '11 at 15:00
  • Yea I can't quite recall how I installed Rails. I either used RVM or the apt-get command. I didnt install from source. – Hugs Oct 25 '11 at 15:20
  • that might be your problem then. Has Rspec ever worked? I'd check your apt-get to see if rails is installed that way and remove it and reinstall rails using rubygems. That seemed to work for the folks in that other thread. – Noah Clark Oct 25 '11 at 15:28
  • Ok thanks. How do I check if I used apt-get? – Hugs Oct 25 '11 at 15:38
  • Try something like: dpkg -s another thing to try is typing in `which rails` at the command line. The path will probably give you a pretty good idea of how you installed it. – Noah Clark Oct 25 '11 at 15:40
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/4510/discussion-between-noahclark-and-hugo) – Noah Clark Oct 25 '11 at 15:51

2 Answers2

1

RSpec is only guaranteed to work out of the box for Rail defaults. Remove webrat from your Gemfile and try it again.

Depending on the tutorial this might break things again in later steps.

My solution to the problem was to remove the package installation of rails (apt-get remove rails && apt-get autoremove) and its dependencies, because it was apparently clashing with the gem install. Quite understandable. You can install it with gem (sudo gem install rails)

Belrog
  • 950
  • 1
  • 11
  • 19
0

I had the same problem on a fresh Ubuntu 11.10 install.

After ensuring I was using the latest versions of rspec and that rails was installed using

gem install rails 

I also ensured that uninstalling the ubuntu rails didn't leave any artificts with

sudo apt-get autoremove

I also had ruby 1.8.7 so I switched to 1.9.2

rvm use 1.9.2 

Either my ruby version was the problem or the autoremove removed some interference. But things were working after that.

Stu
  • 1,497
  • 1
  • 13
  • 24