# Rspec controller not working, but works for models

**URL:** <https://www.ruby-forum.com/t/rspec-controller-not-working-but-works-for-models/111413>\
**Category:** Rails\
**Created:** [August 7, 2007, 3:31am UTC](https://www.ruby-forum.com/t/rspec-controller-not-working-but-works-for-models/111413 "2007-08-07T03:31:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![edxerx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecd19e/32.png) [@edxerx](https://www.ruby-forum.com/u/edxerx)\
**Post date:** [August 7, 2007, 3:31am UTC](https://www.ruby-forum.com/t/rspec-controller-not-working-but-works-for-models/111413/1 "2007-08-07T03:31:49Z")

</div>

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:

1. 

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
