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. I was surprised to discover that controller specs (at least in RSpec 1.0.8) don''t offer the use of the params object (per http://rspec.rubyforge.org/documentation/rails/writing/controllers.html), though assigns, flash, and session are available. Maybe I''m missing something, but it seems to me that it would be helpful if controller specs could use params also.... Al ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/027571ab/attachment.html
Jarkko Laine
2007-Dec-04 08:33 UTC
[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 Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
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 Laine <jarkko at jlaine.net> To: rspec-users <rspec-users at rubyforge.org> 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 Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/4ad4f71a/attachment.html
Daniel Tenner
2007-Dec-04 09:56 UTC
[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 Laine <jarkko at jlaine.net> > To: rspec-users <rspec-users at rubyforge.org> > 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 Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > Never miss a thing. Make Yahoo your homepage. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/49a1610a/attachment.html
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 Tenner <daniel.ruby at tenner.org> To: rspec-users <rspec-users at rubyforge.org> 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 Laine <jarkko at jlaine.net> To: rspec-users <rspec-users at rubyforge.org> 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 Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/68c50619/attachment-0001.html
Jarkko Laine
2007-Dec-04 15:31 UTC
[rspec-users] params not available for controller specs?
On 4.12.2007, at 17.13, Al Chou wrote:> 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.You don''t get the same object through the action queue, which is another reason for not mocking something there. "string 1" is not necessarily the same object as "string 1" and Rails will do a lot of processing to the parameters before they end up in the params hash. Just assume that a similar string will get passed through and spec that the behaviour is what you expect. What kind of method calls are you expecting/stubbing for a string? //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
Going back to my original message, I have the following at the beginning of the download method: def download @orders = Order.find( params[:ids] ) ... The problem is that params[:ids], although built as an Array object by the view that calls the download method on the controller, is passed as a /-delimited string of id values. Order.find() will not do the desired thing with that string, which was intended to be an array by the view, but Rails passed it in a string representation. So the method really should be def download @orders = Order.find( params[:ids].split( ''/'' ) ) and what I''m trying to spec is the addition of the call to split(). Al ----- Original Message ---- From: Jarkko Laine <jarkko at jlaine.net> To: rspec-users <rspec-users at rubyforge.org> Sent: Tuesday, December 4, 2007 7:31:11 AM Subject: Re: [rspec-users] params not available for controller specs? On 4.12.2007, at 17.13, Al Chou wrote:> 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.You don''t get the same object through the action queue, which is another reason for not mocking something there. "string 1" is not necessarily the same object as "string 1" and Rails will do a lot of processing to the parameters before they end up in the params hash. Just assume that a similar string will get passed through and spec that the behaviour is what you expect. What kind of method calls are you expecting/stubbing for a string? //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/dab6cd6b/attachment.html
Jarkko Laine
2007-Dec-04 18:09 UTC
[rspec-users] params not available for controller specs?
On 4.12.2007, at 18.19, Al Chou wrote:> Going back to my original message, I have the following at the > beginning of the download method: > > def download > @orders = Order.find( params[:ids] ) > ... > > The problem is that params[:ids], although built as an Array object > by the view that calls the download method on the controller, is > passed as a /-delimited string of id values.If I set <%= link_to "Test", :controller => "clients", :foo => [1, 2, 3, 4, 5] %> I get this as the url: http://localhost:3000/en/clients?foo%5B%5D=1&foo%5B%5D=2&foo%5B%5D=3&foo%5B%5D=4&foo%5B%5D=5 That will get correctly parsed back to an array in the receiving action: Parameters: {"action"=>"index", "foo"=>["1", "2", "3", "4", "5"], "controller"=>"clients", "locale"=>"en"} This is Edge Rails, though, so YMMV.> Order.find() will not do the desired thing with that string, which > was intended to be an array by the view, but Rails passed it in a > string representation. So the method really should be > > def download > @orders = Order.find( params[:ids].split( ''/'' ) ) > > and what I''m trying to spec is the addition of the call to split().IMHO there''s no need to stub string methods like that. Just do something like this: Order.should_receive(:find).with(%w(1 2 3)).and_return(@some_order_objects) If params[:ids] is "1/2/3", you can be pretty certain that split("/") will work correctly so you''re more interested in that the find method gets called with correct set of attributes, an array. It''s not really interesting how that array got to be. In this case, you might notice that somehow params[:ids] is an array after all and you can take the split call away, and the spec will still pass. I guess what I''m trying to say is that the split call is part of the controller action''s internal implementation, and you should be spec''ing how it behaves related to its surrounding world: fetches stuff from the business model, assigns objects for the view etc. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
I get what you''re saying, but I was trying to fix a bug in existing code in Substruct (that I did not write) that was caused by Rails passing the array as a /-delimited string and then not automatically decoding that string. As Substruct does not say that Edge Rails is a requirement, I felt it was worth documenting what I had to change to run it on Rails 1.2.x. Every code change should be driven by a test or example; perhaps in this situation I should''ve gone over to Test::Unit instead of staying in RSpec? An interesting philosophical thought.... Al ----- Original Message ---- From: Jarkko Laine <jarkko at jlaine.net> To: rspec-users <rspec-users at rubyforge.org> Sent: Tuesday, December 4, 2007 10:09:01 AM Subject: Re: [rspec-users] params not available for controller specs? On 4.12.2007, at 18.19, Al Chou wrote:> Going back to my original message, I have the following at the > beginning of the download method: > > def download > @orders = Order.find( params[:ids] ) > ... > > The problem is that params[:ids], although built as an Array object > by the view that calls the download method on the controller, is > passed as a /-delimited string of id values.If I set <%= link_to "Test", :controller => "clients", :foo => [1, 2, 3, 4, 5] %> I get this as the url: http://localhost:3000/en/clients?foo%5B%5D=1&foo%5B%5D=2&foo%5B%5D=3&foo%5B%5D=4&foo%5B%5D=5 That will get correctly parsed back to an array in the receiving action: Parameters: {"action"=>"index", "foo"=>["1", "2", "3", "4", "5"], "controller"=>"clients", "locale"=>"en"} This is Edge Rails, though, so YMMV.> Order.find() will not do the desired thing with that string, which> was intended to be an array by the view, but Rails passed it in a > string representation. So the method really should be > > def download > @orders = Order.find( params[:ids].split( ''/'' ) ) > > and what I''m trying to spec is the addition of the call to split().IMHO there''s no need to stub string methods like that. Just do something like this: Order.should_receive(:find).with(%w(1 2 3)).and_return(@some_order_objects) If params[:ids] is "1/2/3", you can be pretty certain that split("/") will work correctly so you''re more interested in that the find method gets called with correct set of attributes, an array. It''s not really interesting how that array got to be. In this case, you might notice that somehow params[:ids] is an array after all and you can take the split call away, and the spec will still pass. I guess what I''m trying to say is that the split call is part of the controller action''s internal implementation, and you should be spec''ing how it behaves related to its surrounding world: fetches stuff from the business model, assigns objects for the view etc. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ____________________________________________________________________________________ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/ee360c0a/attachment.html
David Chelimsky
2007-Dec-04 20:18 UTC
[rspec-users] params not available for controller specs?
On Dec 4, 2007 2:09 PM, Al Chou <hotfusionman at yahoo.com> wrote:> > I get what you''re saying, but I was trying to fix a bug in existing code in > Substruct (that I did not write) that was caused by Rails passing the array > as a /-delimited string and then not automatically decoding that string. As > Substruct does not say that Edge Rails is a requirement, I felt it was worth > documenting what I had to change to run it on Rails 1.2.x. Every code > change should be driven by a test or example; perhaps in this situation I > should''ve gone over to Test::Unit instead of staying in RSpec? An > interesting philosophical thought....Seems to me this thread has been about how to deal with rails. I don''t see what that has to do w/ a T::U vs rspec decision.> > Al > > > > ----- Original Message ---- > From: Jarkko Laine <jarkko at jlaine.net> > To: rspec-users <rspec-users at rubyforge.org> > Sent: Tuesday, December 4, 2007 10:09:01 AM > Subject: Re: [rspec-users] params not available for controller specs? > > > On 4.12.2007, at 18.19, Al Chou wrote: > > > Going back to my original message, I have the following at the > > beginning of the download method: > > > > def download > > @orders = Order.find( params[:ids] ) > > ... > > > > The problem is that params[:ids], although built as an Array object > > by the view that calls the download method on the controller, is > > passed as a /-delimited string of id values. > > If I set > > <%= link_to "Test", :controller => "clients", :foo => [1, 2, 3, 4, > 5] %> > > I get this as the url: > > http://localhost:3000/en/clients?foo%5B%5D=1&foo%5B%5D=2&foo%5B%5D=3&foo%5B%5D=4&foo%5B%5D=5 > > That will get correctly parsed back to an array in the receiving action: > > Parameters: {"action"=>"index", "foo"=>["1", "2", "3", "4", "5"], > "controller"=>"clients", "locale"=>"en"} > > This is Edge Rails, though, so YMMV. > > > Order.find() will not do the desired thing with that string, which > > was intended to be an array by the view, but Rails passed it in a > > string representation. So the method really should be > > > > def download > > @orders = Order.find( params[:ids].split( ''/'' ) ) > > > > and what I''m trying to spec is the addition of the call to split(). > > IMHO there''s no need to stub string methods like that. Just do > something like this: > > Order.should_receive(:find).with(%w(1 2 > 3)).and_return(@some_order_objects) > > If params[:ids] is "1/2/3", you can be pretty certain that split("/") > will work correctly so you''re more interested in that the find method > gets called with correct set of attributes, an array. It''s not really > interesting how that array got to be. In this case, you might notice > that somehow params[:ids] is an array after all and you can take the > split call away, and the spec will still pass. > > I guess what I''m trying to say is that the split call is part of the > controller action''s internal implementation, and you should be > spec''ing how it behaves related to its surrounding world: fetches > stuff from the business model, assigns objects for the view etc. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > ________________________________ > Never miss a thing. Make Yahoo your homepage. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
I think Jarkko is saying that no spec should have been written for the code I was trying to fix/change. I''m not sure I would agree that BDD/RSpec is an inappropriate tool for documenting what I was trying to change, but I think he would argue that.... Al ----- Original Message ---- From: David Chelimsky <dchelimsky at gmail.com> To: rspec-users <rspec-users at rubyforge.org> Sent: Tuesday, December 4, 2007 12:18:58 PM Subject: Re: [rspec-users] params not available for controller specs? On Dec 4, 2007 2:09 PM, Al Chou <hotfusionman at yahoo.com> wrote:> > I get what you''re saying, but I was trying to fix a bug in existingcode in> Substruct (that I did not write) that was caused by Rails passing thearray> as a /-delimited string and then not automatically decoding thatstring. As> Substruct does not say that Edge Rails is a requirement, I felt itwas worth> documenting what I had to change to run it on Rails 1.2.x. Everycode> change should be driven by a test or example; perhaps in thissituation I> should''ve gone over to Test::Unit instead of staying in RSpec? An > interesting philosophical thought....Seems to me this thread has been about how to deal with rails. I don''t see what that has to do w/ a T::U vs rspec decision.> > Al > > > > ----- Original Message ---- > From: Jarkko Laine <jarkko at jlaine.net> > To: rspec-users <rspec-users at rubyforge.org> > Sent: Tuesday, December 4, 2007 10:09:01 AM > Subject: Re: [rspec-users] params not available for controller specs? > > > On 4.12.2007, at 18.19, Al Chou wrote: > > > Going back to my original message, I have the following at the > > beginning of the download method: > > > > def download > > @orders = Order.find( params[:ids] ) > > ... > > > > The problem is that params[:ids], although built as an Array object > > by the view that calls the download method on the controller, is > > passed as a /-delimited string of id values. > > If I set > > <%= link_to "Test", :controller => "clients", :foo => [1, 2, 3, 4, > 5] %> > > I get this as the url: > >http://localhost:3000/en/clients?foo%5B%5D=1&foo%5B%5D=2&foo%5B%5D=3&foo%5B%5D=4&foo%5B%5D=5> > That will get correctly parsed back to an array in the receivingaction:> > Parameters: {"action"=>"index", "foo"=>["1", "2", "3", "4", "5"], > "controller"=>"clients", "locale"=>"en"} > > This is Edge Rails, though, so YMMV. > > > Order.find() will not do the desired thing with that string, which > > was intended to be an array by the view, but Rails passed it in a > > string representation. So the method really should be > > > > def download > > @orders = Order.find( params[:ids].split( ''/'' ) ) > > > > and what I''m trying to spec is the addition of the call to split(). > > IMHO there''s no need to stub string methods like that. Just do > something like this: > > Order.should_receive(:find).with(%w(1 2 > 3)).and_return(@some_order_objects) > > If params[:ids] is "1/2/3", you can be pretty certain that split("/") > will work correctly so you''re more interested in that the find method > gets called with correct set of attributes, an array. It''s not really > interesting how that array got to be. In this case, you might notice > that somehow params[:ids] is an array after all and you can take the > split call away, and the spec will still pass. > > I guess what I''m trying to say is that the split call is part of the > controller action''s internal implementation, and you should be > spec''ing how it behaves related to its surrounding world: fetches > stuff from the business model, assigns objects for the view etc. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users____________________________________________________________________________________ Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/6ebf9704/attachment.html
Jarkko Laine
2007-Dec-04 21:49 UTC
[rspec-users] params not available for controller specs?
On 4.12.2007, at 23.11, Al Chou wrote:> I think Jarkko is saying that no spec should have been written for > the code I was trying to fix/change. I''m not sure I would agree > that BDD/RSpec is an inappropriate tool for documenting what I was > trying to change, but I think he would argue that....What I was saying was that I think it''s important that Order.find gets called with an array of ids. That''s what you want to happen and to have in your spec, right? So in your spec, you''d have it "should find orders with an array of ids" do Order.should_receive(:find).with(["1", "2", "3"]) get :download, :ids => "1/2/3" end (or whatever ids you pass to the action). Now, if the current, buggy behaviour just passes the string as "1/2/3" to Order.find, the spec above will break, because it will not receive an array but a string. After you add the split("/") call to the actual code, your broken spec is fixed, and the code works as expected. Tada! No need to stub String#split anywhere. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
OK, I see your strategy now. Rather than mock the String argument, mock Order to confirm that it gets called with an array. Nice! Al ----- Original Message ---- From: Jarkko Laine <jarkko at jlaine.net> To: rspec-users <rspec-users at rubyforge.org> Sent: Tuesday, December 4, 2007 1:49:17 PM Subject: Re: [rspec-users] params not available for controller specs? On 4.12.2007, at 23.11, Al Chou wrote:> I think Jarkko is saying that no spec should have been written for > the code I was trying to fix/change. I''m not sure I would agree > that BDD/RSpec is an inappropriate tool for documenting what I was > trying to change, but I think he would argue that....What I was saying was that I think it''s important that Order.find gets called with an array of ids. That''s what you want to happen and to have in your spec, right? So in your spec, you''d have it "should find orders with an array of ids" do Order.should_receive(:find).with(["1", "2", "3"]) get :download, :ids => "1/2/3" end (or whatever ids you pass to the action). Now, if the current, buggy behaviour just passes the string as "1/2/3" to Order.find, the spec above will break, because it will not receive an array but a string. After you add the split("/") call to the actual code, your broken spec is fixed, and the code works as expected. Tada! No need to stub String#split anywhere. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/b0971fe6/attachment.html