rails restful query and rspec

I am working on a project that searches for an item number. But the
item number is not unique. Which is better to do:

/search/12345 or /search?id=12345 I would prefer to use the first
one.
I have a route for it as map.search "/search/:item_number"

I have made both work with manual testing. I do have a problem in
rSpec testing though. I do not understand how to request the page from
the controller.

I tried:

in the public_controller I have:

  def search
    @items = Item.all_items(params(:item_number))
    ....
  end

and in the rspec for the controller:

describe PublicController do

  #Delete these examples and add some real ones
  it "should use PublicController" do
    controller.should be_an_instance_of(PublicController)
  end

  describe "GET 'index'" do
    it "should be successful" do
      get 'index'
      response.should be_success
    end
  end

  describe "GET /search/:item_number" do
    it "should be successful" do
      get :search, :item_number => "12345" # also tried 'search'
      response.should be_success
    end
  end
end

it errors with:
ArgumentError in 'PublicController GET /search/:item_number should be
successful'
wrong number of arguments (1 for 0)

where have I gone wrong?

Don French

try get ‘search’, { :item_number => “12345” }

used: get "search", {:item_number => "12345"} and it gave the
same error.

dhf

Could I have the backtrace on the error please?

We can talk gtalk if you want.

/Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb:
8:in `params'
/Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb:
8:in `search'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:697:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:689:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
rescue.rb:199:in `perform_action_without_caching'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:678:in `perform_action'
/Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
query_cache.rb:8:in `cache'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:677:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:685:in `process_without_session_management_support'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session_management.rb:123:in `process_without_test'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
test_process.rb:15:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
test_process.rb:393:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
test_process.rb:364:in `get'
./spec/controllers/public_controller_spec.rb:20:

Log file shows:

Processing PublicController#search (for 0.0.0.0 at 2008-01-08
13:15:29) [GET]
  Session ID:
  Parameters: {"action"=>"search", "controller"=>"public",
"item_number"=>"12345"}
  SQL (0.000206) ROLLBACK