I am trying to test some restful routes and the example from the API docs
(suitably munged) is failing. What am I not seeing?

Example from API docs on api.rubyonrails.com

# Check the default route (i.e., the index action)
  assert_recognizes {:controller => 'items', :action => 'index'}, 'items'

My test file test/functionals/birds_controller_test.rb
require 'test_helper'

class BirdsControllerTest < ActionController::TestCase
 test "should have some restful routes" do
    assert_recognizes {:controller => 'birds', :action => "index"},
"birds"
  end
end

Test errors

 $ ruby -Itest test/functional/birds_controller_test.rb
test/functional/birds_controller_test.rb:47: syntax error, unexpected
tASSOC, expecting '}'
    assert_recognizes {:controller => 'birds', :action => "index"}, "birds"
                                     ^
test/functional/birds_controller_test.rb:47: syntax error, unexpected ',',
expecting '}'
    assert_recognizes {:controller => 'birds', :action => "index"}, "birds"
                                              ^
test/functional/birds_controller_test.rb:47: syntax error, unexpected ',',
expecting kEND
    assert_recognizes {:controller => 'birds', :action => "index"}, "birds"
                                                                   ^

-----
This is an example app and birds is just created from script/generate
scaffold birds. And I am using Rails 2.3.2. My routing is as follows:

ActionController::Routing::Routes.draw do |map|
  map.resources :birds
end

$ rake routes
           birds GET    /birds(.:format)
{:action=>"index", :controller=>"birds"}
                   POST   /birds(.:format)
{:action=>"create", :controller=>"birds"
 new_bird GET    /birds/new(.:format)               {:action=>"new",
:controller=>"birds"}
   edit_bird GET    /birds/:id/edit(.:format)          {:action=>"edit",
:controller=>"birds"}
             bird GET    /birds/:id(.:format)
{:action=>"show", :controller=>"birds"}
                    PUT    /birds/:id(.:format)
{:action=>"update", :controller=>"birds"}
                DELETE /birds/:id(.:format)
{:action=>"destroy", :controller=>"birds"}
                       /:controller/:action/:id
                       /:controller/:action/:id(.:format)




  test "should have some restful routes" do
    assert_routing "/birds/1", {:controller => "birds", :action => "show",
:id => "1"}
    assert_recognizes {:controller => 'birds', :action => 'create'}, {:path
=> 'birds', :method => :post}
  end
end

-- 
Cynthia Kiser
cynthia.ki...@gmail.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to