Help with rspec

Hi all,
My name is Shlomi Zadok - I am an old time PHP (mainly Drupal) developer
and
I am doing my first application on Ruby on Rails ( I just love it!!)
I am trying to test my application with rspec and I am having problems.

I have to admit that I rushed with the development and neglected the
testing

  • I have installed rspec & webrat only after finished the prototype,
    not
    sure it is related.

The error I am getting is:
Failure/Error: Unable to find matching line from backtrace
NameError:
uninitialized constant ActionController::TestCase::Assertions

You have encountered that question a lot huh? :slight_smile:

Please find below my configurations:

I run Ubuntu 11.04
Rails 3.0.7
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
I use Aptana as an IDE

My Gemfile:

source ‘http://rubygems.org

gem ‘rails’, ‘3.0.7’

Bundle edge Rails instead:

gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem ‘sqlite3-ruby’, :require => ‘sqlite3’

Enable gravatar

gem ‘gravatar_image_tag’, ‘1.0.0.pre2’

Enable pagination

gem ‘will_paginate’, ‘3.0.pre2’

Use unicorn as the web server

gem ‘unicorn’

Enable jquery

gem ‘jquery-rails’

Enable tiny_mce

gem ‘tiny_mce’

Enable amistad friendship manager

gem ‘amistad’

Enable authorization manager for user (who can see what)

gem ‘cancan’

Paperclip to add attachments to files

gem “paperclip”, “~> 2.3”

Deploy with Capistrano

gem ‘capistrano’

To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby

1.9.2+)

gem ‘ruby-debug’

gem ‘ruby-debug19’

Bundle the extra gems:

gem ‘bj’

gem ‘nokogiri’

gem ‘sqlite3-ruby’, :require => ‘sqlite3’

gem ‘aws-s3’, :require => ‘aws/s3’

Bundle gems for the local environment. Make sure to

put test-only gems in this group so their generators

and rake tasks are available in development mode:

group :development, :test do

gem ‘webrat’

end

group :development do
gem ‘rspec-rails’, ‘2.5.0’
end

group :test do
gem ‘rspec’, ‘2.5.0’
gem ‘webrat’, ‘0.7.1’
end

I started with a very simple test:
spec/controllers/pages_controller_spec.rb (literally copied from
http://ruby.railstutorial.org/chapters/static-pages):

require ‘spec_helper’

describe PagesController do
describe “GET ‘home’” do
it “should be successful” do
get ‘home’
response.should be_success
end
end
end

Thank you so much for your help.
Shlomi

On Jun 12, 2011, at 2:25 AM, שלומי צדוק wrote:


> group :development do > gem 'rspec-rails', '2.5.0' > end > > group :test do > gem 'rspec', '2.5.0' > gem 'webrat', '0.7.1' > end

Do this instead:

group :development, :test do
gem ‘rspec-rails’, ‘2.5.0’
end

group :test do
gem ‘webrat’, ‘0.7.1’
end

rspec-rails needs to be in the development env in order to expose the
rake tasks and the test environment in order to be loaded when you run
the spec suite. It has a dependency on rspec, so you don’t need to list
rspec explicitly.

Webrat only needs to be in the development env.

HTH,
David