[rspec-users] Error in executing controller spec

Amit Kulkarni lists at ruby-forum.com
Tue May 19 04:30:48 EDT 2009


Ruby version : 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
rspec - 1.2.4
rails - 2.1.2
OS - Vista Home
I am running a single file by the command
spec channels_controller(filename)_spec.rb

Contents of the file:

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

def setup
  @controller  = ChannelsController.new
  @request     = ActionController::TestRequest.new
  @response    = ActionController::TestResponse.new
end

def user_attributes
    {
      :login => 'foo',
      :password => 'foobar',
      :password_confirmation => 'foobar',
      :email => 'foo at dibistore.it',
      :privacy => '1',
      :idiom => nil,
      :role_id => 2
    }
end

describe ChannelsController do
    fixtures :channels, :users
    context "Brand Manager" do
    @user = User.find_by_login("amit")
      it "should not create channel" do
        user = User.new
        user.attributes = user_attributes
        post :create, :channel => {:brand_name => 'by manager'}
      end
    end
end

Now when i run this file i get error which says
RuntimeError in 'ChannelsController Brand Manager should not create 
chnnel'
@controller is nil: mke sure you set it in your test's setup method.

Backtrace is as follows:
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/
test_process.rb:378:in `process'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/
test_process.rb:376:in `ech'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/
test_process.rb:376:in `process'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/ctionpck-2.1.2/lib/ction_controller/
test_process.rb:365:in `post'
./chnnels_controller_spec.rb:141:
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m
ethods.rb:41:in `instnce_evl'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m
ethods.rb:41:in `execute'
C:/Progrm Files/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_m
ethods.rb:38:in `execute'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g
roup_methods.rb:203:in `run_exmples'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g
roup_methods.rb:201:in `ech'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g
roup_methods.rb:201:in `run_exmples'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/exmple/exmple_g
roup_methods.rb:99:in `run'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g
roup_runner.rb:23:in `run'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g
roup_runner.rb:22:in `ech'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/exmple_g
roup_runner.rb:22:in `run'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/options.
rb:119:in `run_exmples'
C:/Progrm 
Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/runner/commnd_l
ine.rb:9:in `run'
C:/Progrm Files/ruby/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec:4
C:/Progrm Files/ruby/bin/spec:19:in `lod'
C:/Progrm Files/ruby/bin/spec:19

Please Advice
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list