[rspec-users] first try to make a controller test with RSpe

tgateau at seethroo.us tgateau at seethroo.us
Wed Aug 13 14:33:46 EDT 2008


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




More information about the rspec-users mailing list