# First try to make a controller test with RSpec on rails

**URL:** <https://www.ruby-forum.com/t/first-try-to-make-a-controller-test-with-rspec-on-rails/145780>\
**Category:** Rails\
**Created:** [August 13, 2008, 9:22pm UTC](https://www.ruby-forum.com/t/first-try-to-make-a-controller-test-with-rspec-on-rails/145780 "2008-08-13T21:22:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thib21](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90db22/32.png) [@Thib21](https://www.ruby-forum.com/u/Thib21)\
**Post date:** [August 13, 2008, 9:22pm UTC](https://www.ruby-forum.com/t/first-try-to-make-a-controller-test-with-rspec-on-rails/145780/1 "2008-08-13T21:22:00Z")

</div>

Hello, I’m trying to create a controller test with RSpec but I get the  
error when I run

> spec login\_controller\_spec.rb --format specdoc

…/…/app/controllers/application.rb:4: uninitialized constant  
ActionController (NameError)  
from /usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:  
27:in  
`gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in`require’  
from ./login\_controller\_spec.rb:9  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/  
example\_group\_runner.rb:14:in  
`load' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/ example_group_runner.rb:14:in`load\_files’  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/  
example\_group\_runner.rb:13:in  
`each' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/ example_group_runner.rb:13:in`load\_files’  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/options.rb:  
98:in  
`run_examples' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/ command_line.rb:19:in`run’  
from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec:4  
from /usr/bin/spec:19:in `load’  
from /usr/bin/spec:19

Here is my login\_controller\_spec :

## 

require File.dirname( **FILE** ) + ‘/…/spec\_helper’

describe “A LoginController” do

before(:each) do  
@login\_controlleur = LoginController.new  
end

it “should be valid” do  
@login\_controlleur.should be\_valid  
end  
end

## 

Here is my spec\_helper :

## 

require “rubygems”  
require “activerecord”  
require “spec”  
LIB\_DIR = File.join(File.expand\_path(File.dirname( **FILE** )), \*%w[…  
app  
controllers])

## 

Until now, I was working with Test::Unit, and all my test were  
successfull  
on my login\_controller.rb file.  
The file application.rb exists.  
I have tried to add the line :

require “actioncontroller”

in my spec\_helper, but I only get the error :

/usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require': no such file to load -- ActionController (MissingSourceFile) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in`require’  
from  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
dependencies.rb:509:in  
`require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ dependencies.rb:354:in`new\_constants\_in’  
from  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
dependencies.rb:509:in  
`require' from ./../spec_helper.rb:3 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in`gem\_original\_require’  
from /usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:  
27:in  
`require' from ./login_controller_spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/ example_group_runner.rb:14:in`load’  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/  
example\_group\_runner.rb:14:in  
`load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/ example_group_runner.rb:13:in`each’  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/  
example\_group\_runner.rb:13:in  
`load_files' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/options.rb: 98:in`run\_examples’  
from  
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner/  
command\_line.rb:19:in  
`run' from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.4/bin/spec:4 from /usr/bin/spec:19:in`load’  
from /usr/bin/spec:19

Could somebody help me find a solution to make my test working ?  
Thanks  
Thibault
