Topic: rspec: controller not working, but works for models

I'm new with rspec and using rails 1.2.3, and plugins
(rspec/rspec_on_rails 1.0.5). Followed tutorials by lukeredpath and
rspec's writing tutorial at their site.

I have an agencies controller, thus creating spec files for this
controller:-

spec/controllers/agencies_controller_spec.rb

require File.dirname(__FILE__) + '/../spec_helper'
describe AgenciesController do

  #Delete this example and add some real ones
  it "should use AgenciesController" do
    controller.should be_an_instance_of(AgenciesController)
  end

end

describe AgenciesController, "#route_for" do

  it "should map { :controller => 'agencies', :action => 'index' } to /agencies" do
    route_for(:controller => "agencies", :action => "index").should == "/agencies"
  end

end


when I run it - ruby script/spec
spec/controllers/agencies_controller_spec.rb I get these errors

1)
NameError in 'AgenciesController should use AgenciesController'
undefined local variable or method `controller' for [Dynamically
generated class
for RSpec example]:#<Class:0x464f088>
./spec\controllers\agencies_controller_spec.rb:7:
script/spec_server:23:in `run'
script/spec_server:44:

2)
NoMethodError in 'AgenciesController#route_for should map { :controller
=> 'agen
cies', :action => 'index' } to /agencies'
undefined method `route_for' for [Dynamically generated class for RSpec
example]
:#<Class:0x46426bc>
./spec\controllers\agencies_controller_spec.rb:15:
script/spec_server:23:in `run'
script/spec_server:44:

Finished in 0.016 seconds

2 examples, 2 failures

anyone know what went wrong? since I can run my model specs, and it
seems that route_for is native to rspec

Last edited by edxerx (2007-08-07 00:08:58)

Re: rspec: controller not working, but works for models

update : I upgraded to rspec & rspec_on_rails plugins version 1.0.8, and this problem dissapeared smile