[rspec-users] what's the different between ([@weather]) and (@weather)?

Andrea Jahn anja-email1 at web.de
Thu Mar 26 03:44:22 EDT 2009



 

Hi,

Weather.find(1) returns an object: @weather
Weather.find(:all) returns an array of objects : [@weather] 

look at the api of ActiveRecordBase. http://api.rubyonrails.org/classes/ActiveRecord/Base.html [http://api.rubyonrails.org/classes/ActiveRecord/Base.html]

You have not specified a parameter for the find method here, so you expect, that
the find methods you are using, will all return an array of objects.

In the spec you can also define the expected parameters:

Weather.stub!(:find).with(*:all*,* :order* => "title").and_return([@weather])



Andrea
*Von:* "Zhenning Guan" <lists at ruby-forum.com>
*Gesendet:* 26.03.09 07:54:56
*An:* rspec-users at rubyforge.org
*Betreff:* [rspec-users] what's the different between ([@weather]) and (@weather)?



before do
@weather = mock_model(Weather)
Weather.stub!(:find).and_return([@weather])
end

I saw this code on peepcode, but I'm a little confused the
and_return([@weather]).
mostly, we just and_return(@weather), don't we? so, what is the meaning
of and_return([@weather]) ?
-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
	



	
Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele 
ausländische Netze zum gleichen Preis! 
https://produkte.web.de/webde_sms/sms 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090326/a07090af/attachment.html>


More information about the rspec-users mailing list