Ah, thanks! That was a breakthrough. My mock object “ids_string” isn’t
receiving the method calls I expect (even though the code under test
actually does what I want it to do and works correctly), but at least
I’m past the params issue.
Al
----- Original Message ----
From: Daniel T. [email protected]
To: rspec-users [email protected]
Sent: Tuesday, December 4, 2007 1:56:25 AM
Subject: Re: [rspec-users] params not available for controller specs?
Try:
get :download, :ids => ids_string
You need the “:” in front of the action name.
Daniel
On 4 Dec 2007, at 09:28 4 Dec 2007, Al Chou wrote:
I actually did stub Order.find() but was getting a nil object error
because params[:ids] was nil. I can’t write
controller.download :ids => ‘1/2/3’
in the controller spec, and
get download, :ids => ids_string
results in the following error message:
NameError in ‘Admin::OrdersController should split the params[:ids]
string to create an array of id’s to find for downloading’
undefined local variable or method `download’ for [RSpec
example]:#Class:0x34939e8
./spec/controllers/admin/orders_controller_spec.rb:14:
Al
----- Original Message ----
From: Jarkko L. [email protected]
To: rspec-users [email protected]
Sent: Tuesday, December 4, 2007 12:33:11 AM
Subject: Re: [rspec-users] params not available for controller specs?
On 4.12.2007, at 10.17, Al Chou wrote:
Hi, all,
I’m trying to write a spec for a controller method that starts out:
def download
@orders = Order.find( params[:ids] )
…and started writing a spec that set params[:ids] to a mock.
Why would you want to set params[:ids] to a mock? params values are
always basically strings (or hashes/arrays of strings) and you can set
them in the actual action call:
get :foo, :ids => [1,2,3]
Moreover, in your case Order.find should be the thing you want to
stub. You don’t want the finder call to go to the database, since
you’re speccing the controller behaviour here, not business logic.
//jarkko
–
Jarkko L.
http://www.railsecommerce.com
http://odesign.fi
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping