Hi all.  I'm having a little problem with named routes.  I have the  
following named route:

   map.with_options :controller => 'snippets' do |map|
     map.snippets         
'faq/', :action                                   => 'index'
     map.new_snippet     'faq/ 
new', :action                                => 'new'
     map.snippet_text    'faq/ 
get/:id', :action                            => 'get_snippet_text'
     map.set_snippet     'faq/ 
set/:id', :action                            => 'set_snippet_text'
     map.snippet          
'faq/:id', :action                                => 'show'
     map.snippet_version 'faq/:id/version/:version', :action         
=> 'version'
     map.revert_snippet  'faq/:id/version/:version/revert', :action  
=> 'revert'
   end

When trying to write the following spec (a regression), I get the error:

========================================

describe SnippetsController, "routes" do
   it "should route the snippet_version_url to the version action" do
     snippet_version_url(:id => "1", :version => "41").should == "/foo"
   end
end

========================================

escher: ./script/spec spec/controllers/regressions/ 
2007_11_07_snippets_route_spec.rb
F

1)
NoMethodError in 'SnippetsController routes should route the  
snippet_version_url to the version action'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.rewrite
(eval):19:in `snippet_version_url'
./spec/controllers/regressions/2007_11_07_snippets_route_spec.rb:277:
./script/spec:4:

Finished in 0.029341 seconds

1 example, 1 failure


========================================

Should I be using route_for here?  I've noticed that the following  
spec fails:

========================================

describe SnippetsController, "routes" do
   it "should not raise an error with the snippet_version_url route" do
     lambda {
       snippet_version_url
     }.should_not raise_error
   end
end

escher: ./script/spec spec/controllers/regressions/ 
2007_11_07_snippets_route_spec.rb
F

1)
'SnippetsController routes should not raise an error with the  
snippet_version_url route' FAILED
expected no Exception, got #<NoMethodError: You have a nil object  
when you didn't expect it!
The error occurred while evaluating nil.rewrite>
./spec/controllers/regressions/2007_11_07_snippets_route_spec.rb:281:
./script/spec:4:

Finished in 0.029503 seconds

1 example, 1 failure

========================================

Thanks for any help,

Scott

PS: Running on Rspec edge, rails 1.2.3

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to